parser: skip comments in peek
This commit is contained in:
@@ -70,9 +70,12 @@ impl<'t> Parser<'t> {
|
||||
pub fn peek(&mut self) -> PResult<&Token> {
|
||||
let next_tok = match self.next_tok.take() {
|
||||
Some(tok) => tok,
|
||||
None => match self.lexer.scan() {
|
||||
Ok(tok) => tok,
|
||||
None => loop {
|
||||
match self.lexer.scan() {
|
||||
Ok(Token { kind: TKind::Comment, .. }) => {}
|
||||
Ok(tok) => break tok,
|
||||
Err(e) => Err(ParseError::FromLexer(e))?,
|
||||
}
|
||||
},
|
||||
};
|
||||
self.last_loc = next_tok.span;
|
||||
@@ -286,7 +289,6 @@ fn pat_from_infix(token: &Token) -> Option<(PatPs, PPrec)> {
|
||||
impl<'t> Parse<'t> for Pat {
|
||||
type Prec = PPrec;
|
||||
fn parse(p: &mut Parser<'t>, level: PPrec) -> PResult<Self> {
|
||||
while p.next_if(TKind::Comment).is_ok() {}
|
||||
let tok = p.peek()?;
|
||||
|
||||
// Prefix
|
||||
@@ -813,7 +815,6 @@ impl<'t> Parse<'t> for Expr {
|
||||
/// The `level` parameter indicates the operator binding level of the expression.
|
||||
fn parse(p: &mut Parser<'t>, level: usize) -> PResult<Self> {
|
||||
const MIN: usize = Prec::MIN;
|
||||
while p.next_if(TKind::Comment).is_ok() {}
|
||||
|
||||
// Prefix
|
||||
let tok = p.peek()?;
|
||||
|
||||
Reference in New Issue
Block a user