summaryrefslogtreecommitdiff
path: root/src/parser2.mly
diff options
context:
space:
mode:
authorBrian Campbell2017-12-06 17:10:30 +0000
committerBrian Campbell2017-12-06 17:36:59 +0000
commit87a8f3f491c5c5bb65cb7490e10da2c5c9676f17 (patch)
tree75008cb1201e26c374c26993c30852781edeb4dd /src/parser2.mly
parent98ddcaf12bd2ff2c42f2c20fcb145af806a7e6d8 (diff)
Add parsing for guards in function clauses
Breaks parsing ambiguities by removing = as an identifier in the old parser and requiring parentheses for some expressions in the new parser
Diffstat (limited to 'src/parser2.mly')
-rw-r--r--src/parser2.mly18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/parser2.mly b/src/parser2.mly
index 21959cf5..500344ad 100644
--- a/src/parser2.mly
+++ b/src/parser2.mly
@@ -998,15 +998,21 @@ exp_list:
| exp Comma exp_list
{ $1 :: $3 }
+funcl_patexp:
+ | pat Eq exp
+ { mk_pexp (Pat_exp ($1, $3)) $startpos $endpos }
+ | pat If_ exp0 Eq exp
+ { mk_pexp (Pat_when ($1, $3, $5)) $startpos $endpos }
+
funcl:
- | id pat Eq exp
- { mk_funcl (FCL_Funcl ($1, $2, $4)) $startpos $endpos }
+ | id funcl_patexp
+ { mk_funcl (FCL_Funcl ($1, $2)) $startpos $endpos }
funcls:
- | id pat Eq exp
- { [mk_funcl (FCL_Funcl ($1, $2, $4)) $startpos $endpos] }
- | id pat Eq exp And funcls
- { mk_funcl (FCL_Funcl ($1, $2, $4)) $startpos $endpos :: $6 }
+ | id funcl_patexp
+ { [mk_funcl (FCL_Funcl ($1, $2)) $startpos $endpos] }
+ | id funcl_patexp And funcls
+ { mk_funcl (FCL_Funcl ($1, $2)) $startpos $endpos :: $4 }
type_def:
| Typedef id typquant Eq typ