For expr + whitespace
This commit is contained in:
parent
b6a60a05ba
commit
efda75860c
@ -168,6 +168,7 @@ fn for_expr(text: &str) -> ParseResult<ExpressionKind> {
|
|||||||
))(text)
|
))(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn enumerators(text: &str) -> ParseResult<Vec<Enumerator>> {
|
fn enumerators(text: &str) -> ParseResult<Vec<Enumerator>> {
|
||||||
separated_nonempty_list(alt((value((), tag(",")), statement_sep)),
|
separated_nonempty_list(alt((value((), tag(",")), statement_sep)),
|
||||||
enumerator)(text)
|
enumerator)(text)
|
||||||
@ -181,7 +182,10 @@ fn enumerator(text: &str) -> ParseResult<Enumerator> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn for_expr_body(text: &str) -> ParseResult<ForBody> {
|
fn for_expr_body(text: &str) -> ParseResult<ForBody> {
|
||||||
unimplemented!()
|
alt((
|
||||||
|
map(preceded(tag("return"), expression), ForBody::MonadicReturn),
|
||||||
|
map(delimited(tag("{"), block, tag("}")), ForBody::StatementBlock),
|
||||||
|
))(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn invocation_argument(text: &str) -> ParseResult<InvocationArgument> {
|
fn invocation_argument(text: &str) -> ParseResult<InvocationArgument> {
|
||||||
@ -386,7 +390,7 @@ fn precedence_expr(text: &str) -> ParseResult<ExpressionKind> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn expression_kind(text: &str) -> ParseResult<ExpressionKind> {
|
fn expression_kind(text: &str) -> ParseResult<ExpressionKind> {
|
||||||
context("Expression kind", precedence_expr)(text)
|
context("Expression kind", ws(precedence_expr))(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn type_anno(text: &str) -> ParseResult<TypeIdentifier> {
|
fn type_anno(text: &str) -> ParseResult<TypeIdentifier> {
|
||||||
@ -402,7 +406,7 @@ fn type_name(text: &str) -> ParseResult<TypeIdentifier> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn expression(text: &str) -> ParseResult<Expression> {
|
fn expression(text: &str) -> ParseResult<Expression> {
|
||||||
let (rest, (kind, type_anno)) = pair(expression_kind, opt(type_anno))(text)?;
|
let (rest, (kind, type_anno)) = ws(pair(expression_kind, opt(type_anno)))(text)?;
|
||||||
let expr = Expression { id: ItemId::new(0), kind, type_anno };
|
let expr = Expression { id: ItemId::new(0), kind, type_anno };
|
||||||
Ok((rest, expr))
|
Ok((rest, expr))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user