HLSL: Recognize types declared as identifiers as identifiers.

E.g., in

    float float;
    (float) * float;

The "(float)" is not a type cast, it is an expression.
This commit is contained in:
John Kessenich
2017-06-13 22:22:52 -06:00
parent 91c46c6567
commit 0320d090e2
4 changed files with 127 additions and 76 deletions

View File

@@ -52,7 +52,8 @@ namespace glslang {
class HlslGrammar : public HlslTokenStream {
public:
HlslGrammar(HlslScanContext& scanner, HlslParseContext& parseContext)
: HlslTokenStream(scanner), parseContext(parseContext), intermediate(parseContext.intermediate) { }
: HlslTokenStream(scanner), parseContext(parseContext), intermediate(parseContext.intermediate),
typeIdentifiers(false) { }
virtual ~HlslGrammar() { }
bool parse();
@@ -126,9 +127,11 @@ namespace glslang {
bool acceptDefaultParameterDeclaration(const TType&, TIntermTyped*&);
bool captureBlockTokens(TVector<HlslToken>& tokens);
const char* getTypeString(EHlslTokenClass tokenClass) const;
HlslParseContext& parseContext; // state of parsing and helper functions for building the intermediate
TIntermediate& intermediate; // the final product, the intermediate representation, includes the AST
bool typeIdentifiers; // shader uses some types as identifiers
};
} // end namespace glslang