diff options
Diffstat (limited to 'src/sksl/SkSLParser.h')
-rw-r--r-- | src/sksl/SkSLParser.h | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/sksl/SkSLParser.h b/src/sksl/SkSLParser.h index 5391f6c2ee..4edd8e4e02 100644 --- a/src/sksl/SkSLParser.h +++ b/src/sksl/SkSLParser.h @@ -14,8 +14,7 @@ #include <unordered_set> #include "SkSLErrorReporter.h" #include "ir/SkSLLayout.h" -#include "SkSLLexer.h" -#include "SkSLLayoutLexer.h" +#include "SkSLToken.h" struct yy_buffer_state; #define YY_TYPEDEF_YY_BUFFER_STATE @@ -52,7 +51,9 @@ class SymbolTable; */ class Parser { public: - Parser(const char* text, size_t length, SymbolTable& types, ErrorReporter& errors); + Parser(String text, SymbolTable& types, ErrorReporter& errors); + + ~Parser(); /** * Consumes a complete .sksl file and produces a list of declarations. Errors are reported via @@ -61,15 +62,13 @@ public: */ std::vector<std::unique_ptr<ASTDeclaration>> file(); - StringFragment text(Token token); - - Position position(Token token); - private: /** - * Return the next token, including whitespace tokens, from the parse stream. + * Return the next token, including whitespace tokens, from the parse stream. If needText is + * false, the token's text is only filled in if it is a token with variable text (identifiers, + * numbers, etc.). */ - Token nextRawToken(); + Token nextRawToken(bool needText); /** * Return the next non-whitespace token from the parse stream. @@ -104,15 +103,15 @@ private: * Returns true if the read token was as expected, false otherwise. */ bool expect(Token::Kind kind, const char* expected, Token* result = nullptr); - bool expect(Token::Kind kind, String expected, Token* result = nullptr); - void error(Token token, String msg); - void error(int offset, String msg); + void error(Position p, const char* msg); + void error(Position p, String msg); + /** * Returns true if the 'name' identifier refers to a type name. For instance, isType("int") will * always return true. */ - bool isType(StringFragment name); + bool isType(const String& name); // these functions parse individual grammar rules from the current parse position; you probably // don't need to call any of these outside of the parser. The function declarations in the .cpp @@ -134,7 +133,7 @@ private: std::unique_ptr<ASTVarDeclarations> varDeclarationEnd(Modifiers modifiers, std::unique_ptr<ASTType> type, - StringFragment name); + String name); std::unique_ptr<ASTParameter> parameter(); @@ -224,11 +223,10 @@ private: bool boolLiteral(bool* dest); - bool identifier(StringFragment* dest); + bool identifier(String* dest); - const char* fText; - Lexer fLexer; - LayoutLexer fLayoutLexer; + void* fScanner; + void* fLayoutScanner; YY_BUFFER_STATE fBuffer; // current parse depth, used to enforce a recursion limit to try to keep us from overflowing the // stack on pathological inputs |