summaryrefslogtreecommitdiffstats
path: root/parser.y
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2014-07-14 15:38:58 -0500
committerNicolas Williams <nico@cryptonector.com>2014-07-14 16:41:48 -0500
commit2bb9fc5dda31ed5359eca76c33ad6c9958d7f2e1 (patch)
tree499831e92d12ad14e8e29f35f4af9dfe7793bce9 /parser.y
parentea3e947b50086b6b8601a22e0f92c73887e35150 (diff)
Fix #484, try/catch syntax has conflicts
Diffstat (limited to 'parser.y')
-rw-r--r--parser.y13
1 files changed, 11 insertions, 2 deletions
diff --git a/parser.y b/parser.y
index 79483713..fcada1a5 100644
--- a/parser.y
+++ b/parser.y
@@ -50,7 +50,6 @@ struct lexer_param;
%token <literal> FIELD
%token <literal> LITERAL
%token <literal> FORMAT
-%token Q "?"
%token REC ".."
%token SETMOD "%="
%token EQ "=="
@@ -84,6 +83,9 @@ struct lexer_param;
%token QQSTRING_INTERP_END
%token QQSTRING_END
+/* see Exp '?' rule */
+%expect 9
+
/* revolting hack */
%left ';'
%right '|'
@@ -95,6 +97,9 @@ struct lexer_param;
%nonassoc NEQ EQ '<' '>' LESSEQ GREATEREQ
%left '+' '-'
%left '*' '/' '%'
+%precedence '?'
+%precedence "try"
+%precedence "catch"
%type <blk> Exp Term MkDict MkDictPair ExpD ElseBody QQString FuncDef FuncDefs String
@@ -269,11 +274,15 @@ Term "as" '$' IDENT '|' Exp {
$$ = $2;
} |
+// This rule conflicts with all the other rules using the '?' operator.
+// It doesn't matter which bison prefers: all of them result in the same
+// syntax and semantics, but the more specific rules optimize better
+// because they use opcodes specifically made for the purpose. We
+// expect 9 such conflicts.
Exp '?' {
$$ = gen_try($1, gen_op_simple(BACKTRACK));
} |
-
Exp '=' Exp {
$$ = gen_call("_assign", BLOCK(gen_lambda($1), gen_lambda($3)));
} |