#pragma once #include #include #include #include #include #include #include "dummyvector.h" using namespace std; string esc_str(const string& s); // FIXME namespace G { struct NT { string symbol; unsigned int index; NT() {}; NT(string& s); string repr() const; string escaped() const; friend ostream& operator<<(ostream& os, const NT& t); }; struct T { string word; T(string& s); string repr() const; string escaped() const { return esc_str(word); } friend ostream& operator<<(ostream& os, const NT& nt); }; enum item_type { NON_TERMINAL, TERMINAL }; struct Item { item_type type; NT* nt; T* t; Item(string& s); string repr() const; string escaped() const; friend ostream& operator<<(ostream& os, const Item& i); }; struct Rule { NT* lhs; vector rhs; vector target; //map map; size_t arity; DummyVector f; Rule() {}; Rule(string& s); string repr() const; string escaped() const; friend ostream& operator<<(ostream& os, const Rule& r); MSGPACK_DEFINE(); }; struct Grammar { vector rules; vector flat; vector start_nt; vector start_t; Grammar(string fn); void add_glue(); void add_pass_through(); friend ostream& operator<<(ostream& os, const Grammar& g); }; } // namespace G