summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-04-18 17:58:44 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-04-18 17:58:44 +0200
commit3818c8c5282e14a97ff978d0dc2b114ad0fa6edd (patch)
tree86fef20537e42aa6e4e74e3d5d9eb8fd7ae0de13 /src
parent4ed7d5a1b214101efadbff4b808dbc782ef97dee (diff)
downloadsolar-3818c8c5282e14a97ff978d0dc2b114ad0fa6edd.tar
solar-3818c8c5282e14a97ff978d0dc2b114ad0fa6edd.zip
parse: rename varname nonterm to csymbol
Diffstat (limited to 'src')
-rw-r--r--src/parse.cpp62
-rw-r--r--src/parse.y22
2 files changed, 42 insertions, 42 deletions
diff --git a/src/parse.cpp b/src/parse.cpp
index f9cefc1..2b5b9f7 100644
--- a/src/parse.cpp
+++ b/src/parse.cpp
@@ -14,11 +14,11 @@ namespace solar {
typedef union parse_symbol_value {
parse_token_value_t token;
std::string *symbol_action;
+ std::string *symbol_csymbol;
std::vector<std::string> *symbol_namespace;
rhs_t *symbol_rhs;
symbol_t *symbol_symbol;
symbol_t *symbol_term;
- std::string *symbol_varname;
} parse_symbol_value_t;
typedef struct parse_context_state {
@@ -845,8 +845,8 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
switch (token) {
default:
parser->top -= 1;
- result.symbol_varname = parse_reduce_27(parser->stack[parser->top + 0].value.token.str, grammar);
- parser->stack[parser->top].value.symbol_varname = result.symbol_varname;
+ result.symbol_csymbol = parse_reduce_27(parser->stack[parser->top + 0].value.token.str, grammar);
+ parser->stack[parser->top].value.symbol_csymbol = result.symbol_csymbol;
switch (parser->stack[parser->top].state) {
case 44:
parser->stack[++parser->top].state = 53;
@@ -861,7 +861,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
break;
case 82:
- parser->stack[++parser->top].state = 87;
+ parser->stack[++parser->top].state = 86;
break;
case 85:
@@ -884,8 +884,8 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
switch (token) {
default:
parser->top -= 1;
- result.symbol_varname = parse_reduce_26(parser->stack[parser->top + 0].value.token.str, grammar);
- parser->stack[parser->top].value.symbol_varname = result.symbol_varname;
+ result.symbol_csymbol = parse_reduce_26(parser->stack[parser->top + 0].value.token.str, grammar);
+ parser->stack[parser->top].value.symbol_csymbol = result.symbol_csymbol;
switch (parser->stack[parser->top].state) {
case 44:
parser->stack[++parser->top].state = 53;
@@ -900,7 +900,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
break;
case 82:
- parser->stack[++parser->top].state = 87;
+ parser->stack[++parser->top].state = 86;
break;
case 85:
@@ -1030,9 +1030,9 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
switch (token) {
default:
parser->top -= 5;
- result.symbol_rhs = parse_reduce_14(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, parser->stack[parser->top + 3].value.symbol_varname, grammar);
+ result.symbol_rhs = parse_reduce_14(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, parser->stack[parser->top + 3].value.symbol_csymbol, grammar);
delete(parser->stack[parser->top + 1].value.symbol_symbol);
- delete(parser->stack[parser->top + 3].value.symbol_varname);
+ delete(parser->stack[parser->top + 3].value.symbol_csymbol);
parser->stack[parser->top].value.symbol_rhs = result.symbol_rhs;
parser->stack[++parser->top].state = 19;
}
@@ -1117,10 +1117,10 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
switch (token) {
default:
parser->top -= 8;
- parse_reduce_4(parser->stack[parser->top + 5].value.symbol_term, parser->stack[parser->top + 6].value.token.str, parser->stack[parser->top + 7].value.symbol_varname, grammar);
+ parse_reduce_4(parser->stack[parser->top + 5].value.symbol_term, parser->stack[parser->top + 6].value.token.str, parser->stack[parser->top + 7].value.symbol_csymbol, grammar);
delete(parser->stack[parser->top + 5].value.symbol_term);
delete(parser->stack[parser->top + 6].value.token.str);
- delete(parser->stack[parser->top + 7].value.symbol_varname);
+ delete(parser->stack[parser->top + 7].value.symbol_csymbol);
parser->stack[++parser->top].state = 2;
}
break;
@@ -1129,9 +1129,9 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
switch (token) {
default:
parser->top -= 6;
- result.symbol_rhs = parse_reduce_15(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, parser->stack[parser->top + 4].value.symbol_varname, grammar);
+ result.symbol_rhs = parse_reduce_15(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, parser->stack[parser->top + 4].value.symbol_csymbol, grammar);
delete(parser->stack[parser->top + 1].value.symbol_symbol);
- delete(parser->stack[parser->top + 4].value.symbol_varname);
+ delete(parser->stack[parser->top + 4].value.symbol_csymbol);
parser->stack[parser->top].value.symbol_rhs = result.symbol_rhs;
parser->stack[++parser->top].state = 19;
}
@@ -1275,6 +1275,17 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 86:
switch (token) {
+ default:
+ parser->top -= 1;
+ result.symbol_namespace = parse_reduce_20(parser->stack[parser->top + 0].value.symbol_csymbol, grammar);
+ delete(parser->stack[parser->top + 0].value.symbol_csymbol);
+ parser->stack[parser->top].value.symbol_namespace = result.symbol_namespace;
+ parser->stack[++parser->top].state = 87;
+ }
+ break;
+
+ case 87:
+ switch (token) {
case ':':
parser->stack[++parser->top].state = 90;
return 1;
@@ -1287,17 +1298,6 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
}
break;
- case 87:
- switch (token) {
- default:
- parser->top -= 1;
- result.symbol_namespace = parse_reduce_20(parser->stack[parser->top + 0].value.symbol_varname, grammar);
- delete(parser->stack[parser->top + 0].value.symbol_varname);
- parser->stack[parser->top].value.symbol_namespace = result.symbol_namespace;
- parser->stack[++parser->top].state = 86;
- }
- break;
-
case 88:
switch (token) {
case TOK_SYMBOL:
@@ -1317,9 +1317,9 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
switch (token) {
default:
parser->top -= 12;
- parse_reduce_9(parser->stack[parser->top + 10].value.token.str, parser->stack[parser->top + 11].value.symbol_varname, grammar);
+ parse_reduce_9(parser->stack[parser->top + 10].value.token.str, parser->stack[parser->top + 11].value.symbol_csymbol, grammar);
delete(parser->stack[parser->top + 10].value.token.str);
- delete(parser->stack[parser->top + 11].value.symbol_varname);
+ delete(parser->stack[parser->top + 11].value.symbol_csymbol);
parser->stack[++parser->top].state = 2;
}
break;
@@ -1339,9 +1339,9 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
switch (token) {
default:
parser->top -= 13;
- parse_reduce_5(parser->stack[parser->top + 11].value.symbol_symbol, parser->stack[parser->top + 12].value.symbol_varname, grammar);
+ parse_reduce_5(parser->stack[parser->top + 11].value.symbol_symbol, parser->stack[parser->top + 12].value.symbol_csymbol, grammar);
delete(parser->stack[parser->top + 11].value.symbol_symbol);
- delete(parser->stack[parser->top + 12].value.symbol_varname);
+ delete(parser->stack[parser->top + 12].value.symbol_csymbol);
parser->stack[++parser->top].state = 2;
}
break;
@@ -1365,10 +1365,10 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
switch (token) {
default:
parser->top -= 4;
- result.symbol_namespace = parse_reduce_21(parser->stack[parser->top + 0].value.symbol_namespace, parser->stack[parser->top + 3].value.symbol_varname, grammar);
- delete(parser->stack[parser->top + 3].value.symbol_varname);
+ result.symbol_namespace = parse_reduce_21(parser->stack[parser->top + 0].value.symbol_namespace, parser->stack[parser->top + 3].value.symbol_csymbol, grammar);
+ delete(parser->stack[parser->top + 3].value.symbol_csymbol);
parser->stack[parser->top].value.symbol_namespace = result.symbol_namespace;
- parser->stack[++parser->top].state = 86;
+ parser->stack[++parser->top].state = 87;
}
break;
diff --git a/src/parse.y b/src/parse.y
index cacf898..9e445e7 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -47,8 +47,8 @@ typedef std::pair<std::vector<solar::symbol_t>, vars_t> rhs_t;
%type term {symbol_t *}
%destructor term delete
-%type varname {std::string *}
-%destructor varname delete
+%type csymbol {std::string *}
+%destructor csymbol delete
%extra_arg {__attribute__((unused)) grammar_t *} grammar
@@ -62,11 +62,11 @@ directive |= "%type" SYMBOL(nonterm) BLOCK(type) {
grammar->nonterm_types.insert(std::make_pair(*nonterm, *type));
}
-directive |= "%type" term(term) BLOCK(type) varname(name) {
+directive |= "%type" term(term) BLOCK(type) csymbol(name) {
grammar->term_types.insert(std::make_pair(*term, std::make_pair(*type, *name)));
}
-directive |= "%destructor" symbol(sym) varname(name) {
+directive |= "%destructor" symbol(sym) csymbol(name) {
grammar->destructors.insert(std::make_pair(*sym, *name));
}
@@ -82,7 +82,7 @@ directive |= "%header" BLOCK(block) {
grammar->header_block = *block;
}
-directive |= "%extra_arg" BLOCK(type) varname(name) {
+directive |= "%extra_arg" BLOCK(type) csymbol(name) {
grammar->extra_args.push_back(std::make_pair(*type, *name));
}
@@ -107,14 +107,14 @@ rhs |= rhs(=rhs) symbol(sym) {
return rhs;
}
-rhs |= rhs(=rhs) symbol(sym) '(' varname(var) ')' {
+rhs |= rhs(=rhs) symbol(sym) '(' csymbol(var) ')' {
rhs->first.push_back(*sym);
rhs->second.emplace_back(*var, true);
return rhs;
}
-rhs |= rhs(=rhs) symbol(sym) '(' '=' varname(var) ')' {
+rhs |= rhs(=rhs) symbol(sym) '(' '=' csymbol(var) ')' {
rhs->first.push_back(*sym);
rhs->second.emplace_back(*var, false);
@@ -136,8 +136,8 @@ action |= BLOCK(=v) [v]
action |= SQBLOCK(v) [new std::string("return " + *v + ";")]
-namespace |= varname(v) [new std::vector<std::string> {*v}]
-namespace |= namespace(=ns) "::" varname(v) {
+namespace |= csymbol(v) [new std::vector<std::string> {*v}]
+namespace |= namespace(=ns) "::" csymbol(v) {
ns->push_back(*v);
return ns;
}
@@ -149,5 +149,5 @@ symbol |= term(=v) [v]
term |= SYMBOL_UC(v) [new symbol_t(symbol_t::make_term(*v))]
term |= CHAR(v) [new symbol_t(symbol_t::make_char(v))]
-varname |= SYMBOL_UC(=v) [v]
-varname |= SYMBOL(=v) [v]
+csymbol |= SYMBOL_UC(=v) [v]
+csymbol |= SYMBOL(=v) [v]