about summary refs log tree commit diff
path: root/src/libexpr/parser.y
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-02-19T13·11+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-02-19T13·11+0000
commitdbf547645d26baee030d7db0535e0c0be72c13cc (patch)
tree10471d4dce6cffb8614c61a2c596f0db9613361a /src/libexpr/parser.y
parent86b7efbdbe3c2da0f788df3ee7839cf3b88f7120 (diff)
* Resolve an ambiguity between ifs and attribute selection, e.g., `if
  b then x else y.z'.

Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r--src/libexpr/parser.y10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 257c0cd38ab2..bfd539a3f094 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -32,7 +32,7 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, void * data, char * s)
   ATermList ts;
 }
 
-%type <t> start expr expr_function expr_assert expr_op
+%type <t> start expr expr_function expr_assert expr_if expr_op
 %type <t> expr_app expr_select expr_simple bind inheritsrc formal
 %type <ts> binds ids expr_list formals
 %token <t> ID INT STR PATH URI
@@ -60,6 +60,12 @@ expr_function
 expr_assert
   : ASSERT expr ';' expr_assert
     { $$ = ATmake("Assert(<term>, <term>)", $2, $4); }
+  | expr_if
+  ;
+
+expr_if
+  : IF expr THEN expr ELSE expr
+    { $$ = ATmake("If(<term>, <term>, <term>)", $2, $4, $6); }
   | expr_op
   ;
 
@@ -102,8 +108,6 @@ expr_simple
   | '{' binds '}'
     { $$ = fixAttrs(0, $2); }
   | '[' expr_list ']' { $$ = ATmake("List(<term>)", $2); }
-  | IF expr THEN expr ELSE expr
-    { $$ = ATmake("If(<term>, <term>, <term>)", $2, $4, $6); }
   ;
 
 binds