From 92cec5758f246e8cd77f55f880c09e31780bb232 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Sat, 11 Jan 2014 15:14:17 -0800 Subject: [PATCH] Reorganize compiler directory --- .../{lr => build_tables}/item_spec.cpp | 2 +- .../perform_spec.cpp} | 5 +- .../rule_transitions_spec.cpp} | 26 +- spec/compiler/compile_fixtures.cpp | 17 ++ spec/compiler/generate_parsers.cpp | 26 -- .../{grammar => }/prepare_grammar_spec.cpp | 7 +- spec/compiler/rules/pattern_spec.cpp | 1 - spec/compiler/rules/rules_spec.cpp | 2 +- src/compiler/{lr => build_tables}/item.cpp | 8 +- src/compiler/{lr => build_tables}/item.h | 6 +- .../{lr => build_tables}/item_set.cpp | 6 +- src/compiler/{lr => build_tables}/item_set.h | 8 +- .../perform.cpp} | 8 +- .../perform.h} | 4 +- .../rule_transitions.cpp} | 18 +- .../rule_transitions.h} | 4 +- .../{util => build_tables}/transition_map.h | 0 src/compiler/{util => }/char_match.cpp | 0 src/compiler/{util => }/char_match.h | 0 src/compiler/compile.cpp | 17 ++ src/compiler/compile.h | 12 + .../{code_gen => generate_code}/c_code.cpp | 3 +- .../{code_gen => generate_code}/c_code.h | 4 +- src/compiler/{grammar => }/grammar.cpp | 0 src/compiler/{grammar => }/grammar.h | 0 src/compiler/grammar/extract_tokens.cpp | 78 ------ src/compiler/grammar/prepare_grammar.cpp | 10 - src/compiler/grammar/search_for_symbols.cpp | 33 --- src/compiler/lex_table.cpp | 67 +++++ src/compiler/lex_table.h | 65 +++++ src/compiler/lr/lex_table.cpp | 70 ------ src/compiler/lr/lex_table.h | 69 ------ src/compiler/lr/parse_table.cpp | 80 ------ src/compiler/lr/parse_table.h | 74 ------ src/compiler/parse_table.cpp | 78 ++++++ src/compiler/parse_table.h | 70 ++++++ .../prepare_grammar/extract_tokens.cpp | 80 ++++++ .../extract_tokens.h | 4 +- src/compiler/prepare_grammar/perform.cpp | 12 + .../perform.h} | 4 +- .../prepare_grammar/search_for_symbols.cpp | 35 +++ .../search_for_symbols.h | 4 +- src/compiler/rules/blank.cpp | 1 - src/compiler/rules/character.cpp | 1 - src/compiler/rules/choice.cpp | 1 - src/compiler/rules/pattern.cpp | 1 - src/compiler/rules/repeat.cpp | 1 - src/compiler/rules/seq.cpp | 1 - src/compiler/rules/string.cpp | 1 - src/compiler/rules/symbol.cpp | 1 - tree_sitter.xcodeproj/project.pbxproj | 229 +++++++++--------- 51 files changed, 630 insertions(+), 624 deletions(-) rename spec/compiler/{lr => build_tables}/item_spec.cpp (95%) rename spec/compiler/{lr/table_builder_spec.cpp => build_tables/perform_spec.cpp} (95%) rename spec/compiler/{lr/transitions_spec.cpp => build_tables/rule_transitions_spec.cpp} (85%) create mode 100644 spec/compiler/compile_fixtures.cpp delete mode 100644 spec/compiler/generate_parsers.cpp rename spec/compiler/{grammar => }/prepare_grammar_spec.cpp (89%) rename src/compiler/{lr => build_tables}/item.cpp (91%) rename src/compiler/{lr => build_tables}/item.h (89%) rename src/compiler/{lr => build_tables}/item_set.cpp (94%) rename src/compiler/{lr => build_tables}/item_set.h (85%) rename src/compiler/{lr/table_builder.cpp => build_tables/perform.cpp} (96%) rename src/compiler/{lr/table_builder.h => build_tables/perform.h} (60%) rename src/compiler/{lr/transitions.cpp => build_tables/rule_transitions.cpp} (73%) rename src/compiler/{lr/transitions.h => build_tables/rule_transitions.h} (56%) rename src/compiler/{util => build_tables}/transition_map.h (100%) rename src/compiler/{util => }/char_match.cpp (100%) rename src/compiler/{util => }/char_match.h (100%) create mode 100644 src/compiler/compile.cpp create mode 100644 src/compiler/compile.h rename src/compiler/{code_gen => generate_code}/c_code.cpp (99%) rename src/compiler/{code_gen => generate_code}/c_code.h (73%) rename src/compiler/{grammar => }/grammar.cpp (100%) rename src/compiler/{grammar => }/grammar.h (100%) delete mode 100644 src/compiler/grammar/extract_tokens.cpp delete mode 100644 src/compiler/grammar/prepare_grammar.cpp delete mode 100644 src/compiler/grammar/search_for_symbols.cpp create mode 100644 src/compiler/lex_table.cpp create mode 100644 src/compiler/lex_table.h delete mode 100644 src/compiler/lr/lex_table.cpp delete mode 100644 src/compiler/lr/lex_table.h delete mode 100644 src/compiler/lr/parse_table.cpp delete mode 100644 src/compiler/lr/parse_table.h create mode 100644 src/compiler/parse_table.cpp create mode 100644 src/compiler/parse_table.h create mode 100644 src/compiler/prepare_grammar/extract_tokens.cpp rename src/compiler/{grammar => prepare_grammar}/extract_tokens.h (56%) create mode 100644 src/compiler/prepare_grammar/perform.cpp rename src/compiler/{grammar/prepare_grammar.h => prepare_grammar/perform.h} (58%) create mode 100644 src/compiler/prepare_grammar/search_for_symbols.cpp rename src/compiler/{grammar => prepare_grammar}/search_for_symbols.h (59%) diff --git a/spec/compiler/lr/item_spec.cpp b/spec/compiler/build_tables/item_spec.cpp similarity index 95% rename from spec/compiler/lr/item_spec.cpp rename to spec/compiler/build_tables/item_spec.cpp index 9b1df071..9029efab 100644 --- a/spec/compiler/lr/item_spec.cpp +++ b/spec/compiler/build_tables/item_spec.cpp @@ -2,7 +2,7 @@ #include "item.h" #include "../../fixtures/grammars/arithmetic.h" -using namespace tree_sitter::lr; +using namespace tree_sitter::build_tables; START_TEST diff --git a/spec/compiler/lr/table_builder_spec.cpp b/spec/compiler/build_tables/perform_spec.cpp similarity index 95% rename from spec/compiler/lr/table_builder_spec.cpp rename to spec/compiler/build_tables/perform_spec.cpp index 63fd9cdb..1c9e22b2 100644 --- a/spec/compiler/lr/table_builder_spec.cpp +++ b/spec/compiler/build_tables/perform_spec.cpp @@ -1,8 +1,7 @@ #include "spec_helper.h" #include -#include "table_builder.h" +#include "build_tables/perform.h" -using namespace tree_sitter::lr; using namespace tree_sitter::rules; typedef unordered_set parse_actions; @@ -36,7 +35,7 @@ describe("building parse and lex tables", []() { { "right-paren", str(")") } }); - pair tables = build_tables(grammar, lex_grammar); + pair tables = build_tables::perform(grammar, lex_grammar); ParseTable table = tables.first; LexTable lex_table = tables.second; diff --git a/spec/compiler/lr/transitions_spec.cpp b/spec/compiler/build_tables/rule_transitions_spec.cpp similarity index 85% rename from spec/compiler/lr/transitions_spec.cpp rename to spec/compiler/build_tables/rule_transitions_spec.cpp index 560f6029..e9ec1baa 100644 --- a/spec/compiler/lr/transitions_spec.cpp +++ b/spec/compiler/build_tables/rule_transitions_spec.cpp @@ -1,5 +1,7 @@ #include "spec_helper.h" -#include "transitions.h" +#include "rule_transitions.h" + +using build_tables::rule_transitions; START_TEST @@ -12,7 +14,7 @@ describe("rule transitions", []() { it("handles symbols", [&]() { AssertThat( - lr::transitions(symbol1), + rule_transitions(symbol1), Equals(transition_map({ { symbol1, rules::blank() } }))); @@ -20,7 +22,7 @@ describe("rule transitions", []() { it("handles characters", [&]() { AssertThat( - lr::transitions(char1), + rule_transitions(char1), Equals(transition_map({ { char1, rules::blank() } }))); @@ -29,7 +31,7 @@ describe("rule transitions", []() { it("handles character classes", [&]() { auto rule = rules::character(CharClassDigit); AssertThat( - lr::transitions(rule), + rule_transitions(rule), Equals(transition_map({ { rule, rules::blank() } }))); @@ -37,7 +39,7 @@ describe("rule transitions", []() { it("handles choices", [&]() { AssertThat( - lr::transitions(rules::choice({ symbol1, symbol2 })), + rule_transitions(rules::choice({ symbol1, symbol2 })), Equals(transition_map({ { symbol1, rules::blank() }, { symbol2, rules::blank() } @@ -46,7 +48,7 @@ describe("rule transitions", []() { it("handles sequences", [&]() { AssertThat( - lr::transitions(rules::seq({ symbol1, symbol2 })), + rule_transitions(rules::seq({ symbol1, symbol2 })), Equals(transition_map({ { symbol1, symbol2 } }))); @@ -54,7 +56,7 @@ describe("rule transitions", []() { it("handles_long_sequences", [&]() { AssertThat( - lr::transitions(rules::seq({ + rule_transitions(rules::seq({ symbol1, symbol2, symbol3, @@ -67,7 +69,7 @@ describe("rule transitions", []() { it("handles choices with common starting symbols", [&]() { AssertThat( - lr::transitions( + rule_transitions( rules::choice({ rules::seq({ symbol1, symbol2 }), rules::seq({ symbol1, symbol3 }) })), @@ -78,7 +80,7 @@ describe("rule transitions", []() { it("handles strings", [&]() { AssertThat( - lr::transitions(rules::str("bad")), + rule_transitions(rules::str("bad")), Equals(transition_map({ { rules::character('b'), rules::seq({ rules::character('a'), rules::character('d') }) } @@ -87,7 +89,7 @@ describe("rule transitions", []() { it("handles patterns", [&]() { AssertThat( - lr::transitions(rules::pattern("a|b")), + rule_transitions(rules::pattern("a|b")), Equals(transition_map({ { rules::character('a'), rules::blank() }, { rules::character('b'), rules::blank() } @@ -97,7 +99,7 @@ describe("rule transitions", []() { it("handles repeats", [&]() { rules::rule_ptr repeat = rules::repeat(rules::str("ab")); AssertThat( - lr::transitions(repeat), + rule_transitions(repeat), Equals(transition_map({ { rules::character('a'), @@ -112,7 +114,7 @@ describe("rule transitions", []() { repeat = rules::repeat(rules::str("a")); AssertThat( - lr::transitions(repeat), + rule_transitions(repeat), Equals(transition_map({ { rules::character('a'), diff --git a/spec/compiler/compile_fixtures.cpp b/spec/compiler/compile_fixtures.cpp new file mode 100644 index 00000000..f674b889 --- /dev/null +++ b/spec/compiler/compile_fixtures.cpp @@ -0,0 +1,17 @@ +#include "spec_helper.h" +#include "compile.h" +#include "../fixtures/grammars/arithmetic.h" +#include + +START_TEST + +describe("code generation", []() { + string test_parser_dir = src_dir() + "/spec/fixtures/parsers"; + + it("works for the arithmetic grammar", [&]() { + Grammar grammar = test_grammars::arithmetic(); + ofstream(test_parser_dir + "/arithmetic.c") << compile(grammar); + }); +}); + +END_TEST \ No newline at end of file diff --git a/spec/compiler/generate_parsers.cpp b/spec/compiler/generate_parsers.cpp deleted file mode 100644 index d26744cc..00000000 --- a/spec/compiler/generate_parsers.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "spec_helper.h" -#include "table_builder.h" -#include "parse_table.h" -#include "prepare_grammar.h" -#include "c_code.h" -#include "../fixtures/grammars/arithmetic.h" -#include - -START_TEST - -describe("code generation", []() { - string test_parser_dir = src_dir() + "/spec/fixtures/parsers"; - - it("works for the arithmetic grammar", [&]() { - Grammar grammar = test_grammars::arithmetic(); - auto grammars = prepare_grammar(grammar); - auto tables = lr::build_tables(grammars.first, grammars.second); - auto rule_names = grammars.first.rule_names(); - auto token_names = grammars.second.rule_names(); - rule_names.insert(rule_names.end(), token_names.begin(), token_names.end()); - auto code = code_gen::c_code(rule_names, tables.first, tables.second); - ofstream(test_parser_dir + "/arithmetic.c") << code; - }); -}); - -END_TEST \ No newline at end of file diff --git a/spec/compiler/grammar/prepare_grammar_spec.cpp b/spec/compiler/prepare_grammar_spec.cpp similarity index 89% rename from spec/compiler/grammar/prepare_grammar_spec.cpp rename to spec/compiler/prepare_grammar_spec.cpp index 52859d9c..131c6867 100644 --- a/spec/compiler/grammar/prepare_grammar_spec.cpp +++ b/spec/compiler/prepare_grammar_spec.cpp @@ -1,13 +1,14 @@ #include "spec_helper.h" -#include "prepare_grammar.h" +#include "prepare_grammar/perform.h" START_TEST using namespace tree_sitter::rules; +using tree_sitter::prepare_grammar::perform; describe("preparing a grammar", []() { it("extracts character-based subtrees into a separate grammar", [&]() { - pair result = prepare_grammar(Grammar({ + pair result = perform(Grammar({ { "rule1", seq({ character('a'), character('b'), @@ -36,7 +37,7 @@ describe("preparing a grammar", []() { }); it("turns entire rules into tokens when they contain no symbols", [&]() { - auto result = prepare_grammar(Grammar({ + auto result = perform(Grammar({ { "rule1", sym("rule2") }, { "rule2", seq({ character('a'), diff --git a/spec/compiler/rules/pattern_spec.cpp b/spec/compiler/rules/pattern_spec.cpp index 69d1bc94..853c02c7 100644 --- a/spec/compiler/rules/pattern_spec.cpp +++ b/spec/compiler/rules/pattern_spec.cpp @@ -1,6 +1,5 @@ #include "spec_helper.h" #include "rules.h" -#include "transition_map.h" using namespace tree_sitter::rules; diff --git a/spec/compiler/rules/rules_spec.cpp b/spec/compiler/rules/rules_spec.cpp index f2c460dd..5d823919 100644 --- a/spec/compiler/rules/rules_spec.cpp +++ b/spec/compiler/rules/rules_spec.cpp @@ -1,5 +1,5 @@ #include "spec_helper.h" -#include "transitions.h" +#include "rule_transitions.h" START_TEST diff --git a/src/compiler/lr/item.cpp b/src/compiler/build_tables/item.cpp similarity index 91% rename from src/compiler/lr/item.cpp rename to src/compiler/build_tables/item.cpp index d09d6d47..12218d81 100644 --- a/src/compiler/lr/item.cpp +++ b/src/compiler/build_tables/item.cpp @@ -1,6 +1,6 @@ #include "item.h" #include "grammar.h" -#include "transitions.h" +#include "rule_transitions.h" using std::string; using std::vector; @@ -9,7 +9,7 @@ using std::make_shared; using std::ostream; namespace tree_sitter { - namespace lr { + namespace build_tables { Item::Item(const string &rule_name, const rules::rule_ptr rule, int consumed_sym_count) : rule_name(rule_name), rule(rule), @@ -24,7 +24,7 @@ namespace tree_sitter { } transition_map Item::transitions() const { - return lr::transitions(rule).map([&](rules::rule_ptr to_rule) -> item_ptr { + return rule_transitions(rule).map([&](rules::rule_ptr to_rule) -> item_ptr { int next_sym_count = (consumed_sym_count == -1) ? -1 : (consumed_sym_count + 1); return make_shared(rule_name, to_rule, next_sym_count); }); @@ -32,7 +32,7 @@ namespace tree_sitter { vector Item::next_symbols() const { vector result; - for (auto pair : lr::transitions(rule)) { + for (auto pair : rule_transitions(rule)) { auto sym = dynamic_pointer_cast(pair.first); if (sym) result.push_back(*sym); } diff --git a/src/compiler/lr/item.h b/src/compiler/build_tables/item.h similarity index 89% rename from src/compiler/lr/item.h rename to src/compiler/build_tables/item.h index 34e463c6..8d65ed86 100644 --- a/src/compiler/lr/item.h +++ b/src/compiler/build_tables/item.h @@ -9,7 +9,7 @@ namespace tree_sitter { class Grammar; - namespace lr { + namespace build_tables { class Item; typedef std::shared_ptr item_ptr; @@ -37,8 +37,8 @@ namespace tree_sitter { namespace std { template<> - struct hash { - size_t operator()(const tree_sitter::lr::Item &item) { + struct hash { + size_t operator()(const tree_sitter::build_tables::Item &item) { return hash()(item.rule_name) ^ hash()(*item.rule) ^ diff --git a/src/compiler/lr/item_set.cpp b/src/compiler/build_tables/item_set.cpp similarity index 94% rename from src/compiler/lr/item_set.cpp rename to src/compiler/build_tables/item_set.cpp index 9dcce663..c950fe34 100644 --- a/src/compiler/lr/item_set.cpp +++ b/src/compiler/build_tables/item_set.cpp @@ -9,11 +9,11 @@ using std::string; using std::make_shared; namespace tree_sitter { - namespace lr { + namespace build_tables { ItemSet::ItemSet(const vector &items) : contents(items) {} ItemSet::ItemSet(const initializer_list &items) : contents(items) {} - static bool vector_contains(vector items, lr::Item item) { + static bool vector_contains(vector items, build_tables::Item item) { return (std::find(items.begin(), items.end(), item) != items.end()); } @@ -66,7 +66,7 @@ namespace tree_sitter { return result; } - bool ItemSet::operator==(const tree_sitter::lr::ItemSet &other) const { + bool ItemSet::operator==(const tree_sitter::build_tables::ItemSet &other) const { return contents == other.contents; } diff --git a/src/compiler/lr/item_set.h b/src/compiler/build_tables/item_set.h similarity index 85% rename from src/compiler/lr/item_set.h rename to src/compiler/build_tables/item_set.h index a2397e32..0df46fa4 100644 --- a/src/compiler/lr/item_set.h +++ b/src/compiler/build_tables/item_set.h @@ -6,7 +6,7 @@ #include namespace tree_sitter { - namespace lr { + namespace build_tables { class ItemSet; typedef std::shared_ptr item_set_ptr; @@ -37,11 +37,11 @@ namespace tree_sitter { namespace std { template<> - struct hash { - size_t operator()(const tree_sitter::lr::ItemSet &item_set) const { + struct hash { + size_t operator()(const tree_sitter::build_tables::ItemSet &item_set) const { size_t result = hash()(item_set.size()); for (auto item : item_set) - result ^= hash()(item); + result ^= hash()(item); return result; } }; diff --git a/src/compiler/lr/table_builder.cpp b/src/compiler/build_tables/perform.cpp similarity index 96% rename from src/compiler/lr/table_builder.cpp rename to src/compiler/build_tables/perform.cpp index 39455a1e..959a640e 100644 --- a/src/compiler/lr/table_builder.cpp +++ b/src/compiler/build_tables/perform.cpp @@ -1,5 +1,5 @@ -#include "table_builder.h" -#include "item_set.h" +#include "./perform.h" +#include "./item_set.h" #include "rules.h" #include "grammar.h" @@ -7,7 +7,7 @@ using std::pair; using std::vector; namespace tree_sitter { - namespace lr { + namespace build_tables { static int NOT_FOUND = -1; class TableBuilder { @@ -113,7 +113,7 @@ namespace tree_sitter { } }; - pair build_tables(const Grammar &grammar, const Grammar &lex_grammar) { + pair perform(const Grammar &grammar, const Grammar &lex_grammar) { return TableBuilder(grammar, lex_grammar).build(); } } diff --git a/src/compiler/lr/table_builder.h b/src/compiler/build_tables/perform.h similarity index 60% rename from src/compiler/lr/table_builder.h rename to src/compiler/build_tables/perform.h index 7f688fa5..33257507 100644 --- a/src/compiler/lr/table_builder.h +++ b/src/compiler/build_tables/perform.h @@ -7,8 +7,8 @@ namespace tree_sitter { class Grammar; - namespace lr { - std::pair build_tables(const Grammar &grammar, const Grammar &lex_grammar); + namespace build_tables { + std::pair perform(const Grammar &grammar, const Grammar &lex_grammar); } } diff --git a/src/compiler/lr/transitions.cpp b/src/compiler/build_tables/rule_transitions.cpp similarity index 73% rename from src/compiler/lr/transitions.cpp rename to src/compiler/build_tables/rule_transitions.cpp index bde7c352..8834c929 100644 --- a/src/compiler/lr/transitions.cpp +++ b/src/compiler/build_tables/rule_transitions.cpp @@ -1,10 +1,10 @@ -#include "transitions.h" +#include "rule_transitions.h" #include "rules.h" using namespace tree_sitter::rules; namespace tree_sitter { - namespace lr { + namespace build_tables { class TransitionsVisitor : public rules::Visitor { public: transition_map value; @@ -22,14 +22,14 @@ namespace tree_sitter { } void visit(const Choice *rule) { - value = transitions(rule->left); - value.merge(transitions(rule->right), [&](rule_ptr left, rule_ptr right) -> rule_ptr { + value = rule_transitions(rule->left); + value.merge(rule_transitions(rule->right), [&](rule_ptr left, rule_ptr right) -> rule_ptr { return choice({ left, right }); }); } void visit(const Seq *rule) { - value = transitions(rule->left).map([&](const rule_ptr left_rule) -> rule_ptr { + value = rule_transitions(rule->left).map([&](const rule_ptr left_rule) -> rule_ptr { if (typeid(*left_rule) == typeid(Blank)) return rule->right; else @@ -38,7 +38,7 @@ namespace tree_sitter { } void visit(const Repeat *rule) { - value = transitions(rule->content).map([&](const rule_ptr &value) -> rule_ptr { + value = rule_transitions(rule->content).map([&](const rule_ptr &value) -> rule_ptr { return seq({ value, choice({ rule->copy(), blank() }) }); }); } @@ -47,15 +47,15 @@ namespace tree_sitter { rule_ptr result = character(rule->value[0]); for (int i = 1; i < rule->value.length(); i++) result = seq({ result, character(rule->value[i]) }); - value = transitions(result); + value = rule_transitions(result); } void visit(const Pattern *rule) { - value = transitions(rule->to_rule_tree()); + value = rule_transitions(rule->to_rule_tree()); } }; - transition_map transitions(const rule_ptr &rule) { + transition_map rule_transitions(const rule_ptr &rule) { TransitionsVisitor visitor; rule->accept(visitor); return visitor.value; diff --git a/src/compiler/lr/transitions.h b/src/compiler/build_tables/rule_transitions.h similarity index 56% rename from src/compiler/lr/transitions.h rename to src/compiler/build_tables/rule_transitions.h index eb9c6834..da627dd2 100644 --- a/src/compiler/lr/transitions.h +++ b/src/compiler/build_tables/rule_transitions.h @@ -5,8 +5,8 @@ #include "transition_map.h" namespace tree_sitter { - namespace lr { - transition_map transitions(const rules::rule_ptr &rule); + namespace build_tables { + transition_map rule_transitions(const rules::rule_ptr &rule); } } diff --git a/src/compiler/util/transition_map.h b/src/compiler/build_tables/transition_map.h similarity index 100% rename from src/compiler/util/transition_map.h rename to src/compiler/build_tables/transition_map.h diff --git a/src/compiler/util/char_match.cpp b/src/compiler/char_match.cpp similarity index 100% rename from src/compiler/util/char_match.cpp rename to src/compiler/char_match.cpp diff --git a/src/compiler/util/char_match.h b/src/compiler/char_match.h similarity index 100% rename from src/compiler/util/char_match.h rename to src/compiler/char_match.h diff --git a/src/compiler/compile.cpp b/src/compiler/compile.cpp new file mode 100644 index 00000000..89551540 --- /dev/null +++ b/src/compiler/compile.cpp @@ -0,0 +1,17 @@ +#include "compile.h" + +#include "grammar.h" +#include "prepare_grammar/perform.h" +#include "build_tables/perform.h" +#include "generate_code/c_code.h" + +namespace tree_sitter { + std::string compile(const Grammar &grammar) { + auto grammars = prepare_grammar::perform(grammar); + auto tables = build_tables::perform(grammars.first, grammars.second); + auto rule_names = grammars.first.rule_names(); + auto token_names = grammars.second.rule_names(); + rule_names.insert(rule_names.end(), token_names.begin(), token_names.end()); + return generate_code::c_code(rule_names, tables.first, tables.second); + } +} diff --git a/src/compiler/compile.h b/src/compiler/compile.h new file mode 100644 index 00000000..dc95c74a --- /dev/null +++ b/src/compiler/compile.h @@ -0,0 +1,12 @@ +#ifndef __tree_sitter__compile__ +#define __tree_sitter__compile__ + +#include + +namespace tree_sitter { + class Grammar; + + std::string compile(const Grammar &grammar); +} + +#endif diff --git a/src/compiler/code_gen/c_code.cpp b/src/compiler/generate_code/c_code.cpp similarity index 99% rename from src/compiler/code_gen/c_code.cpp rename to src/compiler/generate_code/c_code.cpp index e54447ce..4cc4e824 100644 --- a/src/compiler/code_gen/c_code.cpp +++ b/src/compiler/generate_code/c_code.cpp @@ -8,10 +8,9 @@ using std::to_string; using std::unordered_map; using std::unordered_set; using std::vector; -using namespace tree_sitter::lr; namespace tree_sitter { - namespace code_gen { + namespace generate_code { static void str_replace(string &input, const string &search, const string &replace) { size_t pos = 0; while (1) { diff --git a/src/compiler/code_gen/c_code.h b/src/compiler/generate_code/c_code.h similarity index 73% rename from src/compiler/code_gen/c_code.h rename to src/compiler/generate_code/c_code.h index f355b893..e01f91b5 100644 --- a/src/compiler/code_gen/c_code.h +++ b/src/compiler/generate_code/c_code.h @@ -6,8 +6,8 @@ #include "lex_table.h" namespace tree_sitter { - namespace code_gen { - std::string c_code(std::vector rule_names, const lr::ParseTable &parse_table, const lr::LexTable &lex_table); + namespace generate_code { + std::string c_code(std::vector rule_names, const ParseTable &parse_table, const LexTable &lex_table); } } diff --git a/src/compiler/grammar/grammar.cpp b/src/compiler/grammar.cpp similarity index 100% rename from src/compiler/grammar/grammar.cpp rename to src/compiler/grammar.cpp diff --git a/src/compiler/grammar/grammar.h b/src/compiler/grammar.h similarity index 100% rename from src/compiler/grammar/grammar.h rename to src/compiler/grammar.h diff --git a/src/compiler/grammar/extract_tokens.cpp b/src/compiler/grammar/extract_tokens.cpp deleted file mode 100644 index 6de5a5dc..00000000 --- a/src/compiler/grammar/extract_tokens.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "extract_tokens.h" -#include "search_for_symbols.h" -#include - -using std::pair; -using std::string; -using std::to_string; -using std::unordered_map; - -namespace tree_sitter { - class TokenExtractor : rules::Visitor { - public: - rules::rule_ptr value; - size_t anonymous_token_count = 0; - unordered_map tokens; - - rules::rule_ptr initial_apply(string name, const rules::rule_ptr rule) { - auto result = apply(rule); - auto symbol = std::dynamic_pointer_cast(result); - if (symbol && *symbol != *rule) { - tokens.insert({ name, tokens[symbol->name] }); - tokens.erase(symbol->name); - anonymous_token_count--; - return rules::rule_ptr(); - } else { - return result; - } - } - - rules::rule_ptr apply(const rules::rule_ptr rule) { - if (search_for_symbols(rule)) { - rule->accept(*this); - return value; - } else { - string token_name = add_token(rule); - return rules::sym(token_name); - } - } - - string add_token(const rules::rule_ptr &rule) { - for (auto pair : tokens) - if (*pair.second == *rule) - return pair.first; - string name = to_string(++anonymous_token_count); - tokens.insert({ name, rule }); - return name; - } - - void default_visit(const rules::Rule *rule) { - value = rule->copy(); - } - - void visit(const rules::Choice *choice) { - value = rules::choice({ apply(choice->left), apply(choice->right) }); - } - - void visit(const rules::Seq *seq) { - value = rules::seq({ apply(seq->left), apply(seq->right) }); - } - }; - - pair extract_tokens(const Grammar &input_grammar) { - TokenExtractor extractor; - unordered_map rules; - - for (auto pair : input_grammar.rules) { - string name = pair.first; - auto new_rule = extractor.initial_apply(name, pair.second); - if (new_rule.get()) - rules.insert({ name, new_rule }); - } - - return { - Grammar(input_grammar.start_rule_name, rules), - Grammar("", extractor.tokens) - }; - } -} diff --git a/src/compiler/grammar/prepare_grammar.cpp b/src/compiler/grammar/prepare_grammar.cpp deleted file mode 100644 index a1195b35..00000000 --- a/src/compiler/grammar/prepare_grammar.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "prepare_grammar.h" -#include "extract_tokens.h" - -using std::pair; - -namespace tree_sitter { - pair prepare_grammar(const Grammar &input_grammar) { - return extract_tokens(input_grammar); - } -} diff --git a/src/compiler/grammar/search_for_symbols.cpp b/src/compiler/grammar/search_for_symbols.cpp deleted file mode 100644 index a115d5a3..00000000 --- a/src/compiler/grammar/search_for_symbols.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "search_for_symbols.h" - -namespace tree_sitter { - class SymbolSearcher : rules::Visitor { - public: - bool value; - - bool apply(const rules::rule_ptr rule) { - rule->accept(*this); - return value; - } - - void default_visit(const rules::Rule *rule) { - value = false; - } - - void visit(const rules::Symbol *symbol) { - value = true; - } - - void visit(const rules::Choice *choice) { - value = apply(choice->left) || apply(choice->right); - } - - void visit(const rules::Seq *seq) { - value = apply(seq->left) || apply(seq->right); - } - }; - - bool search_for_symbols(const rules::rule_ptr &rule) { - return SymbolSearcher().apply(rule); - } -} \ No newline at end of file diff --git a/src/compiler/lex_table.cpp b/src/compiler/lex_table.cpp new file mode 100644 index 00000000..8ee09dbb --- /dev/null +++ b/src/compiler/lex_table.cpp @@ -0,0 +1,67 @@ +#include "lex_table.h" + +using std::string; +using std::to_string; +using std::unordered_map; +using std::unordered_set; +using std::vector; + +namespace tree_sitter { + // Action + LexAction::LexAction(LexActionType type, size_t state_index, std::string symbol_name) : + type(type), + state_index(state_index), + symbol_name(symbol_name) {} + + LexAction LexAction::Error() { + return LexAction(LexActionTypeError, -1, ""); + } + + LexAction LexAction::Advance(size_t state_index) { + return LexAction(LexActionTypeAdvance, state_index, ""); + } + + LexAction LexAction::Accept(std::string symbol_name) { + return LexAction(LexActionTypeAccept, -1, symbol_name); + } + + bool LexAction::operator==(const LexAction &other) const { + return + (type == other.type) && + (state_index == other.state_index) && + (symbol_name == other.symbol_name); + } + + std::ostream& operator<<(std::ostream &stream, const LexAction &action) { + switch (action.type) { + case LexActionTypeError: + return stream << string("#"); + case LexActionTypeAccept: + return stream << string("#"; + case LexActionTypeAdvance: + return stream << string("#"; + } + } + + // State + unordered_set LexState::expected_inputs() const { + unordered_set result; + for (auto pair : actions) + result.insert(pair.first); + return result; + } + + // Table + size_t LexTable::add_state() { + states.push_back(LexState()); + return states.size() - 1; + } + + void LexTable::add_action(size_t state_index, CharMatch match, LexAction action) { + states[state_index].actions[match].insert(action); + } + + void LexTable::add_default_action(size_t state_index, LexAction action) { + states[state_index].default_actions.insert(action); + } +} \ No newline at end of file diff --git a/src/compiler/lex_table.h b/src/compiler/lex_table.h new file mode 100644 index 00000000..2b3f052c --- /dev/null +++ b/src/compiler/lex_table.h @@ -0,0 +1,65 @@ +#ifndef __TreeSitter__lex_table__ +#define __TreeSitter__lex_table__ + +#include +#include +#include +#include +#include "char_match.h" + +namespace tree_sitter { + typedef enum { + LexActionTypeAccept, + LexActionTypeError, + LexActionTypeAdvance + } LexActionType; + + class LexAction { + LexAction(LexActionType type, size_t state_index, std::string symbol_name); + public: + static LexAction Accept(std::string symbol_name); + static LexAction Error(); + static LexAction Advance(size_t state_index); + bool operator==(const LexAction &action) const; + + LexActionType type; + std::string symbol_name; + size_t state_index; + }; + + std::ostream& operator<<(std::ostream &stream, const LexAction &item); +} + +namespace std { + template<> + struct hash { + size_t operator()(const tree_sitter::LexAction &action) const { + return ( + hash()(action.type) ^ + hash()(action.symbol_name) ^ + hash()(action.state_index)); + } + }; +} + +namespace tree_sitter { + class LexState { + public: + std::unordered_map> actions; + std::unordered_set default_actions; + std::unordered_set expected_inputs() const; + }; + + class LexTable { + public: + size_t add_state(); + void add_action(size_t state_index, CharMatch match, LexAction action); + void add_default_action(size_t state_index, LexAction action); + + static const std::string START; + static const std::string END_OF_INPUT; + std::vector states; + }; +} + +#endif diff --git a/src/compiler/lr/lex_table.cpp b/src/compiler/lr/lex_table.cpp deleted file mode 100644 index defd9ae0..00000000 --- a/src/compiler/lr/lex_table.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "lex_table.h" - -using std::string; -using std::to_string; -using std::unordered_map; -using std::unordered_set; -using std::vector; - -namespace tree_sitter { - namespace lr { - - // Action - LexAction::LexAction(LexActionType type, size_t state_index, std::string symbol_name) : - type(type), - state_index(state_index), - symbol_name(symbol_name) {} - - LexAction LexAction::Error() { - return LexAction(LexActionTypeError, -1, ""); - } - - LexAction LexAction::Advance(size_t state_index) { - return LexAction(LexActionTypeAdvance, state_index, ""); - } - - LexAction LexAction::Accept(std::string symbol_name) { - return LexAction(LexActionTypeAccept, -1, symbol_name); - } - - bool LexAction::operator==(const LexAction &other) const { - return - (type == other.type) && - (state_index == other.state_index) && - (symbol_name == other.symbol_name); - } - - std::ostream& operator<<(std::ostream &stream, const LexAction &action) { - switch (action.type) { - case LexActionTypeError: - return stream << string("#"); - case LexActionTypeAccept: - return stream << string("#"; - case LexActionTypeAdvance: - return stream << string("#"; - } - } - - // State - unordered_set LexState::expected_inputs() const { - unordered_set result; - for (auto pair : actions) - result.insert(pair.first); - return result; - } - - // Table - size_t LexTable::add_state() { - states.push_back(LexState()); - return states.size() - 1; - } - - void LexTable::add_action(size_t state_index, CharMatch match, LexAction action) { - states[state_index].actions[match].insert(action); - } - - void LexTable::add_default_action(size_t state_index, LexAction action) { - states[state_index].default_actions.insert(action); - } - } -} \ No newline at end of file diff --git a/src/compiler/lr/lex_table.h b/src/compiler/lr/lex_table.h deleted file mode 100644 index 9f3834cc..00000000 --- a/src/compiler/lr/lex_table.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef __TreeSitter__lex_table__ -#define __TreeSitter__lex_table__ - -#include -#include -#include -#include -#include "char_match.h" - -namespace tree_sitter { - namespace lr { - typedef enum { - LexActionTypeAccept, - LexActionTypeError, - LexActionTypeAdvance - } LexActionType; - - class LexAction { - LexAction(LexActionType type, size_t state_index, std::string symbol_name); - public: - static LexAction Accept(std::string symbol_name); - static LexAction Error(); - static LexAction Advance(size_t state_index); - bool operator==(const LexAction &action) const; - - LexActionType type; - std::string symbol_name; - size_t state_index; - }; - } -} - -namespace std { - template<> - struct hash { - size_t operator()(const tree_sitter::lr::LexAction &action) const { - return ( - hash()(action.type) ^ - hash()(action.symbol_name) ^ - hash()(action.state_index)); - } - }; -} - -namespace tree_sitter { - namespace lr { - std::ostream& operator<<(std::ostream &stream, const LexAction &item); - - class LexState { - public: - std::unordered_map> actions; - std::unordered_set default_actions; - std::unordered_set expected_inputs() const; - }; - - class LexTable { - public: - size_t add_state(); - void add_action(size_t state_index, CharMatch match, LexAction action); - void add_default_action(size_t state_index, LexAction action); - - static const std::string START; - static const std::string END_OF_INPUT; - std::vector states; - }; - } -} - -#endif diff --git a/src/compiler/lr/parse_table.cpp b/src/compiler/lr/parse_table.cpp deleted file mode 100644 index 0a539e86..00000000 --- a/src/compiler/lr/parse_table.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "parse_table.h" - -using std::string; -using std::ostream; -using std::to_string; -using std::unordered_set; - -namespace tree_sitter { - namespace lr { - // Action - ParseAction::ParseAction(ParseActionType type, size_t state_index, string symbol_name, size_t child_symbol_count) : - type(type), - state_index(state_index), - symbol_name(symbol_name), - child_symbol_count(child_symbol_count) {}; - - ParseAction ParseAction::Error() { - return ParseAction(ParseActionTypeError, -1, "", -1); - } - - ParseAction ParseAction::Accept() { - return ParseAction(ParseActionTypeAccept, -1, "", -1); - } - - ParseAction ParseAction::Shift(size_t state_index) { - return ParseAction(ParseActionTypeShift, state_index, "", -1); - } - - ParseAction ParseAction::Reduce(std::string symbol_name, size_t child_symbol_count) { - return ParseAction(ParseActionTypeReduce, -1, symbol_name, child_symbol_count); - } - - bool ParseAction::operator==(const ParseAction &other) const { - bool types_eq = type == other.type; - bool state_indices_eq = state_index == other.state_index; - bool child_symbol_counts_eq = child_symbol_count == other.child_symbol_count; - return types_eq && state_indices_eq && child_symbol_counts_eq; - } - - ostream& operator<<(ostream &stream, const ParseAction &action) { - switch (action.type) { - case ParseActionTypeError: - return stream << string("#"); - case ParseActionTypeAccept: - return stream << string("#"); - case ParseActionTypeShift: - return stream << (string("#"); - case ParseActionTypeReduce: - return stream << (string("#"); - } - } - - // State - ParseState::ParseState() : lex_state_index(-1) {} - - unordered_set ParseState::expected_inputs() const { - unordered_set result; - for (auto pair : actions) - result.insert(pair.first); - return result; - } - - // Table - size_t ParseTable::add_state() { - states.push_back(ParseState()); - return states.size() - 1; - } - - void ParseTable::add_action(size_t state_index, string sym_name, ParseAction action) { - states[state_index].actions[sym_name].insert(action); - } - - void ParseTable::add_default_action(size_t state_index, ParseAction action) { - states[state_index].default_actions.insert(action); - } - - const string ParseTable::START = "__START__"; - const string ParseTable::END_OF_INPUT = "__END__"; - } -} diff --git a/src/compiler/lr/parse_table.h b/src/compiler/lr/parse_table.h deleted file mode 100644 index bb63c679..00000000 --- a/src/compiler/lr/parse_table.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef __TreeSitter__parse_table__ -#define __TreeSitter__parse_table__ - -#include -#include -#include -#include "rule.h" - -namespace tree_sitter { - namespace lr { - typedef enum { - ParseActionTypeAccept, - ParseActionTypeError, - ParseActionTypeShift, - ParseActionTypeReduce, - } ParseActionType; - - class ParseAction { - ParseAction(ParseActionType type, size_t state_index, std::string symbol_name, size_t child_symbol_count); - public: - static ParseAction Accept(); - static ParseAction Error(); - static ParseAction Shift(size_t state_index); - static ParseAction Reduce(std::string symbol_name, size_t child_symbol_count); - bool operator==(const ParseAction &action) const; - - ParseActionType type; - size_t child_symbol_count; - std::string symbol_name; - size_t state_index; - }; - } -} - -namespace std { - template<> - struct hash { - size_t operator()(const tree_sitter::lr::ParseAction &action) const { - return ( - hash()(action.type) ^ - hash()(action.symbol_name) ^ - hash()(action.state_index) ^ - hash()(action.child_symbol_count)); - } - }; -} - -namespace tree_sitter { - namespace lr { - std::ostream& operator<<(std::ostream &stream, const ParseAction &item); - - class ParseState { - public: - ParseState(); - std::unordered_map> actions; - std::unordered_set default_actions; - std::unordered_set expected_inputs() const; - size_t lex_state_index; - }; - - class ParseTable { - public: - size_t add_state(); - void add_action(size_t state_index, std::string symbol_name, ParseAction action); - void add_default_action(size_t state_index, ParseAction action); - - static const std::string START; - static const std::string END_OF_INPUT; - std::vector states; - }; - } -} - -#endif diff --git a/src/compiler/parse_table.cpp b/src/compiler/parse_table.cpp new file mode 100644 index 00000000..a36b830f --- /dev/null +++ b/src/compiler/parse_table.cpp @@ -0,0 +1,78 @@ +#include "parse_table.h" + +using std::string; +using std::ostream; +using std::to_string; +using std::unordered_set; + +namespace tree_sitter { + // Action + ParseAction::ParseAction(ParseActionType type, size_t state_index, string symbol_name, size_t child_symbol_count) : + type(type), + state_index(state_index), + symbol_name(symbol_name), + child_symbol_count(child_symbol_count) {}; + + ParseAction ParseAction::Error() { + return ParseAction(ParseActionTypeError, -1, "", -1); + } + + ParseAction ParseAction::Accept() { + return ParseAction(ParseActionTypeAccept, -1, "", -1); + } + + ParseAction ParseAction::Shift(size_t state_index) { + return ParseAction(ParseActionTypeShift, state_index, "", -1); + } + + ParseAction ParseAction::Reduce(std::string symbol_name, size_t child_symbol_count) { + return ParseAction(ParseActionTypeReduce, -1, symbol_name, child_symbol_count); + } + + bool ParseAction::operator==(const ParseAction &other) const { + bool types_eq = type == other.type; + bool state_indices_eq = state_index == other.state_index; + bool child_symbol_counts_eq = child_symbol_count == other.child_symbol_count; + return types_eq && state_indices_eq && child_symbol_counts_eq; + } + + ostream& operator<<(ostream &stream, const ParseAction &action) { + switch (action.type) { + case ParseActionTypeError: + return stream << string("#"); + case ParseActionTypeAccept: + return stream << string("#"); + case ParseActionTypeShift: + return stream << (string("#"); + case ParseActionTypeReduce: + return stream << (string("#"); + } + } + + // State + ParseState::ParseState() : lex_state_index(-1) {} + + unordered_set ParseState::expected_inputs() const { + unordered_set result; + for (auto pair : actions) + result.insert(pair.first); + return result; + } + + // Table + size_t ParseTable::add_state() { + states.push_back(ParseState()); + return states.size() - 1; + } + + void ParseTable::add_action(size_t state_index, string sym_name, ParseAction action) { + states[state_index].actions[sym_name].insert(action); + } + + void ParseTable::add_default_action(size_t state_index, ParseAction action) { + states[state_index].default_actions.insert(action); + } + + const string ParseTable::START = "__START__"; + const string ParseTable::END_OF_INPUT = "__END__"; +} diff --git a/src/compiler/parse_table.h b/src/compiler/parse_table.h new file mode 100644 index 00000000..eebc83c4 --- /dev/null +++ b/src/compiler/parse_table.h @@ -0,0 +1,70 @@ +#ifndef __TreeSitter__parse_table__ +#define __TreeSitter__parse_table__ + +#include +#include +#include +#include "rule.h" + +namespace tree_sitter { + typedef enum { + ParseActionTypeAccept, + ParseActionTypeError, + ParseActionTypeShift, + ParseActionTypeReduce, + } ParseActionType; + + class ParseAction { + ParseAction(ParseActionType type, size_t state_index, std::string symbol_name, size_t child_symbol_count); + public: + static ParseAction Accept(); + static ParseAction Error(); + static ParseAction Shift(size_t state_index); + static ParseAction Reduce(std::string symbol_name, size_t child_symbol_count); + bool operator==(const ParseAction &action) const; + + ParseActionType type; + size_t child_symbol_count; + std::string symbol_name; + size_t state_index; + }; + + std::ostream& operator<<(std::ostream &stream, const ParseAction &item); +} + +namespace std { + template<> + struct hash { + size_t operator()(const tree_sitter::ParseAction &action) const { + return ( + hash()(action.type) ^ + hash()(action.symbol_name) ^ + hash()(action.state_index) ^ + hash()(action.child_symbol_count)); + } + }; +} + +namespace tree_sitter { + class ParseState { + public: + ParseState(); + std::unordered_map> actions; + std::unordered_set default_actions; + std::unordered_set expected_inputs() const; + size_t lex_state_index; + }; + + class ParseTable { + public: + size_t add_state(); + void add_action(size_t state_index, std::string symbol_name, ParseAction action); + void add_default_action(size_t state_index, ParseAction action); + + static const std::string START; + static const std::string END_OF_INPUT; + std::vector states; + }; +} + +#endif diff --git a/src/compiler/prepare_grammar/extract_tokens.cpp b/src/compiler/prepare_grammar/extract_tokens.cpp new file mode 100644 index 00000000..47378388 --- /dev/null +++ b/src/compiler/prepare_grammar/extract_tokens.cpp @@ -0,0 +1,80 @@ +#include "extract_tokens.h" +#include "search_for_symbols.h" +#include + +using std::pair; +using std::string; +using std::to_string; +using std::unordered_map; + +namespace tree_sitter { + namespace prepare_grammar { + class TokenExtractor : rules::Visitor { + public: + rules::rule_ptr value; + size_t anonymous_token_count = 0; + unordered_map tokens; + + rules::rule_ptr initial_apply(string name, const rules::rule_ptr rule) { + auto result = apply(rule); + auto symbol = std::dynamic_pointer_cast(result); + if (symbol && *symbol != *rule) { + tokens.insert({ name, tokens[symbol->name] }); + tokens.erase(symbol->name); + anonymous_token_count--; + return rules::rule_ptr(); + } else { + return result; + } + } + + rules::rule_ptr apply(const rules::rule_ptr rule) { + if (search_for_symbols(rule)) { + rule->accept(*this); + return value; + } else { + string token_name = add_token(rule); + return rules::sym(token_name); + } + } + + string add_token(const rules::rule_ptr &rule) { + for (auto pair : tokens) + if (*pair.second == *rule) + return pair.first; + string name = to_string(++anonymous_token_count); + tokens.insert({ name, rule }); + return name; + } + + void default_visit(const rules::Rule *rule) { + value = rule->copy(); + } + + void visit(const rules::Choice *choice) { + value = rules::choice({ apply(choice->left), apply(choice->right) }); + } + + void visit(const rules::Seq *seq) { + value = rules::seq({ apply(seq->left), apply(seq->right) }); + } + }; + + pair extract_tokens(const Grammar &input_grammar) { + TokenExtractor extractor; + unordered_map rules; + + for (auto pair : input_grammar.rules) { + string name = pair.first; + auto new_rule = extractor.initial_apply(name, pair.second); + if (new_rule.get()) + rules.insert({ name, new_rule }); + } + + return { + Grammar(input_grammar.start_rule_name, rules), + Grammar("", extractor.tokens) + }; + } + } +} diff --git a/src/compiler/grammar/extract_tokens.h b/src/compiler/prepare_grammar/extract_tokens.h similarity index 56% rename from src/compiler/grammar/extract_tokens.h rename to src/compiler/prepare_grammar/extract_tokens.h index 09139036..63dd21f7 100644 --- a/src/compiler/grammar/extract_tokens.h +++ b/src/compiler/prepare_grammar/extract_tokens.h @@ -4,7 +4,9 @@ #include "grammar.h" namespace tree_sitter { - std::pair extract_tokens(const Grammar &); + namespace prepare_grammar { + std::pair extract_tokens(const Grammar &); + } } #endif diff --git a/src/compiler/prepare_grammar/perform.cpp b/src/compiler/prepare_grammar/perform.cpp new file mode 100644 index 00000000..6bfd4bc5 --- /dev/null +++ b/src/compiler/prepare_grammar/perform.cpp @@ -0,0 +1,12 @@ +#include "./perform.h" +#include "extract_tokens.h" + +using std::pair; + +namespace tree_sitter { + namespace prepare_grammar { + pair perform(const Grammar &input_grammar) { + return prepare_grammar::extract_tokens(input_grammar); + } + } +} diff --git a/src/compiler/grammar/prepare_grammar.h b/src/compiler/prepare_grammar/perform.h similarity index 58% rename from src/compiler/grammar/prepare_grammar.h rename to src/compiler/prepare_grammar/perform.h index 5e3fc348..c46c7d42 100644 --- a/src/compiler/grammar/prepare_grammar.h +++ b/src/compiler/prepare_grammar/perform.h @@ -4,7 +4,9 @@ #include "grammar.h" namespace tree_sitter { - std::pair prepare_grammar(const Grammar &); + namespace prepare_grammar { + std::pair perform(const Grammar &); + } } #endif diff --git a/src/compiler/prepare_grammar/search_for_symbols.cpp b/src/compiler/prepare_grammar/search_for_symbols.cpp new file mode 100644 index 00000000..d73b9d10 --- /dev/null +++ b/src/compiler/prepare_grammar/search_for_symbols.cpp @@ -0,0 +1,35 @@ +#include "search_for_symbols.h" + +namespace tree_sitter { + namespace prepare_grammar { + class SymbolSearcher : rules::Visitor { + public: + bool value; + + bool apply(const rules::rule_ptr rule) { + rule->accept(*this); + return value; + } + + void default_visit(const rules::Rule *rule) { + value = false; + } + + void visit(const rules::Symbol *symbol) { + value = true; + } + + void visit(const rules::Choice *choice) { + value = apply(choice->left) || apply(choice->right); + } + + void visit(const rules::Seq *seq) { + value = apply(seq->left) || apply(seq->right); + } + }; + + bool search_for_symbols(const rules::rule_ptr &rule) { + return SymbolSearcher().apply(rule); + } + } +} \ No newline at end of file diff --git a/src/compiler/grammar/search_for_symbols.h b/src/compiler/prepare_grammar/search_for_symbols.h similarity index 59% rename from src/compiler/grammar/search_for_symbols.h rename to src/compiler/prepare_grammar/search_for_symbols.h index d6adaf1e..7d532e17 100644 --- a/src/compiler/grammar/search_for_symbols.h +++ b/src/compiler/prepare_grammar/search_for_symbols.h @@ -4,7 +4,9 @@ #include "rules.h" namespace tree_sitter { - bool search_for_symbols(const rules::rule_ptr &); + namespace prepare_grammar { + bool search_for_symbols(const rules::rule_ptr &); + } } #endif diff --git a/src/compiler/rules/blank.cpp b/src/compiler/rules/blank.cpp index cc72963c..0d07858a 100644 --- a/src/compiler/rules/blank.cpp +++ b/src/compiler/rules/blank.cpp @@ -1,5 +1,4 @@ #include "rules.h" -#include "transition_map.h" namespace tree_sitter { namespace rules { diff --git a/src/compiler/rules/character.cpp b/src/compiler/rules/character.cpp index 545e76f8..f9435ea0 100644 --- a/src/compiler/rules/character.cpp +++ b/src/compiler/rules/character.cpp @@ -1,5 +1,4 @@ #include "rules.h" -#include "transition_map.h" using std::string; using std::hash; diff --git a/src/compiler/rules/choice.cpp b/src/compiler/rules/choice.cpp index 16ed90ea..8638c085 100644 --- a/src/compiler/rules/choice.cpp +++ b/src/compiler/rules/choice.cpp @@ -1,5 +1,4 @@ #include "rules.h" -#include "transition_map.h" using std::string; diff --git a/src/compiler/rules/pattern.cpp b/src/compiler/rules/pattern.cpp index 3ae02a42..e1efa287 100644 --- a/src/compiler/rules/pattern.cpp +++ b/src/compiler/rules/pattern.cpp @@ -1,5 +1,4 @@ #include "rules.h" -#include "transition_map.h" using std::string; using std::hash; diff --git a/src/compiler/rules/repeat.cpp b/src/compiler/rules/repeat.cpp index a8fb37f3..c686cd84 100644 --- a/src/compiler/rules/repeat.cpp +++ b/src/compiler/rules/repeat.cpp @@ -1,5 +1,4 @@ #include "rules.h" -#include "transition_map.h" using std::string; diff --git a/src/compiler/rules/seq.cpp b/src/compiler/rules/seq.cpp index d8b20fa3..5f771f35 100644 --- a/src/compiler/rules/seq.cpp +++ b/src/compiler/rules/seq.cpp @@ -1,5 +1,4 @@ #include "rules.h" -#include "transition_map.h" using std::string; diff --git a/src/compiler/rules/string.cpp b/src/compiler/rules/string.cpp index b29f466d..b558696f 100644 --- a/src/compiler/rules/string.cpp +++ b/src/compiler/rules/string.cpp @@ -1,5 +1,4 @@ #include "rules.h" -#include "transition_map.h" using std::string; using std::hash; diff --git a/src/compiler/rules/symbol.cpp b/src/compiler/rules/symbol.cpp index 25d505e0..2bc7e837 100644 --- a/src/compiler/rules/symbol.cpp +++ b/src/compiler/rules/symbol.cpp @@ -1,5 +1,4 @@ #include "rules.h" -#include "transition_map.h" using std::string; using std::hash; diff --git a/tree_sitter.xcodeproj/project.pbxproj b/tree_sitter.xcodeproj/project.pbxproj index 42c779f2..24e1d043 100644 --- a/tree_sitter.xcodeproj/project.pbxproj +++ b/tree_sitter.xcodeproj/project.pbxproj @@ -13,55 +13,56 @@ 12130611182C3A1100FCF928 /* blank.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1213060F182C3A1100FCF928 /* blank.cpp */; }; 12130614182C3A1700FCF928 /* seq.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130612182C3A1700FCF928 /* seq.cpp */; }; 12130617182C3D2900FCF928 /* string.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130615182C3D2900FCF928 /* string.cpp */; }; - 1213061B182C84DF00FCF928 /* item.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130619182C84DF00FCF928 /* item.cpp */; }; - 12130622182C85D300FCF928 /* item_set.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130620182C85D300FCF928 /* item_set.cpp */; }; 1214930E181E200B008E9BDA /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 121492E9181E200B008E9BDA /* main.cpp */; }; 1225CC6418765693000D4723 /* prepare_grammar_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1225CC6318765693000D4723 /* prepare_grammar_spec.cpp */; }; - 1225CC6718765737000D4723 /* prepare_grammar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1225CC6518765737000D4723 /* prepare_grammar.cpp */; }; - 1225CC6A187661C7000D4723 /* extract_tokens.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1225CC68187661C7000D4723 /* extract_tokens.cpp */; }; - 1225CC6D18766969000D4723 /* search_for_symbols.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1225CC6B18766969000D4723 /* search_for_symbols.cpp */; }; 1251209B1830145300C9B56A /* rule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1251209A1830145300C9B56A /* rule.cpp */; }; - 125120A018307DEC00C9B56A /* parse_table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1251209E18307DEC00C9B56A /* parse_table.cpp */; }; 125120A4183083BD00C9B56A /* arithmetic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 125120A3183083BD00C9B56A /* arithmetic.cpp */; }; - 129D242C183EB1EB00FE9F71 /* table_builder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 129D242A183EB1EB00FE9F71 /* table_builder.cpp */; }; 12D136A4183678A2005F3369 /* repeat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12D136A2183678A2005F3369 /* repeat.cpp */; }; - 12ED72A7186FC8220089229B /* transitions_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12ED72A6186FC8220089229B /* transitions_spec.cpp */; }; 12EDCF8A187B498C005A7A07 /* tree_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCF89187B498C005A7A07 /* tree_spec.cpp */; }; 12EDCF8D187C6282005A7A07 /* document.c in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCF8C187C6282005A7A07 /* document.c */; }; + 12EDCF981881FCD5005A7A07 /* extract_tokens.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCF8F1881FCCA005A7A07 /* extract_tokens.cpp */; }; + 12EDCF991881FCD9005A7A07 /* perform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCF911881FCCA005A7A07 /* perform.cpp */; }; + 12EDCF9A1881FCD9005A7A07 /* search_for_symbols.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCF931881FCCA005A7A07 /* search_for_symbols.cpp */; }; + 12EDCF9F18820116005A7A07 /* parse_table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCF9D18820116005A7A07 /* parse_table.cpp */; }; + 12EDCFA818820137005A7A07 /* item_set.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCFA018820137005A7A07 /* item_set.cpp */; }; + 12EDCFA918820137005A7A07 /* item.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCFA218820137005A7A07 /* item.cpp */; }; + 12EDCFAA18820137005A7A07 /* perform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCFA418820137005A7A07 /* perform.cpp */; }; + 12EDCFAB18820137005A7A07 /* rule_transitions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCFA618820137005A7A07 /* rule_transitions.cpp */; }; + 12EDCFAF18820387005A7A07 /* parse_table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCF9D18820116005A7A07 /* parse_table.cpp */; }; + 12EDCFB018820392005A7A07 /* item.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCFA218820137005A7A07 /* item.cpp */; }; + 12EDCFB118820395005A7A07 /* item_set.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCFA018820137005A7A07 /* item_set.cpp */; }; + 12EDCFB21882039A005A7A07 /* perform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCFA418820137005A7A07 /* perform.cpp */; }; + 12EDCFB31882039A005A7A07 /* rule_transitions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCFA618820137005A7A07 /* rule_transitions.cpp */; }; + 12EDCFB418820519005A7A07 /* compile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCFAC18820181005A7A07 /* compile.cpp */; }; + 12EDCFBB188205BF005A7A07 /* item_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCFB5188205BA005A7A07 /* item_spec.cpp */; }; + 12EDCFBC188205BF005A7A07 /* rule_transitions_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCFB6188205BA005A7A07 /* rule_transitions_spec.cpp */; }; + 12EDCFBD188205BF005A7A07 /* perform_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12EDCFB7188205BA005A7A07 /* perform_spec.cpp */; }; 12F9A64E182DD5FD00FAF50C /* spec_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12F9A64C182DD5FD00FAF50C /* spec_helper.cpp */; }; 12F9A651182DD6BC00FAF50C /* grammar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12F9A64F182DD6BC00FAF50C /* grammar.cpp */; }; 12FD4061185E68470041A84E /* c_code.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD405F185E68470041A84E /* c_code.cpp */; }; - 12FD4064185E75290041A84E /* generate_parsers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD4063185E75290041A84E /* generate_parsers.cpp */; }; + 12FD4064185E75290041A84E /* compile_fixtures.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD4063185E75290041A84E /* compile_fixtures.cpp */; }; 12FD40B3185EEB5E0041A84E /* seq.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130612182C3A1700FCF928 /* seq.cpp */; }; - 12FD40B4185EEB5E0041A84E /* table_builder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 129D242A183EB1EB00FE9F71 /* table_builder.cpp */; }; 12FD40B6185EEB5E0041A84E /* arithmetic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 125120A3183083BD00C9B56A /* arithmetic.cpp */; }; - 12FD40B8185EEB5E0041A84E /* item.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130619182C84DF00FCF928 /* item.cpp */; }; 12FD40B9185EEB5E0041A84E /* string.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130615182C3D2900FCF928 /* string.cpp */; }; 12FD40BB185EEB5E0041A84E /* blank.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1213060F182C3A1100FCF928 /* blank.cpp */; }; 12FD40BD185EEB5E0041A84E /* choice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1213060C182C398300FCF928 /* choice.cpp */; }; 12FD40BF185EEB5E0041A84E /* c_code.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD405F185E68470041A84E /* c_code.cpp */; }; - 12FD40C0185EEB5E0041A84E /* parse_table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1251209E18307DEC00C9B56A /* parse_table.cpp */; }; 12FD40C2185EEB5E0041A84E /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 121492E9181E200B008E9BDA /* main.cpp */; }; 12FD40C3185EEB5E0041A84E /* grammar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12F9A64F182DD6BC00FAF50C /* grammar.cpp */; }; 12FD40C6185EEB5E0041A84E /* repeat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12D136A2183678A2005F3369 /* repeat.cpp */; }; - 12FD40C7185EEB5E0041A84E /* item_set.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130620182C85D300FCF928 /* item_set.cpp */; }; 12FD40C8185EEB5E0041A84E /* character.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130603182C348F00FCF928 /* character.cpp */; }; 12FD40C9185EEB5E0041A84E /* symbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130609182C389100FCF928 /* symbol.cpp */; }; 12FD40CA185EEB5E0041A84E /* rule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1251209A1830145300C9B56A /* rule.cpp */; }; 12FD40CB185EEB5E0041A84E /* pattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27A340F3EEB184C040521323 /* pattern.cpp */; }; 12FD40D2185EEB970041A84E /* arithmetic.c in Sources */ = {isa = PBXBuildFile; fileRef = 12FD4065185E7C2F0041A84E /* arithmetic.c */; }; - 12FD40D6185FEEDB0041A84E /* table_builder_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12512092182F307C00C9B56A /* table_builder_spec.cpp */; }; - 12FD40D7185FEEDB0041A84E /* item_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12D1369C18328C5A005F3369 /* item_spec.cpp */; }; 12FD40D8185FEEDF0041A84E /* rules_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 121492EA181E200B008E9BDA /* rules_spec.cpp */; }; 12FD40D9185FEEDF0041A84E /* pattern_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12D136A0183570F5005F3369 /* pattern_spec.cpp */; }; 12FD40DB185FEF0D0041A84E /* arithmetic_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40DA185FEF0D0041A84E /* arithmetic_spec.cpp */; }; 12FD40DD185FF12C0041A84E /* parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40DC185FF12C0041A84E /* parser.cpp */; }; 12FD40DF1860064C0041A84E /* tree.c in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40DE1860064C0041A84E /* tree.c */; }; - 12FD40E2186245FE0041A84E /* transitions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40E0186245FE0041A84E /* transitions.cpp */; }; 12FD40E718639B910041A84E /* visitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40E618639B910041A84E /* visitor.cpp */; }; 12FD40E918641FB70041A84E /* rules.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40E818641FB70041A84E /* rules.cpp */; }; 12FD40EE186641430041A84E /* rules.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40E818641FB70041A84E /* rules.cpp */; }; - 12FD40EF186641510041A84E /* transitions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40E0186245FE0041A84E /* transitions.cpp */; }; 12FD40F01866415D0041A84E /* visitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40E618639B910041A84E /* visitor.cpp */; }; 12FD40F3186641C00041A84E /* char_match.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40F1186641C00041A84E /* char_match.cpp */; }; 12FD40F4186641C00041A84E /* char_match.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40F1186641C00041A84E /* char_match.cpp */; }; @@ -105,63 +106,65 @@ 12130613182C3A1700FCF928 /* seq.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = seq.h; sourceTree = ""; }; 12130615182C3D2900FCF928 /* string.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = string.cpp; sourceTree = ""; }; 12130616182C3D2900FCF928 /* string.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = string.h; sourceTree = ""; }; - 12130619182C84DF00FCF928 /* item.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = item.cpp; sourceTree = ""; }; - 1213061A182C84DF00FCF928 /* item.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = item.h; sourceTree = ""; }; - 12130620182C85D300FCF928 /* item_set.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = item_set.cpp; sourceTree = ""; }; - 12130621182C85D300FCF928 /* item_set.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = item_set.h; sourceTree = ""; }; 121492E9181E200B008E9BDA /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = spec/main.cpp; sourceTree = SOURCE_ROOT; }; 121492EA181E200B008E9BDA /* rules_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rules_spec.cpp; path = spec/compiler/rules/rules_spec.cpp; sourceTree = SOURCE_ROOT; }; 121D8B3018795CC0003CF44B /* parser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = parser.h; sourceTree = ""; }; - 1225CC6318765693000D4723 /* prepare_grammar_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = prepare_grammar_spec.cpp; sourceTree = ""; }; - 1225CC6518765737000D4723 /* prepare_grammar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = prepare_grammar.cpp; sourceTree = ""; }; - 1225CC6618765737000D4723 /* prepare_grammar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = prepare_grammar.h; sourceTree = ""; }; - 1225CC68187661C7000D4723 /* extract_tokens.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = extract_tokens.cpp; sourceTree = ""; }; - 1225CC69187661C7000D4723 /* extract_tokens.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = extract_tokens.h; sourceTree = ""; }; - 1225CC6B18766969000D4723 /* search_for_symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = search_for_symbols.cpp; sourceTree = ""; }; - 1225CC6C18766969000D4723 /* search_for_symbols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = search_for_symbols.h; sourceTree = ""; }; - 12512092182F307C00C9B56A /* table_builder_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = table_builder_spec.cpp; path = spec/compiler/lr/table_builder_spec.cpp; sourceTree = SOURCE_ROOT; }; + 1225CC6318765693000D4723 /* prepare_grammar_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = prepare_grammar_spec.cpp; path = compiler/prepare_grammar_spec.cpp; sourceTree = ""; }; 1251209A1830145300C9B56A /* rule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rule.cpp; sourceTree = ""; }; - 1251209E18307DEC00C9B56A /* parse_table.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parse_table.cpp; sourceTree = ""; }; - 1251209F18307DEC00C9B56A /* parse_table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parse_table.h; sourceTree = ""; }; 125120A218307FFD00C9B56A /* arithmetic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = arithmetic.h; path = spec/fixtures/grammars/arithmetic.h; sourceTree = SOURCE_ROOT; }; 125120A3183083BD00C9B56A /* arithmetic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = arithmetic.cpp; path = spec/fixtures/grammars/arithmetic.cpp; sourceTree = SOURCE_ROOT; }; - 129D242A183EB1EB00FE9F71 /* table_builder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = table_builder.cpp; sourceTree = ""; }; - 129D242B183EB1EB00FE9F71 /* table_builder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = table_builder.h; sourceTree = ""; }; - 12C344421822F27700B07BE3 /* transition_map.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = transition_map.h; sourceTree = ""; }; - 12D1369C18328C5A005F3369 /* item_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = item_spec.cpp; path = spec/compiler/lr/item_spec.cpp; sourceTree = SOURCE_ROOT; }; + 12C344421822F27700B07BE3 /* transition_map.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = transition_map.h; path = ../build_tables/transition_map.h; sourceTree = ""; }; 12D1369E18342088005F3369 /* todo.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = todo.md; sourceTree = ""; }; 12D136A0183570F5005F3369 /* pattern_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pattern_spec.cpp; path = spec/compiler/rules/pattern_spec.cpp; sourceTree = SOURCE_ROOT; }; 12D136A2183678A2005F3369 /* repeat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = repeat.cpp; sourceTree = ""; }; 12D136A3183678A2005F3369 /* repeat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = repeat.h; sourceTree = ""; }; 12E71794181D02A80051A649 /* compiler_specs */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = compiler_specs; sourceTree = BUILT_PRODUCTS_DIR; }; 12E71852181D081C0051A649 /* rules.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = rules.h; path = src/compiler/rules/rules.h; sourceTree = SOURCE_ROOT; }; - 12ED72A6186FC8220089229B /* transitions_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = transitions_spec.cpp; path = spec/compiler/lr/transitions_spec.cpp; sourceTree = SOURCE_ROOT; }; 12EDCF89187B498C005A7A07 /* tree_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tree_spec.cpp; sourceTree = ""; }; 12EDCF8B187C6251005A7A07 /* document.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = document.h; sourceTree = ""; }; 12EDCF8C187C6282005A7A07 /* document.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = document.c; sourceTree = ""; }; 12EDCF8E187DB33E005A7A07 /* parse_config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = parse_config.h; sourceTree = ""; }; + 12EDCF8F1881FCCA005A7A07 /* extract_tokens.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = extract_tokens.cpp; path = src/compiler/prepare_grammar/extract_tokens.cpp; sourceTree = SOURCE_ROOT; }; + 12EDCF901881FCCA005A7A07 /* extract_tokens.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = extract_tokens.h; path = src/compiler/prepare_grammar/extract_tokens.h; sourceTree = SOURCE_ROOT; }; + 12EDCF911881FCCA005A7A07 /* perform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = perform.cpp; path = src/compiler/prepare_grammar/perform.cpp; sourceTree = SOURCE_ROOT; }; + 12EDCF921881FCCA005A7A07 /* perform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = perform.h; path = src/compiler/prepare_grammar/perform.h; sourceTree = SOURCE_ROOT; }; + 12EDCF931881FCCA005A7A07 /* search_for_symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = search_for_symbols.cpp; path = src/compiler/prepare_grammar/search_for_symbols.cpp; sourceTree = SOURCE_ROOT; }; + 12EDCF941881FCCA005A7A07 /* search_for_symbols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = search_for_symbols.h; path = src/compiler/prepare_grammar/search_for_symbols.h; sourceTree = SOURCE_ROOT; }; + 12EDCF9C18820116005A7A07 /* lex_table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lex_table.h; sourceTree = ""; }; + 12EDCF9D18820116005A7A07 /* parse_table.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parse_table.cpp; sourceTree = ""; }; + 12EDCF9E18820116005A7A07 /* parse_table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parse_table.h; sourceTree = ""; }; + 12EDCFA018820137005A7A07 /* item_set.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = item_set.cpp; path = src/compiler/build_tables/item_set.cpp; sourceTree = SOURCE_ROOT; }; + 12EDCFA118820137005A7A07 /* item_set.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = item_set.h; path = src/compiler/build_tables/item_set.h; sourceTree = SOURCE_ROOT; }; + 12EDCFA218820137005A7A07 /* item.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = item.cpp; path = src/compiler/build_tables/item.cpp; sourceTree = SOURCE_ROOT; }; + 12EDCFA318820137005A7A07 /* item.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = item.h; path = src/compiler/build_tables/item.h; sourceTree = SOURCE_ROOT; }; + 12EDCFA418820137005A7A07 /* perform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = perform.cpp; path = src/compiler/build_tables/perform.cpp; sourceTree = SOURCE_ROOT; }; + 12EDCFA518820137005A7A07 /* perform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = perform.h; path = src/compiler/build_tables/perform.h; sourceTree = SOURCE_ROOT; }; + 12EDCFA618820137005A7A07 /* rule_transitions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rule_transitions.cpp; path = src/compiler/build_tables/rule_transitions.cpp; sourceTree = SOURCE_ROOT; }; + 12EDCFA718820137005A7A07 /* rule_transitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = rule_transitions.h; path = src/compiler/build_tables/rule_transitions.h; sourceTree = SOURCE_ROOT; }; + 12EDCFAC18820181005A7A07 /* compile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = compile.cpp; sourceTree = ""; }; + 12EDCFAD18820181005A7A07 /* compile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = compile.h; sourceTree = ""; }; + 12EDCFB5188205BA005A7A07 /* item_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = item_spec.cpp; sourceTree = ""; }; + 12EDCFB6188205BA005A7A07 /* rule_transitions_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rule_transitions_spec.cpp; sourceTree = ""; }; + 12EDCFB7188205BA005A7A07 /* perform_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = perform_spec.cpp; sourceTree = ""; }; 12F9A64C182DD5FD00FAF50C /* spec_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = spec_helper.cpp; path = spec/compiler/spec_helper.cpp; sourceTree = SOURCE_ROOT; }; 12F9A64D182DD5FD00FAF50C /* spec_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = spec_helper.h; path = spec/compiler/spec_helper.h; sourceTree = SOURCE_ROOT; }; - 12F9A64F182DD6BC00FAF50C /* grammar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = grammar.cpp; path = src/compiler/grammar/grammar.cpp; sourceTree = SOURCE_ROOT; }; - 12F9A650182DD6BC00FAF50C /* grammar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = grammar.h; path = src/compiler/grammar/grammar.h; sourceTree = SOURCE_ROOT; }; - 12FD405F185E68470041A84E /* c_code.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = c_code.cpp; path = src/compiler/code_gen/c_code.cpp; sourceTree = SOURCE_ROOT; }; - 12FD4060185E68470041A84E /* c_code.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = c_code.h; path = src/compiler/code_gen/c_code.h; sourceTree = SOURCE_ROOT; }; - 12FD4063185E75290041A84E /* generate_parsers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = generate_parsers.cpp; path = spec/compiler/generate_parsers.cpp; sourceTree = SOURCE_ROOT; }; + 12F9A64F182DD6BC00FAF50C /* grammar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = grammar.cpp; path = src/compiler/grammar.cpp; sourceTree = SOURCE_ROOT; }; + 12F9A650182DD6BC00FAF50C /* grammar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = grammar.h; path = src/compiler/grammar.h; sourceTree = SOURCE_ROOT; }; + 12FD405F185E68470041A84E /* c_code.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = c_code.cpp; path = src/compiler/generate_code/c_code.cpp; sourceTree = SOURCE_ROOT; }; + 12FD4060185E68470041A84E /* c_code.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = c_code.h; path = src/compiler/generate_code/c_code.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 12FD4063185E75290041A84E /* compile_fixtures.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = compile_fixtures.cpp; path = spec/compiler/compile_fixtures.cpp; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 12FD4065185E7C2F0041A84E /* arithmetic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = arithmetic.c; path = spec/fixtures/parsers/arithmetic.c; sourceTree = SOURCE_ROOT; }; 12FD40D1185EEB5E0041A84E /* runtime_specs */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = runtime_specs; sourceTree = BUILT_PRODUCTS_DIR; }; 12FD40D4185FED9A0041A84E /* tree.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tree.h; sourceTree = ""; }; 12FD40DA185FEF0D0041A84E /* arithmetic_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = arithmetic_spec.cpp; sourceTree = ""; }; 12FD40DC185FF12C0041A84E /* parser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parser.cpp; sourceTree = ""; }; 12FD40DE1860064C0041A84E /* tree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tree.c; sourceTree = ""; }; - 12FD40E0186245FE0041A84E /* transitions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = transitions.cpp; sourceTree = ""; }; - 12FD40E1186245FE0041A84E /* transitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = transitions.h; sourceTree = ""; }; 12FD40E41862B3530041A84E /* visitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = visitor.h; sourceTree = ""; }; 12FD40E618639B910041A84E /* visitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = visitor.cpp; sourceTree = ""; }; 12FD40E818641FB70041A84E /* rules.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rules.cpp; sourceTree = ""; }; 12FD40F1186641C00041A84E /* char_match.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = char_match.cpp; sourceTree = ""; }; 12FD40F2186641C00041A84E /* char_match.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = char_match.h; sourceTree = ""; }; 12FD40F5186A16020041A84E /* lex_table.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lex_table.cpp; sourceTree = ""; }; - 12FD40F6186A16020041A84E /* lex_table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lex_table.h; sourceTree = ""; }; 27A340F3EEB184C040521323 /* pattern.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pattern.cpp; sourceTree = ""; }; 27A3438C4FA59A3882E8493B /* pattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pattern.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -213,43 +216,32 @@ path = rules; sourceTree = ""; }; - 12130618182C84B700FCF928 /* lr */ = { + 12130618182C84B700FCF928 /* build_tables */ = { isa = PBXGroup; children = ( - 12FD40E0186245FE0041A84E /* transitions.cpp */, - 12FD40E1186245FE0041A84E /* transitions.h */, - 12130619182C84DF00FCF928 /* item.cpp */, - 1213061A182C84DF00FCF928 /* item.h */, - 12130620182C85D300FCF928 /* item_set.cpp */, - 12130621182C85D300FCF928 /* item_set.h */, - 12FD40F5186A16020041A84E /* lex_table.cpp */, - 12FD40F6186A16020041A84E /* lex_table.h */, - 1251209E18307DEC00C9B56A /* parse_table.cpp */, - 1251209F18307DEC00C9B56A /* parse_table.h */, - 129D242A183EB1EB00FE9F71 /* table_builder.cpp */, - 129D242B183EB1EB00FE9F71 /* table_builder.h */, + 12C344421822F27700B07BE3 /* transition_map.h */, + 12EDCFA018820137005A7A07 /* item_set.cpp */, + 12EDCFA118820137005A7A07 /* item_set.h */, + 12EDCFA218820137005A7A07 /* item.cpp */, + 12EDCFA318820137005A7A07 /* item.h */, + 12EDCFA418820137005A7A07 /* perform.cpp */, + 12EDCFA518820137005A7A07 /* perform.h */, + 12EDCFA618820137005A7A07 /* rule_transitions.cpp */, + 12EDCFA718820137005A7A07 /* rule_transitions.h */, ); + name = build_tables; path = lr; sourceTree = ""; }; - 1213061C182C854F00FCF928 /* lr */ = { + 1213061C182C854F00FCF928 /* build_tables */ = { isa = PBXGroup; children = ( - 12ED72A6186FC8220089229B /* transitions_spec.cpp */, - 12512092182F307C00C9B56A /* table_builder_spec.cpp */, - 12D1369C18328C5A005F3369 /* item_spec.cpp */, + 12EDCFB5188205BA005A7A07 /* item_spec.cpp */, + 12EDCFB6188205BA005A7A07 /* rule_transitions_spec.cpp */, + 12EDCFB7188205BA005A7A07 /* perform_spec.cpp */, ); - name = lr; - path = spec/lr; - sourceTree = ""; - }; - 1225CC6218765664000D4723 /* grammar */ = { - isa = PBXGroup; - children = ( - 1225CC6318765693000D4723 /* prepare_grammar_spec.cpp */, - ); - name = grammar; - path = compiler/grammar; + name = build_tables; + path = compiler/build_tables; sourceTree = ""; }; 125120A118307FCA00C9B56A /* grammars */ = { @@ -311,18 +303,17 @@ path = spec; sourceTree = ""; }; - 12ED72A5186FC6D90089229B /* grammar */ = { + 12ED72A5186FC6D90089229B /* prepare_grammar */ = { isa = PBXGroup; children = ( - 1225CC68187661C7000D4723 /* extract_tokens.cpp */, - 1225CC69187661C7000D4723 /* extract_tokens.h */, - 12F9A64F182DD6BC00FAF50C /* grammar.cpp */, - 12F9A650182DD6BC00FAF50C /* grammar.h */, - 1225CC6518765737000D4723 /* prepare_grammar.cpp */, - 1225CC6618765737000D4723 /* prepare_grammar.h */, - 1225CC6B18766969000D4723 /* search_for_symbols.cpp */, - 1225CC6C18766969000D4723 /* search_for_symbols.h */, + 12EDCF8F1881FCCA005A7A07 /* extract_tokens.cpp */, + 12EDCF901881FCCA005A7A07 /* extract_tokens.h */, + 12EDCF911881FCCA005A7A07 /* perform.cpp */, + 12EDCF921881FCCA005A7A07 /* perform.h */, + 12EDCF931881FCCA005A7A07 /* search_for_symbols.cpp */, + 12EDCF941881FCCA005A7A07 /* search_for_symbols.h */, ); + name = prepare_grammar; path = grammar; sourceTree = ""; }; @@ -334,23 +325,32 @@ path = parsers; sourceTree = ""; }; - 12FD4067185E8AF40041A84E /* code_gen */ = { + 12FD4067185E8AF40041A84E /* generate_code */ = { isa = PBXGroup; children = ( 12FD405F185E68470041A84E /* c_code.cpp */, 12FD4060185E68470041A84E /* c_code.h */, ); - path = code_gen; + path = generate_code; sourceTree = ""; }; 12FD40AC185EE4C00041A84E /* compiler */ = { isa = PBXGroup; children = ( - 12ED72A5186FC6D90089229B /* grammar */, - 12FD4067185E8AF40041A84E /* code_gen */, - 12130618182C84B700FCF928 /* lr */, + 12130618182C84B700FCF928 /* build_tables */, + 12FD40F1186641C00041A84E /* char_match.cpp */, + 12FD40F2186641C00041A84E /* char_match.h */, + 12EDCFAC18820181005A7A07 /* compile.cpp */, + 12EDCFAD18820181005A7A07 /* compile.h */, + 12FD4067185E8AF40041A84E /* generate_code */, + 12F9A64F182DD6BC00FAF50C /* grammar.cpp */, + 12F9A650182DD6BC00FAF50C /* grammar.h */, + 12FD40F5186A16020041A84E /* lex_table.cpp */, + 12EDCF9C18820116005A7A07 /* lex_table.h */, + 12EDCF9D18820116005A7A07 /* parse_table.cpp */, + 12EDCF9E18820116005A7A07 /* parse_table.h */, + 12ED72A5186FC6D90089229B /* prepare_grammar */, 12130602182C344400FCF928 /* rules */, - 12FD40F9186F4EBE0041A84E /* util */, ); path = compiler; sourceTree = ""; @@ -368,9 +368,9 @@ 12FD40AE185EE6610041A84E /* compiler */ = { isa = PBXGroup; children = ( - 1225CC6218765664000D4723 /* grammar */, - 12FD4063185E75290041A84E /* generate_parsers.cpp */, - 1213061C182C854F00FCF928 /* lr */, + 1225CC6318765693000D4723 /* prepare_grammar_spec.cpp */, + 12FD4063185E75290041A84E /* compile_fixtures.cpp */, + 1213061C182C854F00FCF928 /* build_tables */, 12D1369F18357066005F3369 /* rules */, 12F9A64C182DD5FD00FAF50C /* spec_helper.cpp */, 12F9A64D182DD5FD00FAF50C /* spec_helper.h */, @@ -407,16 +407,6 @@ path = include; sourceTree = ""; }; - 12FD40F9186F4EBE0041A84E /* util */ = { - isa = PBXGroup; - children = ( - 12C344421822F27700B07BE3 /* transition_map.h */, - 12FD40F1186641C00041A84E /* char_match.cpp */, - 12FD40F2186641C00041A84E /* char_match.h */, - ); - path = util; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -485,37 +475,38 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 12FD40D7185FEEDB0041A84E /* item_spec.cpp in Sources */, 12130614182C3A1700FCF928 /* seq.cpp in Sources */, - 1225CC6A187661C7000D4723 /* extract_tokens.cpp in Sources */, - 129D242C183EB1EB00FE9F71 /* table_builder.cpp in Sources */, 125120A4183083BD00C9B56A /* arithmetic.cpp in Sources */, - 1213061B182C84DF00FCF928 /* item.cpp in Sources */, + 12EDCFB31882039A005A7A07 /* rule_transitions.cpp in Sources */, 12FD40D9185FEEDF0041A84E /* pattern_spec.cpp in Sources */, 12130617182C3D2900FCF928 /* string.cpp in Sources */, - 12FD40E2186245FE0041A84E /* transitions.cpp in Sources */, + 12EDCFBD188205BF005A7A07 /* perform_spec.cpp in Sources */, 12130611182C3A1100FCF928 /* blank.cpp in Sources */, 1213060E182C398300FCF928 /* choice.cpp in Sources */, 12F9A64E182DD5FD00FAF50C /* spec_helper.cpp in Sources */, + 12EDCFB018820392005A7A07 /* item.cpp in Sources */, 12FD40F7186A16020041A84E /* lex_table.cpp in Sources */, 12FD40E918641FB70041A84E /* rules.cpp in Sources */, + 12EDCF981881FCD5005A7A07 /* extract_tokens.cpp in Sources */, 12FD4061185E68470041A84E /* c_code.cpp in Sources */, 12FD40D8185FEEDF0041A84E /* rules_spec.cpp in Sources */, - 125120A018307DEC00C9B56A /* parse_table.cpp in Sources */, - 12FD4064185E75290041A84E /* generate_parsers.cpp in Sources */, + 12FD4064185E75290041A84E /* compile_fixtures.cpp in Sources */, + 12EDCFAF18820387005A7A07 /* parse_table.cpp in Sources */, 1214930E181E200B008E9BDA /* main.cpp in Sources */, 12F9A651182DD6BC00FAF50C /* grammar.cpp in Sources */, - 12FD40D6185FEEDB0041A84E /* table_builder_spec.cpp in Sources */, 12D136A4183678A2005F3369 /* repeat.cpp in Sources */, 1225CC6418765693000D4723 /* prepare_grammar_spec.cpp in Sources */, + 12EDCF9A1881FCD9005A7A07 /* search_for_symbols.cpp in Sources */, 12FD40F3186641C00041A84E /* char_match.cpp in Sources */, + 12EDCFB21882039A005A7A07 /* perform.cpp in Sources */, + 12EDCFBB188205BF005A7A07 /* item_spec.cpp in Sources */, 12FD40E718639B910041A84E /* visitor.cpp in Sources */, - 1225CC6718765737000D4723 /* prepare_grammar.cpp in Sources */, - 1225CC6D18766969000D4723 /* search_for_symbols.cpp in Sources */, - 12ED72A7186FC8220089229B /* transitions_spec.cpp in Sources */, - 12130622182C85D300FCF928 /* item_set.cpp in Sources */, + 12EDCF991881FCD9005A7A07 /* perform.cpp in Sources */, + 12EDCFBC188205BF005A7A07 /* rule_transitions_spec.cpp in Sources */, 12130605182C348F00FCF928 /* character.cpp in Sources */, + 12EDCFB418820519005A7A07 /* compile.cpp in Sources */, 1213060B182C389100FCF928 /* symbol.cpp in Sources */, + 12EDCFB118820395005A7A07 /* item_set.cpp in Sources */, 1251209B1830145300C9B56A /* rule.cpp in Sources */, 27A343CA69E17E0F9EBEDF1C /* pattern.cpp in Sources */, ); @@ -526,14 +517,12 @@ buildActionMask = 2147483647; files = ( 12FD40B3185EEB5E0041A84E /* seq.cpp in Sources */, - 12FD40B4185EEB5E0041A84E /* table_builder.cpp in Sources */, 12FD40B6185EEB5E0041A84E /* arithmetic.cpp in Sources */, 12FD40DD185FF12C0041A84E /* parser.cpp in Sources */, - 12FD40B8185EEB5E0041A84E /* item.cpp in Sources */, 12EDCF8A187B498C005A7A07 /* tree_spec.cpp in Sources */, + 12EDCFA918820137005A7A07 /* item.cpp in Sources */, 12EDCF8D187C6282005A7A07 /* document.c in Sources */, 12FD40B9185EEB5E0041A84E /* string.cpp in Sources */, - 12FD40EF186641510041A84E /* transitions.cpp in Sources */, 12FD40BB185EEB5E0041A84E /* blank.cpp in Sources */, 12FD40F4186641C00041A84E /* char_match.cpp in Sources */, 12FD40BD185EEB5E0041A84E /* choice.cpp in Sources */, @@ -541,17 +530,19 @@ 12FD40BF185EEB5E0041A84E /* c_code.cpp in Sources */, 12FD40F8186A16030041A84E /* lex_table.cpp in Sources */, 12FD40D2185EEB970041A84E /* arithmetic.c in Sources */, + 12EDCFA818820137005A7A07 /* item_set.cpp in Sources */, 12FD40DB185FEF0D0041A84E /* arithmetic_spec.cpp in Sources */, - 12FD40C0185EEB5E0041A84E /* parse_table.cpp in Sources */, 12FD40F01866415D0041A84E /* visitor.cpp in Sources */, + 12EDCF9F18820116005A7A07 /* parse_table.cpp in Sources */, 12FD40C2185EEB5E0041A84E /* main.cpp in Sources */, 12FD40C3185EEB5E0041A84E /* grammar.cpp in Sources */, 12FD40C6185EEB5E0041A84E /* repeat.cpp in Sources */, - 12FD40C7185EEB5E0041A84E /* item_set.cpp in Sources */, 12FD40C8185EEB5E0041A84E /* character.cpp in Sources */, + 12EDCFAB18820137005A7A07 /* rule_transitions.cpp in Sources */, 12FD40C9185EEB5E0041A84E /* symbol.cpp in Sources */, 12FD40CA185EEB5E0041A84E /* rule.cpp in Sources */, 12FD40EE186641430041A84E /* rules.cpp in Sources */, + 12EDCFAA18820137005A7A07 /* perform.cpp in Sources */, 12FD40CB185EEB5E0041A84E /* pattern.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -568,6 +559,8 @@ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, spec/externals/igloo, src/externals/boost, + src/compiler, + src/runtime, ); STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = dynamic; USER_HEADER_SEARCH_PATHS = "src/externals/boost spec/externals/igloo"; @@ -583,6 +576,8 @@ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, spec/externals/igloo, src/externals/boost, + src/compiler, + src/runtime, ); STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = dynamic; USER_HEADER_SEARCH_PATHS = "src/externals/boost spec/externals/igloo";