4 * Created on: Aug 26, 2012
8 #ifndef LOADER_PARSER_H_
9 #define LOADER_PARSER_H_
11 #include "ParsedSource.h"
12 #include "Tokenizer.h"
29 Parser(const std::string &file, ParsedSource &product);
32 Parser(const Parser &);
33 Parser &operator =(const Parser &);
39 class Error: public std::runtime_error {
41 Error(const std::string &file, int line, const std::string &msg)
42 : std::runtime_error(msg), file(file), line(line) { };
44 const std::string &File() const { return file; }
45 int Line() const { return line; }
52 Tokenizer::Token GetToken();
53 void ParseStatement();
54 void ParseExportDirective();
55 void ParseIncludeDirective();
57 Declaration *ProbeDefinition();
58 Definition *ParseDefinition();
60 std::string ParseIdentifier();
61 std::string ParseTypeName();
64 PropertyList *ParsePropertyList();
65 Literal *ParseLiteral();
66 Literal *ParseArray();
67 Literal *ParseColor();
68 Literal *ParseVector();
71 void AssertTokenType(Tokenizer::Token::Type actual, Tokenizer::Token::Type expected);
72 void AssertTokenType(Tokenizer::Token::Type actual, Tokenizer::Token::Type expected, const std::string &msg);
73 bool BeginningOfLiteral(const Tokenizer::Token &) const;
74 bool BeginOfPropertyList(const Tokenizer::Token &) const;
81 ParsedSource &product;
87 #endif /* LOADER_PARSER_H_ */