summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-03-31 00:04:32 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-03-31 00:04:32 +0200
commit679aa4588460b53b3b43ad19e76865c373c8f221 (patch)
tree74f2b34d570b1e5213cdffe612db6c73df37276c
parent63640911b950905057f2ca925e0b2b2c530721ec (diff)
downloadsolar-679aa4588460b53b3b43ad19e76865c373c8f221.tar
solar-679aa4588460b53b3b43ad19e76865c373c8f221.zip
Rename state_t to parser_state_t
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/parser.cpp2
-rw-r--r--src/parser.hpp4
-rw-r--r--src/parser_state.cpp (renamed from src/state.cpp)12
-rw-r--r--src/parser_state.hpp (renamed from src/state.hpp)4
-rw-r--r--src/solar.cpp4
6 files changed, 14 insertions, 14 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bb5e874..67773dc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,7 +1,7 @@
add_executable(solar
lex.cpp
parser.cpp
+ parser_state.cpp
solar.cpp
- state.cpp
)
set_target_properties(solar PROPERTIES COMPILE_FLAGS "-std=c++11 -Wall")
diff --git a/src/parser.cpp b/src/parser.cpp
index bd4dfbf..c931ca6 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -49,7 +49,7 @@ parser_t * parser_alloc(void) {
return parser;
}
-int parser_push(parser_t *parser, int token, const value_t *value, state_t *state) {
+int parser_push(parser_t *parser, int token, const value_t *value, parser_state_t *state) {
switch (parser->state) {
case STATE_INIT:
switch (token) {
diff --git a/src/parser.hpp b/src/parser.hpp
index c5a1e48..0cd6b38 100644
--- a/src/parser.hpp
+++ b/src/parser.hpp
@@ -26,7 +26,7 @@
#pragma once
-#include "state.hpp"
+#include "parser_state.hpp"
#include <cstdint>
@@ -52,7 +52,7 @@ typedef struct parser parser_t;
parser_t * parser_alloc(void);
-int parser_push(parser_t *parser, int token, const value_t *value, state_t *state);
+int parser_push(parser_t *parser, int token, const value_t *value, parser_state_t *state);
void parser_free(parser_t *parser);
}
diff --git a/src/state.cpp b/src/parser_state.cpp
index 958ab3e..c8053be 100644
--- a/src/state.cpp
+++ b/src/parser_state.cpp
@@ -24,12 +24,12 @@
*/
-#include "state.hpp"
+#include "parser_state.hpp"
namespace solar {
-void state_t::new_rule(const char *nonterm) {
+void parser_state_t::new_rule(const char *nonterm) {
if (rules.empty()) {
// start rule
current.get_rhs().emplace_back(symbol_t::make_nonterm(nonterm));
@@ -40,19 +40,19 @@ void state_t::new_rule(const char *nonterm) {
}
-void state_t::add_rule_nonterminal(const char *nonterm) {
+void parser_state_t::add_rule_nonterminal(const char *nonterm) {
current.get_rhs().emplace_back(symbol_t::make_nonterm(nonterm));
}
-void state_t::add_rule_terminal(const char *term) {
+void parser_state_t::add_rule_terminal(const char *term) {
current.get_rhs().emplace_back(symbol_t::make_term(term));
}
-void state_t::add_rule_terminal(unsigned char term) {
+void parser_state_t::add_rule_terminal(unsigned char term) {
current.get_rhs().emplace_back(symbol_t::make_char(term));
}
-void state_t::add_rule() {
+void parser_state_t::add_rule() {
rules.emplace(current.get_lhs(), current);
while (current.has_next()) {
diff --git a/src/state.hpp b/src/parser_state.hpp
index 8069ef0..a0341c6 100644
--- a/src/state.hpp
+++ b/src/parser_state.hpp
@@ -34,7 +34,7 @@
namespace solar {
-class state_t {
+class parser_state_t {
private:
std::multimap<std::string, item_t> rules;
std::multimap<symbol_t, item_t> items;
@@ -42,7 +42,7 @@ private:
item_t current;
public:
- state_t() : current("") {}
+ parser_state_t() : current("") {}
const std::multimap<std::string, item_t> & get_rules() const {
return rules;
diff --git a/src/solar.cpp b/src/solar.cpp
index a5085a1..f466db8 100644
--- a/src/solar.cpp
+++ b/src/solar.cpp
@@ -33,7 +33,7 @@
namespace solar {
-bool read_grammar(const char *filename, state_t *state) {
+bool read_grammar(const char *filename, parser_state_t *state) {
FILE *file = fopen(filename, "r");
if (!file) {
std::fprintf(stderr, "unable to open file %s\n", filename);
@@ -75,7 +75,7 @@ bool read_grammar(const char *filename, state_t *state) {
int main() {
using namespace solar;
- state_t state;
+ parser_state_t state;
if (!read_grammar("grammar.y", &state))
return 1;