Add case guards to parser
This commit is contained in:
parent
20cab3ae57
commit
9e85658ca4
@ -282,9 +282,14 @@ stmt() ->
|
||||
, {else, keyword(else), body()}
|
||||
])).
|
||||
|
||||
branch() ->
|
||||
branch() -> choice(unguarded_branch(), guarded_branch()).
|
||||
|
||||
unguarded_branch() ->
|
||||
?RULE(pattern(), keyword('=>'), body(), {'case', _2, _1, _3}).
|
||||
|
||||
guarded_branch() ->
|
||||
?RULE(pattern(), tok('|'), expr(), keyword('=>'), body(), {'case', _4, _1, _3, _5}).
|
||||
|
||||
pattern() ->
|
||||
?LET_P(E, expr(), parse_pattern(E)).
|
||||
|
||||
|
@ -145,7 +145,8 @@
|
||||
-type stmt() :: letbind()
|
||||
| expr().
|
||||
|
||||
-type alt() :: {'case', ann(), pat(), expr()}.
|
||||
-type alt() :: {'case', ann(), pat(), expr()}
|
||||
| {'case', ann(), pat(), expr(), expr()}.
|
||||
|
||||
-type lvalue() :: nonempty_list(elim()).
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user