| 1 |
#ifndef Parser_h_included |
| 2 |
#define Parser_h_included |
| 3 |
|
| 4 |
// $insert baseclass |
| 5 |
#include "parserbase.h" |
| 6 |
// $insert scanner.h |
| 7 |
#include "../scanner/scanner.h" |
| 8 |
|
| 9 |
|
| 10 |
#undef Parser |
| 11 |
class Parser: public ParserBase |
| 12 |
{ |
| 13 |
// $insert scannerobject |
| 14 |
Scanner d_scanner; |
| 15 |
|
| 16 |
public: |
| 17 |
Parser(); |
| 18 |
int parse(); |
| 19 |
|
| 20 |
private: |
| 21 |
void error(char const *msg); // called on (syntax) errors |
| 22 |
int lex(); // returns the next token from the |
| 23 |
// lexical scanner. |
| 24 |
void print(); // use, e.g., d_token, d_loc |
| 25 |
|
| 26 |
// support functions for parse(): |
| 27 |
void executeAction(int ruleNr); |
| 28 |
void errorRecovery(); |
| 29 |
int lookup(bool recovery); |
| 30 |
void nextToken(); |
| 31 |
}; |
| 32 |
|
| 33 |
inline void Parser::error(char const *msg) |
| 34 |
{ |
| 35 |
std::cerr << msg << '\n'; |
| 36 |
} |
| 37 |
|
| 38 |
// $insert lex |
| 39 |
inline int Parser::lex() |
| 40 |
{ |
| 41 |
return d_scanner.yylex(); |
| 42 |
} |
| 43 |
|
| 44 |
inline void Parser::print() // use d_token, d_loc |
| 45 |
{} |
| 46 |
|
| 47 |
inline Parser::Parser() |
| 48 |
: |
| 49 |
d_scanner(&d_val__) |
| 50 |
{} |
| 51 |
|
| 52 |
|
| 53 |
#endif |