BenchGen
BenchGen is a tool for generating benchmarks to stress-test a computing system.
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
parser.h
Go to the documentation of this file.
1#ifndef PARSER_H
2#define PARSER_H
3
4#include <iostream>
5#include <stack>
6#include <vector>
7
8#include "../ast/ast.h"
10#include "../shared/enums.h"
12
21class Parser {
22 private:
23 int tokenIndex; // Index of the current token being processed
24 std::vector<Token> tokens; // Vector holding the sequence of tokens to be parsed
25 std::shared_ptr<Node> AST; // The root of the abstract syntax tree (AST)
26 std::stack<Call*> currentCall; // Stack to track the number of conditionals within a function call, enabling accurate counting of PATH parameters for that function.
27
33 void match(int symbol);
34
40 std::shared_ptr<Node> parse_CODE();
41
47 std::shared_ptr<Node> parse_STATEMENT();
48
54 std::shared_ptr<Node> parse_IFPARAM();
55
61 std::shared_ptr<Node> parse_ELSE();
62
63 public:
70 tokenIndex = 0;
71 AST = nullptr;
72 currentCall = std::stack<Call*>();
73 }
74
82 void setTokens(std::vector<Token> _tokens);
83
90 void parse();
91
99 std::shared_ptr<Node> getAST();
100};
101
102#endif
The Parser class is responsible for parsing a sequence of tokens and constructing an abstract syntax ...
Definition parser.h:21
Parser()
Constructs a Parser object with default values.
Definition parser.h:69
void parse()
Initiates the parsing process and builds the abstract syntax tree (AST).
Definition parser.cpp:151
void setTokens(std::vector< Token > _tokens)
Sets the tokens for the parser to process.
Definition parser.cpp:147
std::shared_ptr< Node > getAST()
Returns the root of the abstract syntax tree (AST).
Definition parser.cpp:155