From 4844eb55a7c1dca03f15d07ff22a34e3ab3d134c Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Sat, 16 Mar 2019 11:22:19 -0700 Subject: add unary plus sign and fix a bug --- Source/Parser/wp_parser.y | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Source/Parser/wp_parser.y') diff --git a/Source/Parser/wp_parser.y b/Source/Parser/wp_parser.y index e3a007949..3081125cc 100644 --- a/Source/Parser/wp_parser.y +++ b/Source/Parser/wp_parser.y @@ -38,7 +38,7 @@ %left '+' '-' %left '*' '/' %left '<' '>' -%nonassoc NEG +%nonassoc NEG UPLUS %right POW /* This specifies the type of `exp` (i.e., struct wp_node*). Rules @@ -75,6 +75,7 @@ exp: | exp '<' exp { $$ = wp_newf2(WP_LT, $1, $3); } | exp '>' exp { $$ = wp_newf2(WP_GT, $1, $3); } | '-'exp %prec NEG { $$ = wp_newnode(WP_NEG, $2, NULL); } +| '+'exp %prec UPLUS { $$ = $2; } | exp POW exp { $$ = wp_newf2(WP_POW, $1, $3); } | F1 '(' exp ')' { $$ = wp_newf1($1, $3); } | F2 '(' exp ',' exp ')' { $$ = wp_newf2($1, $3, $5); } -- cgit v1.2.3