mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
remove more syntax errors
This commit is contained in:
parent
b688fd11a9
commit
e815e57dcf
5 changed files with 37 additions and 30 deletions
|
@ -48,7 +48,7 @@ pub fn expr<'a>(min_indent: u16) -> impl Parser<'a, Expr<'a>, SyntaxError<'a>> {
|
|||
)
|
||||
}
|
||||
|
||||
fn expr_help<'a>(min_indent: u16) -> impl Parser<'a, Expr<'a>, EExpr<'a>> {
|
||||
pub fn expr_help<'a>(min_indent: u16) -> impl Parser<'a, Expr<'a>, EExpr<'a>> {
|
||||
move |arena, state: State<'a>| parse_expr_help(min_indent, arena, state)
|
||||
}
|
||||
|
||||
|
@ -2062,7 +2062,7 @@ fn list_literal_help<'a>(min_indent: u16) -> impl Parser<'a, Expr<'a>, List<'a>>
|
|||
move |arena, state| {
|
||||
let (_, (parsed_elems, final_comments), state) = collection_trailing_sep_e!(
|
||||
word1(b'[', List::Open),
|
||||
specialize_ref(List::Syntax, loc!(expr(min_indent))),
|
||||
specialize_ref(List::Expr, loc!(expr_help(min_indent))),
|
||||
word1(b',', List::End),
|
||||
word1(b']', List::End),
|
||||
min_indent,
|
||||
|
|
|
@ -426,7 +426,7 @@ pub enum EString<'a> {
|
|||
EndlessSingle(Row, Col),
|
||||
EndlessMulti(Row, Col),
|
||||
UnknownEscape(Row, Col),
|
||||
Format(&'a SyntaxError<'a>, Row, Col),
|
||||
Format(&'a EExpr<'a>, Row, Col),
|
||||
FormatEnd(Row, Col),
|
||||
}
|
||||
|
||||
|
@ -489,7 +489,6 @@ pub enum List<'a> {
|
|||
End(Row, Col),
|
||||
Space(BadInputError, Row, Col),
|
||||
|
||||
Syntax(&'a SyntaxError<'a>, Row, Col),
|
||||
Expr(&'a EExpr<'a>, Row, Col),
|
||||
|
||||
IndentOpen(Row, Col),
|
||||
|
@ -510,7 +509,6 @@ pub enum When<'a> {
|
|||
|
||||
Condition(&'a EExpr<'a>, Row, Col),
|
||||
Branch(&'a EExpr<'a>, Row, Col),
|
||||
Syntax(&'a SyntaxError<'a>, Row, Col),
|
||||
|
||||
IndentIs(Row, Col),
|
||||
IndentCondition(Row, Col),
|
||||
|
@ -531,7 +529,6 @@ pub enum If<'a> {
|
|||
Condition(&'a EExpr<'a>, Row, Col),
|
||||
ThenBranch(&'a EExpr<'a>, Row, Col),
|
||||
ElseBranch(&'a EExpr<'a>, Row, Col),
|
||||
Syntax(&'a SyntaxError<'a>, Row, Col),
|
||||
|
||||
IndentCondition(Row, Col),
|
||||
IndentIf(Row, Col),
|
||||
|
@ -566,9 +563,9 @@ pub enum PRecord<'a> {
|
|||
Field(Row, Col),
|
||||
Colon(Row, Col),
|
||||
Optional(Row, Col),
|
||||
|
||||
Pattern(&'a EPattern<'a>, Row, Col),
|
||||
// TODO remove
|
||||
Syntax(&'a SyntaxError<'a>, Row, Col),
|
||||
Expr(&'a EExpr<'a>, Row, Col),
|
||||
|
||||
Space(BadInputError, Row, Col),
|
||||
|
||||
|
@ -582,13 +579,9 @@ pub enum PRecord<'a> {
|
|||
pub enum PInParens<'a> {
|
||||
End(Row, Col),
|
||||
Open(Row, Col),
|
||||
///
|
||||
// TODO remove
|
||||
Syntax(&'a SyntaxError<'a>, Row, Col),
|
||||
Pattern(&'a EPattern<'a>, Row, Col),
|
||||
|
||||
///
|
||||
Space(BadInputError, Row, Col),
|
||||
///
|
||||
IndentOpen(Row, Col),
|
||||
IndentEnd(Row, Col),
|
||||
}
|
||||
|
|
|
@ -51,13 +51,6 @@ fn parse_closure_param<'a>(
|
|||
.parse(arena, state)
|
||||
}
|
||||
|
||||
pub fn loc_pattern<'a>(min_indent: u16) -> impl Parser<'a, Located<Pattern<'a>>, SyntaxError<'a>> {
|
||||
specialize(
|
||||
|e, _, _| SyntaxError::Pattern(e),
|
||||
loc_pattern_help(min_indent),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn loc_pattern_help<'a>(
|
||||
min_indent: u16,
|
||||
) -> impl Parser<'a, Located<Pattern<'a>>, EPattern<'a>> {
|
||||
|
@ -130,7 +123,7 @@ fn loc_pattern_in_parens_help<'a>(
|
|||
between!(
|
||||
word1(b'(', PInParens::Open),
|
||||
space0_around_ee(
|
||||
move |arena, state| specialize_ref(PInParens::Syntax, loc_pattern(min_indent))
|
||||
move |arena, state| specialize_ref(PInParens::Pattern, loc_pattern_help(min_indent))
|
||||
.parse(arena, state),
|
||||
min_indent,
|
||||
PInParens::Space,
|
||||
|
@ -386,7 +379,7 @@ fn record_pattern_field<'a>(min_indent: u16) -> impl Parser<'a, Located<Pattern<
|
|||
|
||||
match opt_loc_val {
|
||||
Some(First(_)) => {
|
||||
let val_parser = specialize_ref(PRecord::Syntax, loc_pattern(min_indent));
|
||||
let val_parser = specialize_ref(PRecord::Pattern, loc_pattern_help(min_indent));
|
||||
let (_, loc_val, state) =
|
||||
space0_before_e(val_parser, min_indent, PRecord::Space, PRecord::IndentColon)
|
||||
.parse(arena, state)?;
|
||||
|
@ -414,7 +407,7 @@ fn record_pattern_field<'a>(min_indent: u16) -> impl Parser<'a, Located<Pattern<
|
|||
}
|
||||
Some(Second(_)) => {
|
||||
let val_parser =
|
||||
specialize_ref(PRecord::Syntax, loc!(crate::expr::expr(min_indent)));
|
||||
specialize_ref(PRecord::Expr, loc!(crate::expr::expr_help(min_indent)));
|
||||
|
||||
let (_, loc_val, state) =
|
||||
space0_before_e(val_parser, min_indent, PRecord::Space, PRecord::IndentColon)
|
||||
|
|
|
@ -231,7 +231,7 @@ pub fn parse<'a>() -> impl Parser<'a, StrLiteral<'a>, EString<'a>> {
|
|||
// canonicalization error if that expression variant
|
||||
// is not allowed inside a string interpolation.
|
||||
let (_progress, loc_expr, new_state) = skip_second!(
|
||||
specialize_ref(EString::Format, loc(allocated(expr::expr(0)))),
|
||||
specialize_ref(EString::Format, loc(allocated(expr::expr_help(0)))),
|
||||
word1(b')', EString::FormatEnd)
|
||||
)
|
||||
.parse(arena, state)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue