Reserve some more symbols.
This commit is contained in:
parent
994e5a4251
commit
9d93dac8e7
@ -15,6 +15,7 @@ Breaking changes
|
|||||||
* The following `EvalAltResult` variants are removed and merged into `EvalAltResult::ErrorMismatchDataType`: `ErrorCharMismatch`, `ErrorNumericIndexExpr`, `ErrorStringIndexExpr`, `ErrorImportExpr`, `ErrorLogicGuard`, `ErrorBooleanArgMismatch`
|
* The following `EvalAltResult` variants are removed and merged into `EvalAltResult::ErrorMismatchDataType`: `ErrorCharMismatch`, `ErrorNumericIndexExpr`, `ErrorStringIndexExpr`, `ErrorImportExpr`, `ErrorLogicGuard`, `ErrorBooleanArgMismatch`
|
||||||
* `Scope::iter_raw` returns an iterator with an additional field indicating whether the variable is constant or not.
|
* `Scope::iter_raw` returns an iterator with an additional field indicating whether the variable is constant or not.
|
||||||
* `rhai::ser` and `rhai::de` namespaces are merged into `rhai::serde`.
|
* `rhai::ser` and `rhai::de` namespaces are merged into `rhai::serde`.
|
||||||
|
* New reserved symbols: `++`, `--`, `..`, `...`.
|
||||||
|
|
||||||
New features
|
New features
|
||||||
------------
|
------------
|
||||||
|
@ -56,6 +56,10 @@ Symbols and Patterns
|
|||||||
| `/*` .. `*/` | comment | block comment |
|
| `/*` .. `*/` | comment | block comment |
|
||||||
| `(*` .. `*)` | comment | _reserved_ |
|
| `(*` .. `*)` | comment | _reserved_ |
|
||||||
| `<` .. `>` | angular brackets | _reserved_ |
|
| `<` .. `>` | angular brackets | _reserved_ |
|
||||||
|
| `++` | increment | _reserved_ |
|
||||||
|
| `--` | decrement | _reserved_ |
|
||||||
|
| `..` | range | _reserved_ |
|
||||||
|
| `...` | range | _reserved_ |
|
||||||
| `#` | hash | _reserved_ |
|
| `#` | hash | _reserved_ |
|
||||||
| `@` | at | _reserved_ |
|
| `@` | at | _reserved_ |
|
||||||
| `$` | dollar | _reserved_ |
|
| `$` | dollar | _reserved_ |
|
||||||
|
20
src/token.rs
20
src/token.rs
@ -1205,6 +1205,10 @@ fn get_next_token_inner(
|
|||||||
eat_next(stream, pos);
|
eat_next(stream, pos);
|
||||||
return Some((Token::PlusAssign, start_pos));
|
return Some((Token::PlusAssign, start_pos));
|
||||||
}
|
}
|
||||||
|
('+', '+') => {
|
||||||
|
eat_next(stream, pos);
|
||||||
|
return Some((Token::Reserved("++".into()), start_pos));
|
||||||
|
}
|
||||||
('+', _) if !state.non_unary => return Some((Token::UnaryPlus, start_pos)),
|
('+', _) if !state.non_unary => return Some((Token::UnaryPlus, start_pos)),
|
||||||
('+', _) => return Some((Token::Plus, start_pos)),
|
('+', _) => return Some((Token::Plus, start_pos)),
|
||||||
|
|
||||||
@ -1218,6 +1222,10 @@ fn get_next_token_inner(
|
|||||||
eat_next(stream, pos);
|
eat_next(stream, pos);
|
||||||
return Some((Token::Reserved("->".into()), start_pos));
|
return Some((Token::Reserved("->".into()), start_pos));
|
||||||
}
|
}
|
||||||
|
('-', '-') => {
|
||||||
|
eat_next(stream, pos);
|
||||||
|
return Some((Token::Reserved("--".into()), start_pos));
|
||||||
|
}
|
||||||
('-', _) if !state.non_unary => return Some((Token::UnaryMinus, start_pos)),
|
('-', _) if !state.non_unary => return Some((Token::UnaryMinus, start_pos)),
|
||||||
('-', _) => return Some((Token::Minus, start_pos)),
|
('-', _) => return Some((Token::Minus, start_pos)),
|
||||||
|
|
||||||
@ -1282,12 +1290,22 @@ fn get_next_token_inner(
|
|||||||
|
|
||||||
(';', _) => return Some((Token::SemiColon, start_pos)),
|
(';', _) => return Some((Token::SemiColon, start_pos)),
|
||||||
(',', _) => return Some((Token::Comma, start_pos)),
|
(',', _) => return Some((Token::Comma, start_pos)),
|
||||||
|
|
||||||
|
('.', '.') => {
|
||||||
|
eat_next(stream, pos);
|
||||||
|
|
||||||
|
if stream.peek_next() == Some('.') {
|
||||||
|
eat_next(stream, pos);
|
||||||
|
return Some((Token::Reserved("...".into()), start_pos));
|
||||||
|
} else {
|
||||||
|
return Some((Token::Reserved("..".into()), start_pos));
|
||||||
|
}
|
||||||
|
}
|
||||||
('.', _) => return Some((Token::Period, start_pos)),
|
('.', _) => return Some((Token::Period, start_pos)),
|
||||||
|
|
||||||
('=', '=') => {
|
('=', '=') => {
|
||||||
eat_next(stream, pos);
|
eat_next(stream, pos);
|
||||||
|
|
||||||
// Warn against `===`
|
|
||||||
if stream.peek_next() == Some('=') {
|
if stream.peek_next() == Some('=') {
|
||||||
eat_next(stream, pos);
|
eat_next(stream, pos);
|
||||||
return Some((Token::Reserved("===".into()), start_pos));
|
return Some((Token::Reserved("===".into()), start_pos));
|
||||||
|
Loading…
Reference in New Issue
Block a user