HLSL: Separate out token stream handling from grammar recognition.

This commit is contained in:
John Kessenich 2016-05-03 22:49:24 -06:00
parent e512cd943e
commit 9c86c6ab5b
5 changed files with 143 additions and 38 deletions

View file

@ -36,29 +36,25 @@
#ifndef HLSLGRAMMAR_H_
#define HLSLGRAMMAR_H_
#include "hlslScanContext.h"
#include "hlslParseHelper.h"
#include "hlslTokenStream.h"
namespace glslang {
// Should just be the grammar aspect of HLSL.
// Described in more detail in hlslGrammar.cpp.
class HlslGrammar {
class HlslGrammar : public HlslTokenStream {
public:
HlslGrammar(HlslScanContext& scanner, HlslParseContext& parseContext)
: scanner(scanner), parseContext(parseContext), intermediate(parseContext.intermediate) { }
: HlslTokenStream(scanner), parseContext(parseContext), intermediate(parseContext.intermediate) { }
virtual ~HlslGrammar() { }
bool parse();
protected:
void expected(const char*);
void advanceToken();
bool acceptTokenClass(EHlslTokenClass);
bool peekTokenClass(EHlslTokenClass);
bool acceptIdentifier(HlslToken&);
bool acceptCompilationUnit();
bool acceptDeclaration(TIntermNode*& node);
bool acceptFullySpecifiedType(TType&);
@ -76,11 +72,8 @@ namespace glslang {
bool acceptStatement(TIntermNode*&);
bool acceptSemantic();
HlslScanContext& scanner; // lexical scanner, to get next token
HlslParseContext& parseContext; // state of parsing and helper functions for building the intermediate
TIntermediate& intermediate; // the final product, the intermediate representation, includes the AST
HlslToken token; // the current token we are processing
};
} // end namespace glslang