Start work on parser code generation
This commit is contained in:
parent
99a6561db2
commit
562d780f9a
7 changed files with 583 additions and 4 deletions
21
spec/code_gen_spec.cpp
Normal file
21
spec/code_gen_spec.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include "spec_helper.h"
|
||||
#include "test_grammars/arithmetic.h"
|
||||
#include "parse_table_builder.h"
|
||||
#include "parse_table.h"
|
||||
#include "c_code.h"
|
||||
#include <fstream>
|
||||
|
||||
using namespace std;
|
||||
using namespace tree_sitter::lr;
|
||||
using namespace tree_sitter;
|
||||
|
||||
Describe(code_generation) {
|
||||
string test_parser_dir = src_dir() + "/spec/test_parsers";
|
||||
|
||||
It(works_for_the_arithmetic_grammar) {
|
||||
Grammar grammar = test_grammars::arithmetic();
|
||||
ParseTable table = ParseTableBuilder::build_table(grammar);
|
||||
std::ofstream parser_file(test_parser_dir + "/arithmetic.c");
|
||||
parser_file << code_gen::c_code(grammar, table);
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue