4 * Created on: Aug 26, 2012
8 #ifndef LOADER_PARSER_H_
9 #define LOADER_PARSER_H_
12 #include "ParsedSource.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();
67 void AssertTokenType(Tokenizer::Token::Type actual, Tokenizer::Token::Type expected);
68 void AssertTokenType(Tokenizer::Token::Type actual, Tokenizer::Token::Type expected, const std::string &msg);
69 bool BeginningOfLiteral(const Tokenizer::Token &) const;
70 bool BeginningOfPrimitiveLiteral(const Tokenizer::Token &) const;
71 bool BeginOfPropertyList(const Tokenizer::Token &) const;
78 ParsedSource &product;
84 #endif /* LOADER_PARSER_H_ */