Parsodus/include/Parsodus/lrtables/table.h

29 lines
654 B
C++

#pragma once
#ifndef PARSODUS_LRTABLES_TABLE_H_4JGXOTCZ
#define PARSODUS_LRTABLES_TABLE_H_4JGXOTCZ
#include <map>
#include <string>
#include <vector>
#include <utility>
namespace pds {
namespace lr {
enum class Action {
ERROR,
SHIFT,
REDUCE,
ACCEPT
};
struct LRTable {
std::vector<std::map<std::string, std::pair<Action, std::size_t>>> act; ///< indexed on state number, then on terminal -> action to take + (next state | rule applied)
std::vector<std::map<std::string, size_t>> goto_; ///< indexed on state number, then on nonterminal -> next state
};
} /* lr */
} /* pds */
#endif /* PARSODUS_LRTABLES_TABLE_H_4JGXOTCZ */