about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2008-08-14T10·14+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2008-08-14T10·14+0000
commite8188384129bda7c8cdd5e17023ab05047551e6e (patch)
tree7b40bce45285a1113498d1acd2c1f814909a146a /src
parentefe4b690ae4de5f0adea99abb1176a64a099d433 (diff)
* "pattern" non-terminal.
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/parser.y13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 067a0f8d54da..7713021a909e 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -211,7 +211,7 @@ static void freeAndUnprotect(void * p)
 }
 
 %type <t> start expr expr_function expr_if expr_op
-%type <t> expr_app expr_select expr_simple bind inheritsrc formal
+%type <t> expr_app expr_select expr_simple bind inheritsrc formal pattern
 %type <ts> binds ids expr_list formals string_parts ind_string_parts
 %token <t> ID INT STR IND_STR PATH URI
 %token IF THEN ELSE ASSERT WITH LET IN REC INHERIT EQ NEQ AND OR IMPL
@@ -236,10 +236,8 @@ start: expr { data->result = $1; };
 expr: expr_function;
 
 expr_function
-  : '{' formals '}' ':' expr_function
-    { $$ = makeFunction(makeAttrsPat($2), $5, CUR_POS); }
-  | ID ':' expr_function
-    { $$ = makeFunction(makeVarPat($1), $3, CUR_POS); }
+  : pattern ':' expr_function
+    { $$ = makeFunction($1, $3, CUR_POS); }
   | ASSERT expr ';' expr_function
     { $$ = makeAssert($2, $4, CUR_POS); }
   | WITH expr ';' expr_function
@@ -320,6 +318,11 @@ ind_string_parts
   | { $$ = ATempty; }
   ;
 
+pattern
+  : ID { $$ = makeVarPat($1); }
+  | '{' formals '}' { $$ = makeAttrsPat($2); }
+  ;
+
 binds
   : binds bind { $$ = ATinsert($1, $2); }
   | { $$ = ATempty; }