glsl: fix typo in the vec2 += operator function
[mesa.git] / src / mesa / shader / slang / library / slang_shader.syn
index 883bfe42816bcb102ad4700860c97e079bf69883..0ad4a1cba62ab4a283f16c20896335629827828d 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
  *
  * Copyright (C) 2004-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2008 VMware, Inc.  All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -59,7 +59,7 @@
 .syntax translation_unit;
 
 /* revision number - increment after each change affecting emitted output */
-.emtcode REVISION                                   4
+.emtcode REVISION                                   5
 
 /* external declaration (or precision or invariant stmt) */
 .emtcode EXTERNAL_NULL                              0
 .emtcode FUNCTION_CONSTRUCTOR                       1
 .emtcode FUNCTION_OPERATOR                          2
 
+/* function call type */
+.emtcode FUNCTION_CALL_NONARRAY                     0
+.emtcode FUNCTION_CALL_ARRAY                        1
+
 /* operator type */
 .emtcode OPERATOR_ADDASSIGN                         1
 .emtcode OPERATOR_SUBASSIGN                         2
 .emtcode TYPE_QUALIFIER_FIXEDOUTPUT                 5
 .emtcode TYPE_QUALIFIER_FIXEDINPUT                  6
 
+/* invariant qualifier */
+.emtcode TYPE_VARIANT                               90
+.emtcode TYPE_INVARIANT                             91
+
+/* centroid qualifier */
+.emtcode TYPE_CENTER                                95
+.emtcode TYPE_CENTROID                              96
+
 /* type specifier */
 .emtcode TYPE_SPECIFIER_VOID                        0
 .emtcode TYPE_SPECIFIER_BOOL                        1
 .emtcode TYPE_SPECIFIER_MAT34                       30
 .emtcode TYPE_SPECIFIER_MAT43                       31
 
+/* type specifier array */
+.emtcode TYPE_SPECIFIER_NONARRAY                    0
+.emtcode TYPE_SPECIFIER_ARRAY                       1
 
 /* structure field */
 .emtcode FIELD_NONE                                 0
 .emtcode OP_POSTINCREMENT                           60
 .emtcode OP_POSTDECREMENT                           61
 .emtcode OP_PRECISION                               62
+.emtcode OP_METHOD                                  63
 
 /* parameter qualifier */
 .emtcode PARAM_QUALIFIER_IN                         0
@@ -331,6 +347,25 @@ integer_expression
  * <function_call> ::= <function_call_generic>
  */
 function_call
+    function_call_or_method;
+
+/*
+ * <function_call_or_method> ::= <regular_function_call>
+ *                             | <postfix_expression> "." <function_call_generic>
+ */
+function_call_or_method
+    regular_function_call .or method_call;
+
+/*
+ * <method_call> ::= <identifier> "." <function_call_generic>
+ */
+method_call
+    identifier .emit OP_METHOD .and dot .and function_call_generic .and .true .emit OP_END;
+
+/*
+ * <regular_function_call> ::= <function_call_generic>
+ */
+regular_function_call
     function_call_generic .emit OP_CALL .and .true .emit OP_END;
 
 /*
@@ -372,11 +407,17 @@ function_call_header
 /*
  * <function_identifier> ::= <constructor_identifier>
  *                         | <identifier>
+ *                         | <type_specifier>
  *
- * note: <constructor_identifier> has been deleted
+ * note: <constructor_identifier> and <type_specifier> have been deleted
  */
 function_identifier
-    identifier;
+    identifier .and function_identifier_opt_array;
+function_identifier_opt_array
+    function_identifier_array .emit FUNCTION_CALL_ARRAY .or
+    .true .emit FUNCTION_CALL_NONARRAY;
+function_identifier_array
+    lbracket .and constant_expression .and rbracket;
 
 /*
  * <unary_expression> ::= <postfix_expression>
@@ -829,10 +870,8 @@ parameter_type_specifier_3
  * <init_declarator_list> ::= <single_declaration>
  *                          | <init_declarator_list> "," <identifier>
  *                          | <init_declarator_list> "," <identifier> "[" "]"
- *                          | <init_declarator_list> "," <identifier> "["
- *                            <constant_expression> "]"
- *                          | <init_declarator_list> "," <identifier> "="
- *                            <initializer>
+ *                          | <init_declarator_list> "," <identifier> "[" <constant_expression> "]"
+ *                          | <init_declarator_list> "," <identifier> "=" <initializer>
  */
 init_declarator_list
     single_declaration .and .loop init_declarator_list_1 .emit DECLARATOR_NEXT .and
@@ -852,10 +891,9 @@ init_declarator_list_5
  * <single_declaration> ::= <fully_specified_type>
  *                        | <fully_specified_type> <identifier>
  *                        | <fully_specified_type> <identifier> "[" "]"
- *                        | <fully_specified_type> <identifier> "["
- *                          <constant_expression> "]"
+ *                        | <fully_specified_type> <identifier> "[" <constant_expression> "]"
  *                        | <fully_specified_type> <identifier> "=" <initializer>
-*/
+ */
 single_declaration
     single_declaration_nospace .or single_declaration_space;
 single_declaration_space
@@ -880,15 +918,22 @@ single_declaration_6
     constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
 
 /*
- * <fully_specified_type> ::= <type_specifier>
- *                          | <type_qualifier> <type_specifier>
- *                          | <precision> <type_specifier>
- *                          | <type_qualifier> <precision> <type_specifier>
+ * <fully_specified_type> ::= <opt_invariant> <opt_centroid> <opt_qualifer> <opt_precision> <type_specifier>
+ *
+ * Example: "invariant varying highp vec3"
  */
 fully_specified_type_space
-    fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;
+    fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;
 fully_specified_type_nospace
-    fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;
+    fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;
+fully_specified_type_optinvariant
+    fully_specified_type_invariant .or .true .emit TYPE_VARIANT;
+fully_specified_type_invariant
+    invariant_qualifier .and space;
+fully_specified_type_optcentroid
+    fully_specified_type_centroid .or .true .emit TYPE_CENTER;
+fully_specified_type_centroid
+    centroid_qualifier .and space;
 fully_specified_type_optqual
     fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;
 fully_specified_type_qual
@@ -899,12 +944,22 @@ fully_specified_type_prec
     precision .and space;
 
 /*
- *  <type_qualifier> ::= "const"
- *                     | "attribute" // Vertex only.
- *                     | "varying"
- *                     | "uniform"
- *                     | "__fixed_output"
- *                     | "__fixed_input"
+ * <invariant_qualifier> ::= "invariant"
+ */
+invariant_qualifier
+    "invariant" .emit TYPE_INVARIANT;
+
+centroid_qualifier
+    "centroid" .emit TYPE_CENTROID;
+
+
+/*
+ * <type_qualifier> ::= "const"
+ *                    | "attribute" // Vertex only.
+ *                    | "varying"
+ *                    | "uniform"
+ *                    | "__fixed_output"
+ *                    | "__fixed_input"
  *
  * note: this is an extension to the standard language specification,
  * normally slang disallows __fixed_output and __fixed_input type qualifiers
@@ -918,40 +973,40 @@ type_qualifier
     .if (parsing_builtin != 0) "__fixed_input" .emit TYPE_QUALIFIER_FIXEDINPUT;
 
 /*
- * <type_specifier> ::= "void"
- *                    | "float"
- *                    | "int"
- *                    | "bool"
- *                    | "vec2"
- *                    | "vec3"
- *                    | "vec4"
- *                    | "bvec2"
- *                    | "bvec3"
- *                    | "bvec4"
- *                    | "ivec2"
- *                    | "ivec3"
- *                    | "ivec4"
- *                    | "mat2"
- *                    | "mat3"
- *                    | "mat4"
- *                    | "mat2x3"
- *                    | "mat3x2"
- *                    | "mat2x4"
- *                    | "mat4x2"
- *                    | "mat3x4"
- *                    | "mat4x3"
- *                    | "sampler1D"
- *                    | "sampler2D"
- *                    | "sampler3D"
- *                    | "samplerCube"
- *                    | "sampler1DShadow"
- *                    | "sampler2DShadow"
- *                    | "sampler2DRect"
- *                    | "sampler2DRectShadow"
- *                    | <struct_specifier>
- *                    | <type_name>
- */
-type_specifier_space
+ * <type_specifier_nonarray> ::= "void"
+ *                             | "float"
+ *                             | "int"
+ *                             | "bool"
+ *                             | "vec2"
+ *                             | "vec3"
+ *                             | "vec4"
+ *                             | "bvec2"
+ *                             | "bvec3"
+ *                             | "bvec4"
+ *                             | "ivec2"
+ *                             | "ivec3"
+ *                             | "ivec4"
+ *                             | "mat2"
+ *                             | "mat3"
+ *                             | "mat4"
+ *                             | "mat2x3"
+ *                             | "mat3x2"
+ *                             | "mat2x4"
+ *                             | "mat4x2"
+ *                             | "mat3x4"
+ *                             | "mat4x3"
+ *                             | "sampler1D"
+ *                             | "sampler2D"
+ *                             | "sampler3D"
+ *                             | "samplerCube"
+ *                             | "sampler1DShadow"
+ *                             | "sampler2DShadow"
+ *                             | "sampler2DRect"
+ *                             | "sampler2DRectShadow"
+ *                             | <struct_specifier>
+ *                             | <type_name>
+ */
+type_specifier_nonarray_space
     "void" .emit TYPE_SPECIFIER_VOID .or
     "float" .emit TYPE_SPECIFIER_FLOAT .or
     "int" .emit TYPE_SPECIFIER_INT .or
@@ -983,12 +1038,27 @@ type_specifier_space
     "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or
     "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW .or
     type_name .emit TYPE_SPECIFIER_TYPENAME;
-type_specifier_nospace
+type_specifier_nonarray_nospace
     struct_specifier .emit TYPE_SPECIFIER_STRUCT;
+type_specifier_nonarray
+    type_specifier_nonarray_nospace .or type_specifier_nonarray_space;
+
+/*
+ * <type_specifier> ::= <type_specifier_nonarray>
+ *                    | <type_specifier_nonarray> "[" <constant_expression> "]"
+ */
+type_specifier_space
+    type_specifier_nonarray_space .and .true .emit TYPE_SPECIFIER_NONARRAY;
+type_specifier_nospace
+    type_specifier_nospace_array .or type_specifier_nospace_1;
+type_specifier_nospace_1
+    type_specifier_nonarray_nospace .and .true .emit TYPE_SPECIFIER_NONARRAY;
+type_specifier_nospace_array
+    type_specifier_nonarray .and lbracket .emit TYPE_SPECIFIER_ARRAY .and constant_expression .and rbracket;
 
 /*
  * <struct_specifier> ::= "struct" <identifier> "{" <struct_declaration_list> "}"
- *                       | "struct" "{" <struct_declaration_list> "}"
+ *                      | "struct" "{" <struct_declaration_list> "}"
  */
 struct_specifier
     "struct" .and struct_specifier_1 .and optional_space .and lbrace .error LBRACE_EXPECTED .and
@@ -1000,7 +1070,7 @@ struct_specifier_2
 
 /*
  * <struct_declaration_list> ::= <struct_declaration>
- *                              | <struct_declaration_list> <struct_declaration>
+ *                             | <struct_declaration_list> <struct_declaration>
  */
 struct_declaration_list
     struct_declaration .and .loop struct_declaration .emit FIELD_NEXT;
@@ -1017,7 +1087,7 @@ struct_declaration_nospace
 
 /*
  * <struct_declarator_list> ::= <struct_declarator>
- *                             | <struct_declarator_list> "," <struct_declarator>
+ *                            | <struct_declarator_list> "," <struct_declarator>
  */
 struct_declarator_list
     struct_declarator .and .loop struct_declarator_list_1 .emit FIELD_NEXT;
@@ -1291,8 +1361,8 @@ translation_unit
  */
 external_declaration
     precision_stmt .emit DEFAULT_PRECISION .or
-    invariant_stmt .emit INVARIANT_STMT .or
     function_definition .emit EXTERNAL_FUNCTION_DEFINITION .or
+    invariant_stmt .emit INVARIANT_STMT .or
     declaration .emit EXTERNAL_DECLARATION;
 
 
@@ -1368,11 +1438,13 @@ identifier
     id_character_first .emit * .and .loop id_character_next .emit * .and .true .emit '\0';
 
 float
-    float_1 .or float_2;
+    float_1 .or float_2 .or float_3;
 float_1
-    float_fractional_constant .and float_optional_exponent_part;
+    float_fractional_constant .and float_optional_exponent_part .and optional_f_suffix;
 float_2
-    float_digit_sequence .and .true .emit '\0' .and float_exponent_part;
+    float_digit_sequence .and .true .emit '\0' .and float_exponent_part .and optional_f_suffix;
+float_3
+    float_digit_sequence .and .true .emit '\0' .and 'f' .emit '\0';
 
 float_fractional_constant
     float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;
@@ -1402,6 +1474,10 @@ float_optional_sign
 float_sign
     '+' .or '-' .emit '-';
 
+optional_f_suffix
+    'f' .or .true;
+
+
 integer
     integer_hex .or integer_oct .or integer_dec;