summaryrefslogtreecommitdiffstats
path: root/src/generator.hpp
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-03-31 22:52:25 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-03-31 23:40:44 +0200
commit3f1b701ad15458829468ce176ee6cecd16c4b420 (patch)
treef237e4925191a002adbcd4745a6288da84c3194a /src/generator.hpp
parent342f927aace815c2b6e7903def14d4aca9bc2233 (diff)
downloadsolar-3f1b701ad15458829468ce176ee6cecd16c4b420.tar
solar-3f1b701ad15458829468ce176ee6cecd16c4b420.zip
generator: add actions and gotos for LR(0) parsers
Diffstat (limited to 'src/generator.hpp')
-rw-r--r--src/generator.hpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/generator.hpp b/src/generator.hpp
index b901785..955739f 100644
--- a/src/generator.hpp
+++ b/src/generator.hpp
@@ -36,26 +36,33 @@ namespace solar {
class generator_t {
private:
- std::multimap<std::string, item_t> rules;
+ std::vector<item_t> rules;
+ std::map<item_t, size_t> rule_ids;
+ std::multimap<std::string, size_t> nonterms;
+
+ std::set<symbol_t> terminals;
+
std::multimap<symbol_t, item_t> items;
- std::map<std::set<item_t>, unsigned> itemsets;
- std::map<std::pair<unsigned, symbol_t>, unsigned> transitions;
+ std::map<std::set<item_t>, size_t> itemsets;
+
+ std::multimap<std::pair<unsigned, symbol_t>, std::pair<char, unsigned>> actions;
+ std::map<std::pair<unsigned, symbol_t>, unsigned> gotos;
void close_set(std::set<item_t> *set);
std::set<item_t> get_set(const std::string &nonterm);
- std::pair<std::map<std::set<item_t>, unsigned>::iterator, bool> add_set(const std::set<item_t> &set) {
+ std::pair<std::map<std::set<item_t>, size_t>::iterator, bool> add_set(const std::set<item_t> &set) {
return itemsets.emplace(set, itemsets.size());
}
void generate_itemsets();
static void print_symbol(const symbol_t &sym);
- static void print_item(const item_t &item);
+ static void print_item(const item_t &item, bool point);
static void print_set(const std::set<item_t> &set);
public:
- generator_t(const std::set<item_t> &rules0);
+ generator_t(const std::vector<item_t> &rules0);
};
}