Fix bracket subscript parsing
This commit is contained in:
parent
d1e04b8bbd
commit
d50122540b
|
@ -331,7 +331,7 @@ fn parse_expression<'a>(
|
||||||
let tuple = parse_tuple_expr(m, full_expr.clone());
|
let tuple = parse_tuple_expr(m, full_expr.clone());
|
||||||
|
|
||||||
let base = choice((parse_literal(m), parse_var_ref_expr(m)));
|
let base = choice((parse_literal(m), parse_var_ref_expr(m)));
|
||||||
let subscript = parse_subscript_expr(m, base);
|
let subscript = parse_subscript_expr(m, base, full_expr.clone());
|
||||||
let term = choice((lambda, let_, match_, record, subscript, tuple));
|
let term = choice((lambda, let_, match_, record, subscript, tuple));
|
||||||
|
|
||||||
let application = term.repeated().at_least(1).map(|exprs| {
|
let application = term.repeated().at_least(1).map(|exprs| {
|
||||||
|
@ -518,6 +518,7 @@ fn parse_lambda_expr(
|
||||||
fn parse_subscript_expr(
|
fn parse_subscript_expr(
|
||||||
_m: &ParserMeta,
|
_m: &ParserMeta,
|
||||||
base: impl Parser<char, Expr, Error = Simple<char>> + Clone,
|
base: impl Parser<char, Expr, Error = Simple<char>> + Clone,
|
||||||
|
rec: impl Parser<char, Expr, Error = Simple<char>> + Clone,
|
||||||
) -> impl Parser<char, Expr, Error = Simple<char>> + Clone {
|
) -> impl Parser<char, Expr, Error = Simple<char>> + Clone {
|
||||||
enum SubscriptKind {
|
enum SubscriptKind {
|
||||||
Dot,
|
Dot,
|
||||||
|
@ -530,7 +531,7 @@ fn parse_subscript_expr(
|
||||||
pad(just('.'))
|
pad(just('.'))
|
||||||
.ignore_then(base.clone())
|
.ignore_then(base.clone())
|
||||||
.map(|e| (SubscriptKind::Dot, e)),
|
.map(|e| (SubscriptKind::Dot, e)),
|
||||||
base.clone()
|
rec.clone()
|
||||||
.delimited_by(pad(just('[')), pad(just(']')))
|
.delimited_by(pad(just('[')), pad(just(']')))
|
||||||
.map(|e| (SubscriptKind::Bracket, e)),
|
.map(|e| (SubscriptKind::Bracket, e)),
|
||||||
))
|
))
|
||||||
|
|
Loading…
Reference in a new issue