mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
fixed peg-parser for when
This commit is contained in:
parent
434bcd08fd
commit
e924220237
1 changed files with 13 additions and 3 deletions
|
@ -446,14 +446,14 @@ mod test_peg_grammar {
|
|||
[T::KeywordWhen] expr() [T::KeywordIs] when_branches()
|
||||
|
||||
rule when_branches() =
|
||||
[T::OpenIndent] when_branch()+ close_or_end()
|
||||
[T::OpenIndent] when_branch() ([T::SameIndent]? when_branch())* close_or_end()
|
||||
/ when_branch()+
|
||||
|
||||
pub rule when_branch() =
|
||||
when_match_pattern() ([T::Pipe] full_expr())* ([T::KeywordIf] full_expr())? [T::Arrow] when_branch_body()
|
||||
|
||||
rule when_branch_body() =
|
||||
[T::OpenIndent] full_expr() ([T::CloseIndent] / end_of_file())
|
||||
[T::OpenIndent] full_expr() close_or_end()
|
||||
/ full_expr()
|
||||
|
||||
rule var() =
|
||||
|
@ -807,6 +807,16 @@ test1 =
|
|||
assert_eq!(tokenparser::when(&tokens), Ok(()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_when_3() {
|
||||
let tokens = tokenize(
|
||||
r#"when list is
|
||||
Nil -> Cons a
|
||||
Nil -> Nil"#,
|
||||
);
|
||||
assert_eq!(tokenparser::when(&tokens), Ok(()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_when_in_defs() {
|
||||
let tokens = tokenize(
|
||||
|
@ -815,7 +825,7 @@ test1 =
|
|||
Ok v -> v
|
||||
"#,
|
||||
);
|
||||
|
||||
dbg!(&tokens);
|
||||
assert_eq!(tokenparser::module_defs(&tokens), Ok(()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue