Brain  1.0.0
A fast esoteric language!
Parser.h
1 /* This is the source code of Brain Programming Language.
2  * It is licensed under GNU GPL v. 3 or later.
3  * You should have received a copy of the license in this archive (see LICENSE).
4  *
5  * Copyright Brain, 2016.
6  */
7 
8 #ifndef PARSER_H
9 #define PARSER_H
10 
11 #include <llvm/IR/IRBuilder.h>
12 #include <llvm/IR/Module.h>
13 
14 #include <string>
15 #include <vector>
16 
17 #include "../ast/general/ASTInfo.h"
18 #include "../ast/expr/Expr.h"
19 #include "../utils/ArgsOptions.h"
20 
25 class Parser
26 {
27 protected:
29  std::string _data;
31  int _index;
36  std::vector<Expr *> _exprs;
37 
43  void parse(std::vector<Expr *> &exprs, int level);
44 public:
51  explicit Parser(std::string source) :
52  _data(source), _index(0) { parse(_exprs, 0); }
59  void code_gen(llvm::Module *M, llvm::IRBuilder<> &B);
66  void debug_description(int level);
71  void ast_code_gen();
72 };
73 
74 #endif // PARSER_H
std::string _data
The content of the source file passed to Brain.
Definition: Parser.h:29
void ast_code_gen()
Method for the reverse code generation from the AST. It prints out to the stdout the token itself...
Definition: Parser.cpp:176
void code_gen(llvm::Module *M, llvm::IRBuilder<> &B)
Generates the IR (Intermediate Representation) code to be executed by llvm.
Definition: Parser.cpp:159
void parse(std::vector< Expr * > &exprs, int level)
It parses the Brain code.
Definition: Parser.cpp:23
The parser of the Brain language, it interpretes *.b, *.br or *.brain files.
Definition: Parser.h:25
Parser(std::string source)
Calls parse to create all expressions found in the source code.
Definition: Parser.h:51
std::vector< Expr * > _exprs
Definition: Parser.h:36
void debug_description(int level)
Prints debug information when Brain&#39;s compiler has the active flags: -v | -emit-ast.
Definition: Parser.cpp:168
int _index
Variable that holds the current index read by the parser.
Definition: Parser.h:31