Merge pull request #400 from HigherOrderCO/bug/sc-703/fix-superposition-parsing

[sc-703] Fix superposition parsing
This commit is contained in:
Nicolas Abril 2024-05-20 14:37:09 +02:00 committed by GitHub
commit add15416db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 17 additions and 6 deletions

View File

@ -124,7 +124,13 @@ impl<'a> PyParser<'a> {
}
let head = self.parse_expr(false)?;
self.skip_trivia();
if self.starts_with(":") { self.parse_map_init(head)? } else { self.parse_sup(head)? }
if self.try_consume(",") {
self.parse_sup(head)?
} else if self.try_consume(":") {
self.parse_map_init(head)?
} else {
self.expected("',' or ':'")?
}
}
// List or Comprehension
'[' => self.list_or_comprehension()?,
@ -226,7 +232,6 @@ impl<'a> PyParser<'a> {
fn parse_map_init(&mut self, head: Expr) -> ParseResult<Expr> {
let mut entries = Vec::new();
self.consume(":")?;
let val = self.parse_expr(false)?;
entries.push((head, val));
self.skip_trivia();

View File

@ -70,6 +70,10 @@ def era():
the_expr_killer = *
return the_expr_killer(9)
def sup():
x = {[1, 2], [3, 4, 5, 6]}
return x
def main():
do IO:
x <- IO.read();

View File

@ -1,6 +1,6 @@
def bar(x, y):
return {x y}
return {x, y}
def main(x):
use result = bar(1, x)
return {result result}
return {result, result}

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: examples/bitonic_sort.bend
---
16760832
16646144

View File

@ -32,6 +32,8 @@ input_file: tests/golden_tests/parse_file/imp_program.bend
(era) = let * = (+ 2 3); let the_expr_killer = *; (the_expr_killer 9)
(sup) = let x = {(List/Cons 1 (List/Cons 2 List/Nil)) (List/Cons 3 (List/Cons 4 (List/Cons 5 (List/Cons 6 List/Nil))))}; x
(main) = do IO { ask x = IO.read; x }
(List/Cons) = λhead λtail λList/Cons λList/Nil (List/Cons head tail)

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/imp_empty_literals.bend
---
λ* λa a
[]