Remove most of the remaining logic from glslang.y

Move most of the logic in glslang.y to ParseContext. This will make it
easier to change the code in the future.

Only a few specific bits of logic are kept in glslang.y:

* Disabling a parsing rule when a given shading language version is
  being parsed. This makes it easier to check the grammar against the
  grammar in the GLSL ES specs.
* Scoping calls that need to be paired with another call. It's much
  easier to check these for correctness when the paired calls are next
  to each other.

BUG=angleproject:911
TEST=angle_unittests

Change-Id: I52f42a1fc0f28463ca4b237dc6e88345e5173064
Reviewed-on: https://chromium-review.googlesource.com/539640
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/ParseContext.h b/src/compiler/translator/ParseContext.h
index d0d7ed5..a7fe95d 100644
--- a/src/compiler/translator/ParseContext.h
+++ b/src/compiler/translator/ParseContext.h
@@ -193,6 +193,10 @@
                          TIntermNode *body,
                          const TSourceLoc &loc);
 
+    // For "if" test nodes. There are three children: a condition, a true path, and a false path.
+    // The two paths are in TIntermNodePair code.
+    TIntermNode *addIfElse(TIntermTyped *cond, TIntermNodePair code, const TSourceLoc &loc);
+
     void addFullySpecifiedType(TPublicType *typeSpecifier);
     TPublicType addFullySpecifiedType(const TTypeQualifierBuilder &typeQualifierBuilder,
                                       const TPublicType &typeSpecifier);
@@ -254,7 +258,11 @@
                                   TIntermTyped *initializer,
                                   TIntermDeclaration *declarationOut);
 
+    void parseDefaultPrecisionQualifier(const TPrecision precision,
+                                        const TPublicType &type,
+                                        const TSourceLoc &loc);
     void parseGlobalLayoutQualifier(const TTypeQualifierBuilder &typeQualifierBuilder);
+
     TIntermFunctionPrototype *addFunctionPrototypeDeclaration(const TFunction &parsedFunction,
                                                               const TSourceLoc &location);
     TIntermFunctionDefinition *addFunctionDefinition(TIntermFunctionPrototype *functionPrototype,
@@ -267,7 +275,16 @@
     TFunction *parseFunctionHeader(const TPublicType &type,
                                    const TString *name,
                                    const TSourceLoc &location);
+    TFunction *addNonConstructorFunc(const TString *name, const TSourceLoc &loc);
     TFunction *addConstructorFunc(const TPublicType &publicType);
+    TParameter parseParameterDeclarator(const TPublicType &publicType,
+                                        const TString *name,
+                                        const TSourceLoc &nameLoc);
+    TParameter parseParameterArrayDeclarator(const TString *identifier,
+                                             const TSourceLoc &identifierLoc,
+                                             TIntermTyped *arraySize,
+                                             const TSourceLoc &arrayLoc,
+                                             TPublicType *type);
 
     TIntermTyped *addIndexExpression(TIntermTyped *baseExpression,
                                      const TSourceLoc &location,
@@ -277,6 +294,13 @@
                                               const TString &fieldString,
                                               const TSourceLoc &fieldLocation);
 
+    // Parse declarator for a single field
+    TField *parseStructDeclarator(TString *identifier, const TSourceLoc &loc);
+    TField *parseStructArrayDeclarator(TString *identifier,
+                                       const TSourceLoc &loc,
+                                       TIntermTyped *arraySize,
+                                       const TSourceLoc &arraySizeLoc);
+
     TFieldList *combineStructFieldLists(TFieldList *processedFields,
                                         const TFieldList *newlyAddedFields,
                                         const TSourceLoc &location);
@@ -317,6 +341,12 @@
                                           int intValue,
                                           const TSourceLoc &intValueLine);
     TTypeQualifierBuilder *createTypeQualifierBuilder(const TSourceLoc &loc);
+    TStorageQualifierWrapper *parseGlobalStorageQualifier(TQualifier qualifier,
+                                                          const TSourceLoc &loc);
+    TStorageQualifierWrapper *parseVaryingQualifier(const TSourceLoc &loc);
+    TStorageQualifierWrapper *parseInQualifier(const TSourceLoc &loc);
+    TStorageQualifierWrapper *parseOutQualifier(const TSourceLoc &loc);
+    TStorageQualifierWrapper *parseInOutQualifier(const TSourceLoc &loc);
     TLayoutQualifier joinLayoutQualifiers(TLayoutQualifier leftQualifier,
                                           TLayoutQualifier rightQualifier,
                                           const TSourceLoc &rightQualifierLocation);
@@ -351,7 +381,7 @@
     TIntermTyped *addComma(TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
 
     TIntermBranch *addBranch(TOperator op, const TSourceLoc &loc);
-    TIntermBranch *addBranch(TOperator op, TIntermTyped *returnValue, const TSourceLoc &loc);
+    TIntermBranch *addBranch(TOperator op, TIntermTyped *expression, const TSourceLoc &loc);
 
     void checkTextureOffsetConst(TIntermAggregate *functionCall);
     void checkImageMemoryAccessForBuiltinFunctions(TIntermAggregate *functionCall);