#include "ParsedSource.h"
#include "Tokenizer.h"
+#include <fstream>
#include <iosfwd>
#include <stdexcept>
#include <string>
class Parser {
public:
- Parser(std::istream &in, ParsedSource &product) : tok(in), product(product) { }
+ Parser(const char *file, ParsedSource &product)
+ : file(file), in(file), tok(in), product(product) { }
~Parser() { }
private:
Parser(const Parser &);
void Parse();
public:
- class ParseError: public std::runtime_error {
+ class Error: public std::runtime_error {
public:
- explicit ParseError(const std::string &msg) : std::runtime_error(msg) { };
+ Error(const char *file, int line, const std::string &msg)
+ : std::runtime_error(msg), file(file), line(line) { };
+ const char *File() const { return file; }
+ int Line() const { return line; }
+ private:
+ const char *file;
+ int line;
};
private:
+ Tokenizer::Token GetToken();
void ParseStatement();
void ParseExportDirective();
void ParseIncludeDirective();
bool BeginOfPropertyList(const Tokenizer::Token &) const;
private:
+ const char *file;
+ std::ifstream in;
Tokenizer tok;
ParsedSource &product;