From f1916c39b820b7d10d1ae7d7447675c4224d8197 Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Sun, 24 Aug 2014 17:26:05 +0100
Subject: fixes
---
fast/grammar.hh | 51 ++++++++++++++++++++++++++-------------------------
1 file changed, 26 insertions(+), 25 deletions(-)
(limited to 'fast/grammar.hh')
diff --git a/fast/grammar.hh b/fast/grammar.hh
index e5acb8a..4906c46 100644
--- a/fast/grammar.hh
+++ b/fast/grammar.hh
@@ -49,32 +49,29 @@ struct NT : public Item {
index_ = 0; // default
string t(s);
t.erase(0, 1); t.pop_back(); // remove '[' and ']'
- istringstream ss(s);
+ istringstream ss(t);
if (ss >> index_) { // [i]
symbol_ = "";
index_ = stoi(s);
-
return;
- } else { // [X]
- symbol_ = s;
-
- return;
- }
- string buf;
- size_t j = 0;
- while (ss.good() && getline(ss, buf, ',')) {
- if (j == 0) {
- symbol_ = buf;
- } else {
- index_ = stoi(buf);
+ } else {
+ ss.clear();
+ string buf;
+ size_t j = 0;
+ while (ss.good() && getline(ss, buf, ',')) {
+ if (j == 0) {
+ symbol_ = buf;
+ } else {
+ index_ = stoi(buf);
+ }
+ j++;
}
- j++;
}
}
virtual size_t index() const { return index_; }
virtual symbol_t symbol() const { return symbol_; }
- virtual item_type type() { return NON_TERMINAL; }
+ virtual item_type type() const { return NON_TERMINAL; }
virtual ostream&
repr(ostream& os) const
@@ -103,7 +100,7 @@ struct T : public Item {
}
virtual symbol_t symbol() const { return symbol_; }
- virtual item_type type() { return TERMINAL; }
+ virtual item_type type() const { return TERMINAL; }
virtual ostream&
repr(ostream& os) const
@@ -169,7 +166,7 @@ Sv::SparseVector