mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-09-17 14:47:21 +03:00
Remove Missing Parenthesis parser error
This commit is contained in:
parent
0776b48781
commit
7dc78cac6f
@ -15,7 +15,6 @@ use chumsky::{
|
||||
IterParser, Parser,
|
||||
};
|
||||
use indexmap::{map::Entry, IndexMap};
|
||||
use itertools::fold;
|
||||
use logos::{Logos, SpannedIter};
|
||||
use std::{iter::Map, ops::Range, path::Path};
|
||||
|
||||
@ -414,8 +413,7 @@ where
|
||||
)
|
||||
}));
|
||||
|
||||
let paren_lhs =
|
||||
just(Token::LParen)
|
||||
let paren_lhs = just(Token::LParen)
|
||||
.ignore_then(lhs.clone().map_err(|err| map_unexpected_eof::<I>(err, Token::Name("<Name>".into()))))
|
||||
.then_ignore(just(Token::RParen))
|
||||
.then_ignore(just(Token::Equals).map_err(|err| map_unexpected_eof::<I>(err, Token::Equals)));
|
||||
@ -427,28 +425,7 @@ fn rule<'a, I>() -> impl Parser<'a, I, TopLevel, extra::Err<Rich<'a, Token>>>
|
||||
where
|
||||
I: ValueInput<'a, Token = Token, Span = SimpleSpan>,
|
||||
{
|
||||
let unclosed_terms = term()
|
||||
.and_is(soft_keyword("data").not().rewind())
|
||||
.and_is(rule_pattern().not().rewind())
|
||||
.repeated()
|
||||
.at_least(1)
|
||||
.collect::<Vec<Term>>()
|
||||
.boxed();
|
||||
|
||||
rule_pattern()
|
||||
.then(term()
|
||||
// FIXME: This is used to report a parsing error that would be unclear otherwise
|
||||
// couldn't implement it in terms of `.recover(via_parser(...))`
|
||||
.then(unclosed_terms.or_not()).validate(
|
||||
|(body, unclosed_terms), span, emit| match unclosed_terms {
|
||||
Some(t) => {
|
||||
emit.emit(Rich::custom(span, "Missing Parenthesis around rule body"));
|
||||
fold(t, body, Term::app)
|
||||
}
|
||||
None => body,
|
||||
},
|
||||
))
|
||||
.map(move |((name, pats), body)| TopLevel::Rule((name, Rule { pats, body })))
|
||||
rule_pattern().then(term()).map(move |((name, pats), body)| TopLevel::Rule((name, Rule { pats, body })))
|
||||
}
|
||||
|
||||
fn datatype<'a, I>() -> impl Parser<'a, I, TopLevel, extra::Err<Rich<'a, Token>>>
|
||||
|
@ -1 +1,2 @@
|
||||
main = *
|
||||
(
|
@ -1,5 +0,0 @@
|
||||
Foo a b = a b
|
||||
Bar a b = Foo * (+ a b)
|
||||
Baz = * *
|
||||
|
||||
main = Foo Baz
|
@ -1 +0,0 @@
|
||||
main = * *
|
@ -1,3 +0,0 @@
|
||||
main = * * * *
|
||||
|
||||
data Foo = Bar
|
@ -2,5 +2,5 @@
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/compile_file/just_paren.hvm
|
||||
---
|
||||
At tests/golden_tests/compile_file/just_paren.hvm:1:1: found end of input expected <Name>
|
||||
[0m 1 | [4m[31m([0m
|
||||
At tests/golden_tests/compile_file/just_paren.hvm:2:1: found end of input expected <Name>
|
||||
[0m 2 | [4m[31m([0m
|
||||
|
@ -1,10 +0,0 @@
|
||||
---
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/compile_file/missing_paren.hvm
|
||||
---
|
||||
At tests/golden_tests/compile_file/missing_paren.hvm:2:11: Missing Parenthesis around rule body
|
||||
[0m 2 | Bar a b = [4m[31mFoo * (+ a b)[0m
|
||||
At tests/golden_tests/compile_file/missing_paren.hvm:3:7: Missing Parenthesis around rule body
|
||||
[0m 3 | Baz = [4m[31m* *[0m
|
||||
At tests/golden_tests/compile_file/missing_paren.hvm:5:8: Missing Parenthesis around rule body
|
||||
[0m 5 | main = [4m[31mFoo Baz[0m
|
@ -1,6 +0,0 @@
|
||||
---
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/parse_file/missing_paren.hvm
|
||||
---
|
||||
At tests/golden_tests/parse_file/missing_paren.hvm:1:8: Missing Parenthesis around rule body
|
||||
[0m 1 | main = [4m[31m* *[0m
|
@ -1,6 +0,0 @@
|
||||
---
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/parse_file/missing_paren_then_adt.hvm
|
||||
---
|
||||
At tests/golden_tests/parse_file/missing_paren_then_adt.hvm:1:8: Missing Parenthesis around rule body
|
||||
[0m 1 | main = [4m[31m* * * *[0m
|
Loading…
Reference in New Issue
Block a user