| 1 |
#ifndef Parser_h_included |
| 2 |
#define Parser_h_included |
| 3 |
|
| 4 |
// for error()'s inline implementation |
| 5 |
#include <iostream> |
| 6 |
|
| 7 |
// for mfcalc's memory |
| 8 |
#include <map> |
| 9 |
#include <string> |
| 10 |
|
| 11 |
// $insert baseclass |
| 12 |
#include "Parserbase.h" |
| 13 |
|
| 14 |
|
| 15 |
#undef Parser |
| 16 |
class Parser: public ParserBase |
| 17 |
{ |
| 18 |
using FunctionPair = std::pair<char const *, double (*)(double)>; |
| 19 |
|
| 20 |
std::map<std::string, double> d_symbols; |
| 21 |
|
| 22 |
static std::map<std::string, double (*)(double)> s_functions; |
| 23 |
static FunctionPair s_funTab[]; |
| 24 |
|
| 25 |
public: |
| 26 |
int parse(); |
| 27 |
|
| 28 |
private: |
| 29 |
void error() |
| 30 |
{ |
| 31 |
std::cerr << "Syntax error\n"; |
| 32 |
} |
| 33 |
|
| 34 |
// $insert lex |
| 35 |
int lex(); |
| 36 |
|
| 37 |
void print() // d_token, d_loc |
| 38 |
{} |
| 39 |
|
| 40 |
// support functions for parse(): |
| 41 |
void executeAction_(int ruleNr); |
| 42 |
void errorRecovery_(); |
| 43 |
void nextCycle_(); |
| 44 |
void nextToken_(); |
| 45 |
void print_(); |
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
#endif |