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);
32 Parser(const Parser &);
33 Parser &operator =(const Parser &);
39 class Error: public std::runtime_error {
41 Error(const char *file, int line, const std::string &msg)
42 : std::runtime_error(msg), file(file), line(line) { };
43 const char *File() const { return file; }
44 int Line() const { return line; }
51 Tokenizer::Token GetToken();
52 void ParseStatement();
53 void ParseExportDirective();
54 void ParseIncludeDirective();
56 Declaration *ProbeDefinition();
57 Definition *ParseDefinition();
59 std::string ParseIdentifier();
60 std::string ParseTypeName();
63 PropertyList *ParsePropertyList();
64 Literal *ParseLiteral();
65 Literal *ParseArray();
66 Literal *ParseColor();
67 Literal *ParseVector();
70 void AssertTokenType(Tokenizer::Token::Type actual, Tokenizer::Token::Type expected);
71 void AssertTokenType(Tokenizer::Token::Type actual, Tokenizer::Token::Type expected, const std::string &msg);
72 bool BeginningOfLiteral(const Tokenizer::Token &) const;
73 bool BeginOfPropertyList(const Tokenizer::Token &) const;
79 ParsedSource &product;
85 #endif /* LOADER_PARSER_H_ */