summaryrefslogtreecommitdiffstats
path: root/src/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse.y')
-rw-r--r--src/parse.y21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/parse.y b/src/parse.y
index 8d8a081..4fcba12 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -15,10 +15,6 @@ static inline void free_symbol(solar::symbol_t *v) {
delete v;
}
-static inline void free_rule(solar::rule_t *v) {
- delete v;
-}
-
static inline void free_rhs(rhs_t *v) {
delete v;
}
@@ -40,12 +36,9 @@ static inline void free_rhs(rhs_t *v) {
%type STRING {std::string *} str
%destructor STRING free_string
-%type CHAR {char} c
+%type CHAR {unsigned char} c
-%type rule {solar::rule_t *}
-%destructor rule free_rule
-
%type rhs {rhs_t *}
%destructor rhs free_rhs
@@ -93,13 +86,17 @@ directive |= "%extra_arg" BLOCK(type) varname(name) {
grammar->extra_args.push_back(std::make_pair(*type, *name));
}
-directive |= rule(rule) {
- grammar->add_rule(*rule);
+directive |= SYMBOL(lhs) "|=" rhs(rhs) action(action) {
+ grammar->add_rule({solar::item_t(*lhs, rhs->first), rhs->second, *action});
}
+directive |= SYMBOL(lhs) "|=" '(' CHAR(c1) "..." CHAR(c2) ')' ';' {
+ vars_t vars;
+ vars.emplace_back();
-rule |= SYMBOL(lhs) "|=" rhs(rhs) action(action)
- [new solar::rule_t {solar::item_t(*lhs, rhs->first), rhs->second, *action}]
+ for (unsigned int c = c1; c <= c2; c++)
+ grammar->add_rule({solar::item_t(*lhs, {solar::symbol_t::make_char(c)}), vars, std::string()});
+}
rhs |= [new rhs_t()]