Gymbo

pipeline.h
Go to the documentation of this file.
1
7 #pragma once
8 #include "compiler.h"
9
10 namespace gymbo {
11
33 inline std::pair<std::unordered_map<std::string, int>, Prog> gcompile(
34 char *user_input) {
35 std::unordered_map<std::string, int> var_counter;
36 std::vector<gymbo::Node *> code;
37 Prog prg;
38
39 Token *token = tokenize(user_input, var_counter);
40 generate_ast(token, user_input, code);
41 compile_ast(code, prg);
42
43 return std::make_pair(var_counter, prg);
44 }
45
46 } // namespace gymbo
compiler.h
Implementation of compiler.
gymbo
Definition: compiler.h:11
gymbo::compile_ast
void compile_ast(std::vector< Node * > code, Prog &prg)
Compile the Abstract Syntax Tree (AST) into a sequence of instructions.
Definition: compiler.h:133
gymbo::generate_ast
void generate_ast(Token *&token, char *user_input, std::vector< Node * > &code)
Parses a C-like language program into an AST.
Definition: parser.h:439
gymbo::gcompile
std::pair< std::unordered_map< std::string, int >, Prog > gcompile(char *user_input)
Compiles user input into a program, returning variable counts and the compiled program.
Definition: pipeline.h:33
gymbo::tokenize
Token * tokenize(char *user_input, std::unordered_map< std::string, int > &var_counter)
Tokenizes a given string and returns a linked list of tokens.
Definition: tokenizer.h:222
gymbo::Prog
std::vector< Instr > Prog
Alias for a program, represented as a vector of instructions.
Definition: type.h:143
gymbo::Token
Structure representing a token.
Definition: tokenizer.h:89