ztsdb
parser_ctx.hpp
1 // (C) 2016 Leonardo Silvestri
2 //
3 // This file is part of ztsdb.
4 //
5 // ztsdb is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // ztsdb is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with ztsdb. If not, see <http://www.gnu.org/licenses/>.
17 
18 
19 #ifndef PARSER_CTX_HPP
20 #define PARSER_CTX_HPP
21 
22 
23 #include "location.hpp"
24 #include "ast.hpp"
25 
26 
27 class ParserCtx {
28 public:
29  ParserCtx();
30 
31  // Run the parser on file F.
32  // Return 0 on success.
33  int parsefile(const std::string& filename);
34  int parse(const std::shared_ptr<const std::string> s_p);
35 
39  void error(const yy::location& l, const std::string& m);
40 
41  ~ParserCtx();
42 
43  // The name of the file being parsed.
44  // Used later to pass the file name to the location tracker.
45  std::string file;
46 
49  bool trace_parsing;
50 
51  bool ignore_nl;
52  std::unique_ptr<El> prog;
53 
54  yy::location loc;
57  std::string string_literal;
58 
59  std::shared_ptr<const std::string> s;
60 
61  yy::location errorLoc;
62  std::string errorString;
63 
64 };
65 
66 
67 #endif
ParserCtx::error
void error(const yy::location &l, const std::string &m)
Definition: parser_ctx.cpp:71
ParserCtx
Definition: parser_ctx.hpp:27
yy::location
Abstract a location.
Definition: location.hpp:54
ParserCtx::trace_scanning
bool trace_scanning
Whether scanner/parser traces should be generated.
Definition: parser_ctx.hpp:48
location.hpp
ParserCtx::string_literal
std::string string_literal
Definition: parser_ctx.hpp:57