parser: allow any token to be a metaidentifier
This commit is contained in:
parent
7b05da1334
commit
b1619f6e4e
@ -232,7 +232,7 @@ impl<'t> Parse<'t> for Pat {
|
|||||||
"_" => p.consume().then(Pat::Ignore),
|
"_" => p.consume().then(Pat::Ignore),
|
||||||
_ => Pat::Name(p.take_lexeme().expect("should have Token")),
|
_ => Pat::Name(p.take_lexeme().expect("should have Token")),
|
||||||
},
|
},
|
||||||
TKind::Grave => Pat::MetId(p.consume().next_if(TKind::Identifier)?.lexeme),
|
TKind::Grave => Pat::MetId(p.consume().next()?.lexeme),
|
||||||
TKind::DotDot => Pat::Rest(match p.consume().peek_if(TKind::Identifier) {
|
TKind::DotDot => Pat::Rest(match p.consume().peek_if(TKind::Identifier) {
|
||||||
Some(_) => Some(p.parse(level)?),
|
Some(_) => Some(p.parse(level)?),
|
||||||
None => None,
|
None => None,
|
||||||
@ -518,7 +518,7 @@ impl<'t> Parse<'t> for Expr {
|
|||||||
Ps::End => Err(ParseError::NotPrefix(tok.kind, span))?,
|
Ps::End => Err(ParseError::NotPrefix(tok.kind, span))?,
|
||||||
|
|
||||||
Ps::Id => Expr::Id(p.take_lexeme().expect("should have ident")),
|
Ps::Id => Expr::Id(p.take_lexeme().expect("should have ident")),
|
||||||
Ps::Mid => Expr::MetId(p.consume().next_if(TKind::Identifier)?.lexeme),
|
Ps::Mid => Expr::MetId(p.consume().next()?.lexeme),
|
||||||
Ps::Lit => Expr::Lit(p.parse(())?),
|
Ps::Lit => Expr::Lit(p.parse(())?),
|
||||||
Ps::Let => Expr::Let(
|
Ps::Let => Expr::Let(
|
||||||
p.consume().parse(PPrec::Alt)?,
|
p.consume().parse(PPrec::Alt)?,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user