-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.cpp
57 lines (40 loc) · 1.34 KB
/
parser.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/***********************************************************************\
*
* Contents:
* Systems: all
*
\***********************************************************************/
/****************************** Includes *******************************/
#include <stdio.h>
#include <stdarg.h>
#include <iostream>
#include "location.h"
#include "scanner.h"
#include "parser.h"
#include "ast.h"
using namespace FSM;
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/***************************** Forwards ********************************/
/****************************** Macros *********************************/
/***************************** Functions *******************************/
#include "parser.tab.c"
Parser::Parser(const std::string &inputFilePath, FSM::Scanner &scanner, FSM::AST &ast, bool debug)
{
extern int yydebug;
(void)yydebug; // Note: avoid warning
::inputFilePath = &inputFilePath;
::scanner = &scanner;
::ast = *
::yydebug = debug ? 1 : 0;
}
void Parser::parse()
{
if (::yyparse() != 0)
{
throw std::runtime_error("parsing failed");
}
}
/* end of file */