mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-09-11 03:45:29 +03:00
Merge pull request #400 from HigherOrderCO/bug/sc-703/fix-superposition-parsing
[sc-703] Fix superposition parsing
This commit is contained in:
commit
add15416db
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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}
|
||||
|
@ -2,4 +2,4 @@
|
||||
source: tests/golden_tests.rs
|
||||
input_file: examples/bitonic_sort.bend
|
||||
---
|
||||
16760832
|
||||
16646144
|
||||
|
@ -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)
|
||||
|
@ -2,4 +2,4 @@
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/run_file/imp_empty_literals.bend
|
||||
---
|
||||
λ* λa a
|
||||
[]
|
||||
|
Loading…
Reference in New Issue
Block a user