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 char *file, ParsedSource &product)
30 : file(file), in(file), tok(in), product(product) { }
33 Parser(const Parser &);
34 Parser &operator =(const Parser &);
40 class Error: public std::runtime_error {
42 Error(const char *file, int line, const std::string &msg)
43 : std::runtime_error(msg), file(file), line(line) { };
44 const char *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;
80 ParsedSource &product;
86 #endif /* LOADER_PARSER_H_ */