summaryrefslogtreecommitdiffstats
path: root/src/parse.y
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-04-10 17:22:55 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-04-10 17:26:20 +0200
commit48b791d443efa3fc41715ea7d177d583952a77ee (patch)
tree5ef937517ca45eddddaef04f46ee6d62d1a7a22b /src/parse.y
parent5a54699f18e3ac52fe18d854f6d57be6795ed8e5 (diff)
downloadsolar-48b791d443efa3fc41715ea7d177d583952a77ee.tar
solar-48b791d443efa3fc41715ea7d177d583952a77ee.zip
Allow specifying sequences of character terminals as strings
Diffstat (limited to 'src/parse.y')
-rw-r--r--src/parse.y14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/parse.y b/src/parse.y
index 46f5ff6..28f13ad 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -2,6 +2,7 @@
%type SYMBOL_UC {std::string *} str
%type SYMBOL_LC {std::string *} str
%type BLOCK {std::string *} str
+%type STRING {std::string *} str
%type CHAR {char} c
%type rule {solar::rule_t *}
@@ -65,7 +66,7 @@ grammar |= grammar EXTRA_ARG BLOCK(type) varname(name) {
}
-rule |= SYMBOL_LC(lhs) '|' '=' rhs(rhs) action(action) {
+rule |= SYMBOL_LC(lhs) "|=" rhs(rhs) action(action) {
auto *ret = new solar::rule_t {solar::item_t(*lhs, rhs->first), rhs->second, *action};
delete lhs;
@@ -98,6 +99,17 @@ rhs |= rhs(rhs) symbol(sym) '(' varname(var) ')' {
return rhs;
}
+rhs |= rhs(rhs) STRING(str) {
+ for (char c : *str) {
+ rhs->first.push_back(solar::symbol_t::make_char(c));
+ rhs->second.emplace_back();
+ }
+
+ delete str;
+
+ return rhs;
+}
+
action |= ';' {
return new std::string;