From 0b3cdb4ae2fa176ba74a48ff7a1616395079c151 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 5 Aug 2014 22:46:43 +0200 Subject: too much to tell --- fast/grammar.hh | 58 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 22 deletions(-) (limited to 'fast/grammar.hh') diff --git a/fast/grammar.hh b/fast/grammar.hh index 51501cf..48a5116 100644 --- a/fast/grammar.hh +++ b/fast/grammar.hh @@ -1,38 +1,42 @@ #pragma once +#include #include -#include #include -#include -#include +#include #include +#include +#include -#include "dummyvector.h" +#include "sparse_vector.hh" +#include "util.hh" using namespace std; -string esc_str(const string& s); // FIXME - namespace G { struct NT { - string symbol; - unsigned int index; + string symbol; + size_t index; NT() {}; NT(string& s); + string repr() const; string escaped() const; + friend ostream& operator<<(ostream& os, const NT& t); }; struct T { - string word; + string word; // use word ids instead? + + T(const string& s); - T(string& s); string repr() const; - string escaped() const { return esc_str(word); } + string escaped() const; + friend ostream& operator<<(ostream& os, const NT& nt); }; @@ -47,26 +51,33 @@ struct Item { 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; + NT* lhs; + vector rhs; + vector target; + size_t arity; +Sv::SparseVector* f; + map order; + string as_str_; // FIXME Rule() {}; - Rule(string& s); + Rule(const string& s); + string repr() const; string escaped() const; + friend ostream& operator<<(ostream& os, const Rule& r); - MSGPACK_DEFINE(); + void prep_for_serialization_() { as_str_ = escaped(); }; // FIXME + + MSGPACK_DEFINE(as_str_); // TODO }; struct Grammar { @@ -75,9 +86,12 @@ struct Grammar { vector start_nt; vector start_t; - Grammar(string fn); - void add_glue(); - void add_pass_through(); + Grammar() {}; + Grammar(const string& fn); + + void add_glue(); // TODO + void add_pass_through(const string& input); // TODO + friend ostream& operator<<(ostream& os, const Grammar& g); }; -- cgit v1.2.3