summaryrefslogtreecommitdiffstats
path: root/src/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse.y')
-rw-r--r--src/parse.y36
1 files changed, 12 insertions, 24 deletions
diff --git a/src/parse.y b/src/parse.y
index 259e0de..ed946e0 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 SQBLOCK {std::string *} str
%type STRING {std::string *} str
%type CHAR {char} c
@@ -78,9 +79,7 @@ rule |= SYMBOL_LC(lhs) "|=" rhs(rhs) action(action) {
}
-rhs |= {
- return new std::pair<std::vector<solar::symbol_t>, std::vector<std::string>>();
-}
+rhs |= [new std::pair<std::vector<solar::symbol_t>, std::vector<std::string>>()]
rhs |= rhs(rhs) symbol(sym) {
rhs->first.push_back(*sym);
@@ -112,18 +111,17 @@ rhs |= rhs(rhs) STRING(str) {
}
-action |= ';' {
- return new std::string;
-}
+action |= ';' [new std::string]
-action |= BLOCK(v) {
+action |= BLOCK(v) [v]
+
+action |= SQBLOCK(v) {
+ *v = "\n\treturn " + *v + ";\n";
return v;
}
-symbol |= term(v) {
- return v;
-}
+symbol |= term(v) [v]
symbol |= SYMBOL_LC(v) {
solar::symbol_t *ret = new solar::symbol_t(solar::symbol_t::make_nonterm(*v));
@@ -138,19 +136,9 @@ term |= SYMBOL_UC(v) {
return ret;
}
-term |= CHAR(v) {
- return new solar::symbol_t(solar::symbol_t::make_char(v));
-}
-
+term |= CHAR(v) [new solar::symbol_t(solar::symbol_t::make_char(v))]
-varname |= SYMBOL_LC(v) {
- return v;
-}
-varname |= SYMBOL_UC(v) {
- return v;
-}
-
-varname |= SYMBOL(v) {
- return v;
-}
+varname |= SYMBOL_LC(v) [v]
+varname |= SYMBOL_UC(v) [v]
+varname |= SYMBOL(v) [v]