summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-04-10 22:00:34 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-04-10 22:00:34 +0200
commit0e9b564f8cb89e377738723fc431c1420f2f360c (patch)
tree4187fb7b7011fe7a408bdb1d0b92a3df2b4c8aa9 /src
parent4976085b722319a29a84e0591ba52d6cfd94b3da (diff)
downloadsolar-0e9b564f8cb89e377738723fc431c1420f2f360c.tar
solar-0e9b564f8cb89e377738723fc431c1420f2f360c.zip
output: rename i argument to state
Diffstat (limited to 'src')
-rw-r--r--src/output.cpp4
-rw-r--r--src/output.hpp2
-rw-r--r--src/output_lr0.cpp14
-rw-r--r--src/output_lr0.hpp4
-rw-r--r--src/output_slr.cpp22
-rw-r--r--src/output_slr.hpp6
6 files changed, 26 insertions, 26 deletions
diff --git a/src/output.cpp b/src/output.cpp
index 9c30443..cd08a9e 100644
--- a/src/output.cpp
+++ b/src/output.cpp
@@ -214,8 +214,8 @@ void output_t::emit_reductions() {
}
void output_t::emit_states() {
- for (size_t i = 0; i < get_generator()->get_state_count(); i++)
- emit_state(i);
+ for (size_t state = 0; state < get_generator()->get_state_count(); state++)
+ emit_state(state);
}
void output_t::emit_header_include() {
diff --git a/src/output.hpp b/src/output.hpp
index da5fb2f..6704ed4 100644
--- a/src/output.hpp
+++ b/src/output.hpp
@@ -72,7 +72,7 @@ protected:
void initialize();
virtual const generator_t * get_generator() = 0;
- virtual void emit_state(unsigned i) = 0;
+ virtual void emit_state(unsigned state) = 0;
output_t(const char *header, const char *source);
diff --git a/src/output_lr0.cpp b/src/output_lr0.cpp
index b821333..031ed43 100644
--- a/src/output_lr0.cpp
+++ b/src/output_lr0.cpp
@@ -29,16 +29,16 @@
namespace solar {
-void output_lr0_t::emit_state_shift(unsigned i) {
+void output_lr0_t::emit_state_shift(unsigned state) {
std::fprintf(source_file, "\t\t\tswitch (token) {\n");
- if (generator->get_shifts().find(std::make_pair(i, symbol_t::make_nonterm(""))) != generator->get_shifts().end()) {
+ if (generator->get_shifts().find(std::make_pair(state, symbol_t::make_nonterm(""))) != generator->get_shifts().end()) {
std::fprintf(source_file, "\t\t\tcase 0:\n");
std::fprintf(source_file, "\t\t\t\treturn 0;\n\n");
}
for (const auto &token : generator->get_terminals()) {
- auto it = generator->get_shifts().find(std::make_pair(i, token));
+ auto it = generator->get_shifts().find(std::make_pair(state, token));
if (it == generator->get_shifts().end())
continue;
@@ -124,12 +124,12 @@ void output_lr0_t::emit_state_reduce(const item_t &item, int rule_id) {
}
}
-void output_lr0_t::emit_state(unsigned i) {
- std::fprintf(source_file, "\t\tcase %u:\n", i);
+void output_lr0_t::emit_state(unsigned state) {
+ std::fprintf(source_file, "\t\tcase %u:\n", state);
- auto it = generator->get_reductions().find(i);
+ auto it = generator->get_reductions().find(state);
if (it == generator->get_reductions().end()) {
- emit_state_shift(i);
+ emit_state_shift(state);
}
else {
const rule_t &rule = generator->get_grammar().rules[it->second];
diff --git a/src/output_lr0.hpp b/src/output_lr0.hpp
index dc77761..dd95318 100644
--- a/src/output_lr0.hpp
+++ b/src/output_lr0.hpp
@@ -36,7 +36,7 @@ class output_lr0_t : public output_t {
private:
const generator_lr0_t *generator;
- void emit_state_shift(unsigned i);
+ void emit_state_shift(unsigned state);
void emit_state_reduce(const item_t &item, int rule_id);
protected:
@@ -44,7 +44,7 @@ protected:
return generator;
}
- virtual void emit_state(unsigned i);
+ virtual void emit_state(unsigned state);
public:
output_lr0_t(const generator_lr0_t *generator0, const char *header, const char *source) : output_t(header, source), generator(generator0) {
diff --git a/src/output_slr.cpp b/src/output_slr.cpp
index 371d55b..01b0560 100644
--- a/src/output_slr.cpp
+++ b/src/output_slr.cpp
@@ -33,8 +33,8 @@
namespace solar {
-void output_slr_t::emit_state_shift(unsigned i, const symbol_t &token) {
- auto it = generator->get_shifts().find(std::make_pair(i, token));
+void output_slr_t::emit_state_shift(unsigned state, const symbol_t &token) {
+ auto it = generator->get_shifts().find(std::make_pair(state, token));
if (it == generator->get_shifts().end())
return;
@@ -108,7 +108,7 @@ void output_slr_t::emit_state_reduce(const item_t &item, const symbol_t &token,
std::fprintf(source_file, "\t\t\t\tcase %u:\n", unsigned(i));
std::fprintf(source_file, "\t\t\t\t\tparser->stack[++parser->top].state = %u;\n", unsigned(it->second));
- std::fprintf(source_file, "\t\t\t\t\tbreak;\n");
+ std::fprintf(source_file, "\t\t\t\t\tbreak;\n\n");
}
@@ -118,10 +118,10 @@ void output_slr_t::emit_state_reduce(const item_t &item, const symbol_t &token,
std::fprintf(source_file, "\t\t\t\tbreak;\n\n");
}
-void output_slr_t::do_emit_state(unsigned i, const symbol_t &token) {
- auto it = generator->get_reductions().find(std::make_pair(i, token));
+void output_slr_t::do_emit_state(unsigned state, const symbol_t &token) {
+ auto it = generator->get_reductions().find(std::make_pair(state, token));
if (it == generator->get_reductions().end()) {
- emit_state_shift(i, token);
+ emit_state_shift(state, token);
}
else {
const rule_t &rule = generator->get_grammar().rules[it->second];
@@ -129,19 +129,19 @@ void output_slr_t::do_emit_state(unsigned i, const symbol_t &token) {
}
}
-void output_slr_t::emit_state(unsigned i) {
- std::fprintf(source_file, "\t\tcase %u:\n", i);
+void output_slr_t::emit_state(unsigned state) {
+ std::fprintf(source_file, "\t\tcase %u:\n", state);
std::fprintf(source_file, "\t\t\tswitch (token) {\n");
- if (generator->get_shifts().find(std::make_pair(i, symbol_t::make_nonterm(""))) != generator->get_shifts().end()) {
+ if (generator->get_shifts().find(std::make_pair(state, symbol_t::make_nonterm(""))) != generator->get_shifts().end()) {
std::fprintf(source_file, "\t\t\tcase 0:\n");
std::fprintf(source_file, "\t\t\t\treturn 0;\n\n");
}
- do_emit_state(i, symbol_t::empty());
+ do_emit_state(state, symbol_t::empty());
for (const symbol_t &token : generator->get_terminals())
- do_emit_state(i, token);
+ do_emit_state(state, token);
std::fprintf(source_file, "\t\t\tdefault:\n");
std::fprintf(source_file, "\t\t\t\treturn -1;\n");
diff --git a/src/output_slr.hpp b/src/output_slr.hpp
index 3c6690a..aac9511 100644
--- a/src/output_slr.hpp
+++ b/src/output_slr.hpp
@@ -36,16 +36,16 @@ class output_slr_t : public output_t {
private:
const generator_slr_t *generator;
- void emit_state_shift(unsigned i, const symbol_t &token);
+ void emit_state_shift(unsigned state, const symbol_t &token);
void emit_state_reduce(const item_t &item, const symbol_t &token, int rule_id);
- void do_emit_state(unsigned i, const symbol_t &token);
+ void do_emit_state(unsigned state, const symbol_t &token);
protected:
virtual const generator_t * get_generator() {
return generator;
}
- virtual void emit_state(unsigned i);
+ virtual void emit_state(unsigned state);
public:
output_slr_t(const generator_slr_t *generator0, const char *header, const char *source) : output_t(header, source), generator(generator0) {