mirror of
https://github.com/danog/parser.git
synced 2024-11-30 04:29:13 +01:00
lexer: produce correct token for single !
This commit is contained in:
parent
c372b9e9bd
commit
e21b6a40ef
@ -187,7 +187,7 @@ impl Lexer {
|
|||||||
}
|
}
|
||||||
[b'!', ..] => {
|
[b'!', ..] => {
|
||||||
self.next();
|
self.next();
|
||||||
TokenKind::BangEquals
|
TokenKind::Bang
|
||||||
}
|
}
|
||||||
[b'&', b'&', ..] => {
|
[b'&', b'&', ..] => {
|
||||||
self.skip(2);
|
self.skip(2);
|
||||||
|
@ -210,6 +210,7 @@ impl Default for Token {
|
|||||||
impl Display for TokenKind {
|
impl Display for TokenKind {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
let s = match self {
|
let s = match self {
|
||||||
|
Self::BangEquals => "!=",
|
||||||
Self::From => "from",
|
Self::From => "from",
|
||||||
Self::Print => "print",
|
Self::Print => "print",
|
||||||
Self::BitwiseNot => "~",
|
Self::BitwiseNot => "~",
|
||||||
|
@ -2203,12 +2203,7 @@ impl Parser {
|
|||||||
prefix(&op, rhs)
|
prefix(&op, rhs)
|
||||||
}
|
}
|
||||||
TokenKind::Dollar => self.dynamic_variable()?,
|
TokenKind::Dollar => self.dynamic_variable()?,
|
||||||
_ => todo!(
|
_ => return Err(ParseError::UnexpectedToken(self.current.kind.to_string(), self.current.span)),
|
||||||
"expr lhs: {:?}, line {} col {}",
|
|
||||||
self.current.kind,
|
|
||||||
self.current.span.0,
|
|
||||||
self.current.span.1
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.current.kind == TokenKind::SemiColon {
|
if self.current.kind == TokenKind::SemiColon {
|
||||||
|
Loading…
Reference in New Issue
Block a user