General cleanup of compiler directory and ParseHelper.
Review URL: http://codereview.appspot.com/4801084

git-svn-id: https://angleproject.googlecode.com/svn/trunk@730 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/common/version.h b/src/common/version.h
index db97b05..4d0d58b 100644
--- a/src/common/version.h
+++ b/src/common/version.h
@@ -1,7 +1,7 @@
 #define MAJOR_VERSION 0
 #define MINOR_VERSION 0
 #define BUILD_VERSION 0
-#define BUILD_REVISION 729
+#define BUILD_REVISION 730
 
 #define STRINGIFY(x) #x
 #define MACRO_STRINGIFY(x) STRINGIFY(x)
diff --git a/src/compiler/ParseHelper.cpp b/src/compiler/ParseHelper.cpp
index e2141c6..dd997fc 100644
--- a/src/compiler/ParseHelper.cpp
+++ b/src/compiler/ParseHelper.cpp
@@ -196,7 +196,6 @@
 //
 void TParseContext::recover()
 {
-    recoveredFromError = true;
 }
 
 //
diff --git a/src/compiler/ParseHelper.h b/src/compiler/ParseHelper.h
index 7efc23f..b85eb81 100644
--- a/src/compiler/ParseHelper.h
+++ b/src/compiler/ParseHelper.h
@@ -32,8 +32,8 @@
 struct TParseContext {
     TParseContext(TSymbolTable& symt, TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, int options, bool checksPrecErrors, const char* sourcePath, TInfoSink& is) :
             intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), shaderType(type), shaderSpec(spec), compileOptions(options), checksPrecisionErrors(checksPrecErrors), sourcePath(sourcePath), treeRoot(0),
-            recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
-            inTypeParen(false), scanner(NULL), contextPragma(true, false) {  }
+            numErrors(0), lexAfterType(false), loopNestingLevel(0),
+            inTypeParen(false), contextPragma(true, false), scanner(NULL) {  }
     TIntermediate& intermediate; // to hold and build a parse tree
     TSymbolTable& symbolTable;   // symbol table that goes with the language currently being parsed
     TExtensionBehavior& extensionBehavior;  // mapping between supported extensions and current behavior.
@@ -43,7 +43,6 @@
     int compileOptions;
     const char* sourcePath;      // Path of source file or NULL.
     TIntermNode* treeRoot;       // root of parse tree being created
-    bool recoveredFromError;     // true if a parse error has occurred, but we continue to parse
     int numErrors;
     bool lexAfterType;           // true if we've recognized a type, so can only be looking for an identifier
     int loopNestingLevel;        // 0 if outside all loops
@@ -51,16 +50,21 @@
     const TType* currentFunctionType;  // the return type of the function that's currently being parsed
     bool functionReturnsValue;   // true if a non-void function has a return
     bool checksPrecisionErrors;  // true if an error will be generated when a variable is declared without precision, explicit or implicit.
+    struct TPragma contextPragma;
+    TString HashErrMsg;
+    bool AfterEOF;
+    void* scanner;
 
     void error(TSourceLoc loc, const char *reason, const char* token,
                const char* extraInfoFormat, ...);
     void warning(TSourceLoc loc, const char* reason, const char* token,
                  const char* extraInfoFormat, ...);
-    bool reservedErrorCheck(int line, const TString& identifier);
     void recover();
 
     bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line);
     bool parseMatrixFields(const TString&, int matSize, TMatrixFields&, int line);
+
+    bool reservedErrorCheck(int line, const TString& identifier);
     void assignError(int line, const char* op, TString left, TString right);
     void unaryOpError(int line, const char* op, TString operand);
     void binaryOpError(int line, const char* op, TString left, TString right);
@@ -80,16 +84,19 @@
     bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason);
     bool structQualifierErrorCheck(int line, const TPublicType& pType);
     bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type);
-    bool containsSampler(TType& type);
     bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type);
     bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type, TVariable*& variable);
     bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
     bool extensionErrorCheck(int line, const TString&);
     bool supportsExtension(const char* extension);
+
+    bool containsSampler(TType& type);
+    bool areAllChildConst(TIntermAggregate* aggrNode);
     const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0);
     bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType,
                             TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
-    bool areAllChildConst(TIntermAggregate* aggrNode);
+    bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
+
     TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, TSourceLoc);
     TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type);
     TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset);
@@ -98,11 +105,6 @@
     TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
     TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line);
     TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
-    bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
-    void* scanner;
-    struct TPragma contextPragma;
-    TString HashErrMsg;
-    bool AfterEOF;
 };
 
 int PaParseStrings(int count, const char* const string[], const int length[],
diff --git a/src/compiler/generate_glslang_lexer.sh b/src/compiler/generate_glslang_lexer.sh
deleted file mode 100755
index 268479d..0000000
--- a/src/compiler/generate_glslang_lexer.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2010 The ANGLE Project Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Generates GLSL ES lexer - glslang_lex.cpp
-
-script_dir=$(dirname $0)
-input_file=$script_dir/glslang.l
-output_file=$script_dir/glslang_lex.cpp
-flex --noline --nounistd --outfile=$output_file $input_file
diff --git a/src/compiler/generate_glslang_parser.sh b/src/compiler/generate_glslang_parser.sh
deleted file mode 100755
index 889f5c0..0000000
--- a/src/compiler/generate_glslang_parser.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2010 The ANGLE Project Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Generates GLSL ES parser - glslang_tab.h and glslang_tab.cpp
-
-script_dir=$(dirname $0)
-input_file=$script_dir/glslang.y
-output_header=$script_dir/glslang_tab.h
-output_source=$script_dir/glslang_tab.cpp
-bison --no-lines --skeleton=yacc.c --defines=$output_header --output=$output_source $input_file
diff --git a/src/compiler/generate_parser.sh b/src/compiler/generate_parser.sh
new file mode 100755
index 0000000..e472191
--- /dev/null
+++ b/src/compiler/generate_parser.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# Copyright (c) 2010 The ANGLE Project Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Generates GLSL ES parser - glslang_lex.cpp, glslang_tab.h, and glslang_tab.cpp
+
+run_flex()
+{
+input_file=$script_dir/$1.l
+output_source=$script_dir/$1_lex.cpp
+flex --noline --nounistd --outfile=$output_source $input_file
+}
+
+run_bison()
+{
+input_file=$script_dir/$1.y
+output_header=$script_dir/$1_tab.h
+output_source=$script_dir/$1_tab.cpp
+bison --no-lines --skeleton=yacc.c --defines=$output_header --output=$output_source $input_file
+}
+
+script_dir=$(dirname $0)
+
+# Generate Parser
+run_flex glslang
+run_bison glslang
diff --git a/src/compiler/glslang.l b/src/compiler/glslang.l
index f7ecb23..1eaa30c 100644
--- a/src/compiler/glslang.l
+++ b/src/compiler/glslang.l
@@ -9,7 +9,7 @@
 Based on ANSI C grammar, Lex specification:
 http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
 
-IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_lexer.sh,
+IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh,
 WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
 */
 
@@ -20,7 +20,7 @@
 // found in the LICENSE file.
 //
 
-// This file is auto-generated by generate_glslang_lexer.sh. DO NOT EDIT!
+// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
 }
 
 %{
diff --git a/src/compiler/glslang.y b/src/compiler/glslang.y
index c86fdf0..f073452 100644
--- a/src/compiler/glslang.y
+++ b/src/compiler/glslang.y
@@ -9,7 +9,7 @@
 Based on ANSI C Yacc grammar:
 http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
 
-IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_parser.sh,
+IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh,
 WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
 */
 
@@ -20,7 +20,7 @@
 // found in the LICENSE file.
 //
 
-// This file is auto-generated by generate_glslang_parser.sh. DO NOT EDIT!
+// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
 
 #include "compiler/SymbolTable.h"
 #include "compiler/ParseHelper.h"
diff --git a/src/compiler/glslang_lex.cpp b/src/compiler/glslang_lex.cpp
index 1448ce1..7866056 100644
--- a/src/compiler/glslang_lex.cpp
+++ b/src/compiler/glslang_lex.cpp
@@ -1,15 +1,15 @@
-#line 17 "./glslang.l"
+#line 17 "compiler/glslang.l"
 //
 // Copyright (c) 2010 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
-// This file is auto-generated by generate_glslang_lexer.sh. DO NOT EDIT!
+// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
 
 
 
-#line 13 "./glslang_lex.cpp"
+#line 13 "compiler/glslang_lex.cpp"
 
 #define  YY_INT_ALIGNED short int
 
@@ -179,11 +179,6 @@
 typedef struct yy_buffer_state *YY_BUFFER_STATE;
 #endif
 
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
 #define EOB_ACT_CONTINUE_SCAN 0
 #define EOB_ACT_END_OF_FILE 1
 #define EOB_ACT_LAST_MATCH 2
@@ -219,6 +214,11 @@
 
 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
 
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
 #ifndef YY_STRUCT_YY_BUFFER_STATE
 #define YY_STRUCT_YY_BUFFER_STATE
 struct yy_buffer_state
@@ -236,7 +236,7 @@
 	/* Number of characters read into yy_ch_buf, not including EOB
 	 * characters.
 	 */
-	yy_size_t yy_n_chars;
+	int yy_n_chars;
 
 	/* Whether we "own" the buffer - i.e., we know we created it,
 	 * and can realloc() it to grow it, and should free() it to
@@ -315,7 +315,7 @@
 
 YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
 YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
 
 void *yyalloc (yy_size_t ,yyscan_t yyscanner );
 void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
@@ -764,7 +764,7 @@
 Based on ANSI C grammar, Lex specification:
 http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
 
-IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_lexer.sh,
+IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh,
 WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
 */
 
@@ -805,8 +805,8 @@
     size_t yy_buffer_stack_max; /**< capacity of stack. */
     YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
     char yy_hold_char;
-    yy_size_t yy_n_chars;
-    yy_size_t yyleng_r;
+    int yy_n_chars;
+    int yyleng_r;
     char *yy_c_buf_p;
     int yy_init;
     int yy_start;
@@ -859,7 +859,7 @@
 
 void yyset_out  (FILE * out_str ,yyscan_t yyscanner );
 
-yy_size_t yyget_leng (yyscan_t yyscanner );
+int yyget_leng (yyscan_t yyscanner );
 
 char *yyget_text (yyscan_t yyscanner );
 
@@ -928,7 +928,7 @@
 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
 		{ \
 		int c = '*'; \
-		yy_size_t n; \
+		int n; \
 		for ( n = 0; n < max_size && \
 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
 			buf[n] = (char) c; \
@@ -1889,7 +1889,7 @@
 
 	else
 		{
-			yy_size_t num_to_read =
+			int num_to_read =
 			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
 
 		while ( num_to_read <= 0 )
@@ -1903,7 +1903,7 @@
 
 			if ( b->yy_is_our_buffer )
 				{
-				yy_size_t new_size = b->yy_buf_size * 2;
+				int new_size = b->yy_buf_size * 2;
 
 				if ( new_size <= 0 )
 					b->yy_buf_size += b->yy_buf_size / 8;
@@ -1934,7 +1934,7 @@
 
 		/* Read in more data. */
 		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
-			yyg->yy_n_chars, num_to_read );
+			yyg->yy_n_chars, (size_t) num_to_read );
 
 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
 		}
@@ -2059,7 +2059,7 @@
 
 		else
 			{ /* need more input */
-			yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+			int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
 			++yyg->yy_c_buf_p;
 
 			switch ( yy_get_next_buffer( yyscanner ) )
@@ -2083,7 +2083,7 @@
 				case EOB_ACT_END_OF_FILE:
 					{
 					if ( yywrap(yyscanner ) )
-						return 0;
+						return EOF;
 
 					if ( ! yyg->yy_did_buffer_switch_on_eof )
 						YY_NEW_FILE;
@@ -2346,7 +2346,7 @@
  */
 static void yyensure_buffer_stack (yyscan_t yyscanner)
 {
-	yy_size_t num_to_alloc;
+	int num_to_alloc;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
 	if (!yyg->yy_buffer_stack) {
@@ -2444,11 +2444,12 @@
  * @param yyscanner The scanner object.
  * @return the newly allocated buffer state object.
  */
-YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
 {
 	YY_BUFFER_STATE b;
 	char *buf;
-	yy_size_t n, i;
+	yy_size_t n;
+	int i;
     
 	/* Get memory for full buffer, including space for trailing EOB's. */
 	n = _yybytes_len + 2;
@@ -2598,7 +2599,7 @@
 /** Get the length of the current token.
  * @param yyscanner The scanner object.
  */
-yy_size_t yyget_leng  (yyscan_t yyscanner)
+int yyget_leng  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     return yyleng;
diff --git a/src/compiler/glslang_tab.cpp b/src/compiler/glslang_tab.cpp
index e1f033e..6e54e96 100644
--- a/src/compiler/glslang_tab.cpp
+++ b/src/compiler/glslang_tab.cpp
@@ -266,7 +266,7 @@
 // found in the LICENSE file.
 //
 
-// This file is auto-generated by generate_glslang_parser.sh. DO NOT EDIT!
+// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
 
 #include "compiler/SymbolTable.h"
 #include "compiler/ParseHelper.h"
@@ -327,7 +327,7 @@
         };
     } interm;
 }
-/* Line 193 of yacc.c.  */
+/* Line 187 of yacc.c.  */
 
 	YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -417,7 +417,7 @@
 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
 
 #ifndef YY_
-# if defined YYENABLE_NLS && YYENABLE_NLS
+# if YYENABLE_NLS
 #  if ENABLE_NLS
 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
@@ -1373,7 +1373,7 @@
    we won't break user code: when these are the locations we know.  */
 
 #ifndef YY_LOCATION_PRINT
-# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
+# if YYLTYPE_IS_TRIVIAL
 #  define YY_LOCATION_PRINT(File, Loc)			\
      fprintf (File, "%d.%d-%d.%d",			\
 	      (Loc).first_line, (Loc).first_column,	\
diff --git a/src/compiler/glslang_tab.h b/src/compiler/glslang_tab.h
index 185dc84..55c271c 100644
--- a/src/compiler/glslang_tab.h
+++ b/src/compiler/glslang_tab.h
@@ -264,7 +264,7 @@
         };
     } interm;
 }
-/* Line 1529 of yacc.c.  */
+/* Line 1489 of yacc.c.  */
 
 	YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */