Properly handle unary operators at beginning of statement.
This commit is contained in:
parent
7c6b444616
commit
231584824a
@ -8,6 +8,7 @@ Bug fixes
|
||||
---------
|
||||
|
||||
* `0.0` now prints correctly (used to print `0e0`).
|
||||
* Unary operators are now properly recognized as an expression statement.
|
||||
|
||||
|
||||
Version 1.1.1
|
||||
|
51
src/token.rs
51
src/token.rs
@ -805,55 +805,56 @@ impl Token {
|
||||
|
||||
match self {
|
||||
LexError(_) |
|
||||
LeftBrace | // {+expr} - is unary
|
||||
SemiColon | // ; - is unary
|
||||
Comma | // ( ... , -expr ) - is unary
|
||||
//Period |
|
||||
LeftBrace | // { -expr } - is unary
|
||||
// RightBrace | { expr } - expr not unary & is closing
|
||||
LeftParen | // ( -expr ) - is unary
|
||||
// RightParen | (expr) - expr not unary & is closing
|
||||
// RightParen | // ( expr ) - expr not unary & is closing
|
||||
LeftBracket | // [ -expr ] - is unary
|
||||
// RightBracket | [expr] - expr not unary & is closing
|
||||
// RightBracket | // [ expr ] - expr not unary & is closing
|
||||
Plus |
|
||||
PlusAssign |
|
||||
UnaryPlus |
|
||||
Minus |
|
||||
MinusAssign |
|
||||
UnaryMinus |
|
||||
Multiply |
|
||||
MultiplyAssign |
|
||||
Divide |
|
||||
Comma |
|
||||
Period |
|
||||
DivideAssign |
|
||||
Modulo |
|
||||
ModuloAssign |
|
||||
PowerOf |
|
||||
PowerOfAssign |
|
||||
LeftShift |
|
||||
LeftShiftAssign |
|
||||
RightShift |
|
||||
RightShiftAssign |
|
||||
Equals |
|
||||
EqualsTo |
|
||||
NotEqualsTo |
|
||||
LessThan |
|
||||
GreaterThan |
|
||||
Bang |
|
||||
LessThanEqualsTo |
|
||||
GreaterThanEqualsTo |
|
||||
EqualsTo |
|
||||
NotEqualsTo |
|
||||
Pipe |
|
||||
Or |
|
||||
Ampersand |
|
||||
And |
|
||||
If |
|
||||
Do |
|
||||
//Do |
|
||||
While |
|
||||
Until |
|
||||
PlusAssign |
|
||||
MinusAssign |
|
||||
MultiplyAssign |
|
||||
DivideAssign |
|
||||
LeftShiftAssign |
|
||||
RightShiftAssign |
|
||||
PowerOf |
|
||||
PowerOfAssign |
|
||||
In |
|
||||
And |
|
||||
AndAssign |
|
||||
Or |
|
||||
OrAssign |
|
||||
XOrAssign |
|
||||
LeftShift |
|
||||
RightShift |
|
||||
XOr |
|
||||
Modulo |
|
||||
ModuloAssign |
|
||||
XOrAssign |
|
||||
Return |
|
||||
Throw |
|
||||
In => true,
|
||||
Throw => true,
|
||||
|
||||
_ => false,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user