1 #ifndef LOADER_PARSER_H_
2 #define LOADER_PARSER_H_
13 #include "Tokenizer.h"
25 Parser(const std::string &file, ParsedSource &product);
28 Parser(const Parser &);
29 Parser &operator =(const Parser &);
35 class Error: public std::runtime_error {
37 Error(const std::string &file, int line, const std::string &msg)
38 : std::runtime_error(msg), file(file), line(line) { };
40 const std::string &File() const { return file; }
41 int Line() const { return line; }
48 Tokenizer::Token GetToken();
49 void ParseStatement();
50 void ParseExportDirective();
51 void ParseIncludeDirective();
53 Declaration *ProbeDefinition();
54 Definition *ParseDefinition();
56 std::string ParseIdentifier();
57 std::string ParseTypeName();
60 PropertyList *ParsePropertyList();
61 Literal *ParseLiteral();
62 Literal *ParseArray();
63 Literal *ParseColor();
64 Literal *ParseVector();
65 Literal *ParseScript();
68 void AssertTokenType(Tokenizer::Token::Type actual, Tokenizer::Token::Type expected);
69 void AssertTokenType(Tokenizer::Token::Type actual, Tokenizer::Token::Type expected, const std::string &msg);
70 bool BeginningOfLiteral(const Tokenizer::Token &) const;
71 bool BeginningOfPrimitiveLiteral(const Tokenizer::Token &) const;
72 bool BeginOfPropertyList(const Tokenizer::Token &) const;
73 bool BeginningOfScriptLiteral(const Tokenizer::Token &) const;
80 ParsedSource &product;