Merge pull request #398 from schungx/master

Finalize 0.20.0.
This commit is contained in:
Stephen Chung 2021-04-16 22:25:29 +08:00 committed by GitHub
commit b54d44c670
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 12 deletions

View File

@ -1,11 +1,17 @@
Rhai Release Notes Rhai Release Notes
================== ==================
Version 0.19.16 Version 0.20.1
=============== ==============
Version 0.20.0
==============
This version adds string interpolation with `` `... ${`` ... ``} ...` `` syntax. This version adds string interpolation with `` `... ${`` ... ``} ...` `` syntax.
`switch` statement cases can now have conditions.
Negative indices for arrays and strings are allowed and now count from the end (-1 = last item/character). Negative indices for arrays and strings are allowed and now count from the end (-1 = last item/character).
Bug fixes Bug fixes

View File

@ -3,7 +3,7 @@ members = [".", "codegen"]
[package] [package]
name = "rhai" name = "rhai"
version = "0.19.16" version = "0.20.1"
edition = "2018" edition = "2018"
authors = ["Jonathan Turner", "Lukáš Hozda", "Stephen Chung", "jhwgh1968"] authors = ["Jonathan Turner", "Lukáš Hozda", "Stephen Chung", "jhwgh1968"]
description = "Embedded scripting for Rust" description = "Embedded scripting for Rust"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "rhai_codegen" name = "rhai_codegen"
version = "0.3.4" version = "0.3.5"
edition = "2018" edition = "2018"
authors = ["jhwgh1968"] authors = ["jhwgh1968"]
description = "Procedural macro support package for Rhai, a scripting language for Rust" description = "Procedural macro support package for Rhai, a scripting language for Rust"
@ -16,7 +16,7 @@ default = []
metadata = [] metadata = []
[dev-dependencies] [dev-dependencies]
rhai = { path = "..", version = "0.19" } rhai = { path = "..", version = ">=0.19.15" }
trybuild = "1" trybuild = "1"
[dependencies] [dependencies]

View File

@ -1328,7 +1328,7 @@ fn parse_unary(
match parse_unary(input, state, lib, settings.level_up())? { match parse_unary(input, state, lib, settings.level_up())? {
// Negative integer // Negative integer
Expr::IntegerConstant(num, pos) => num Expr::IntegerConstant(num, _) => num
.checked_neg() .checked_neg()
.map(|i| Expr::IntegerConstant(i, pos)) .map(|i| Expr::IntegerConstant(i, pos))
.or_else(|| { .or_else(|| {
@ -1341,7 +1341,7 @@ fn parse_unary(
// Negative float // Negative float
#[cfg(not(feature = "no_float"))] #[cfg(not(feature = "no_float"))]
Expr::FloatConstant(x, pos) => Ok(Expr::FloatConstant((-(*x)).into(), pos)), Expr::FloatConstant(x, _) => Ok(Expr::FloatConstant((-(*x)).into(), pos)),
// Call negative function // Call negative function
expr => { expr => {

View File

@ -1240,7 +1240,7 @@ fn get_next_token_inner(
); );
} }
let mut negated = false; let mut negated_pos = Position::NONE;
while let Some(c) = stream.get_next() { while let Some(c) = stream.get_next() {
pos.advance(); pos.advance();
@ -1349,9 +1349,12 @@ fn get_next_token_inner(
} }
} }
if negated { let num_pos = if !negated_pos.is_none() {
result.insert(0, '-'); result.insert(0, '-');
} negated_pos
} else {
start_pos
};
// Parse number // Parse number
return Some(( return Some((
@ -1388,7 +1391,7 @@ fn get_next_token_inner(
Token::LexError(LERR::MalformedNumber(result.into_iter().collect())) Token::LexError(LERR::MalformedNumber(result.into_iter().collect()))
}) })
}, },
start_pos, num_pos,
)); ));
} }
@ -1507,7 +1510,7 @@ fn get_next_token_inner(
('+', _) 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)),
('-', '0'..='9') if !state.non_unary => negated = true, ('-', '0'..='9') if !state.non_unary => negated_pos = start_pos,
('-', '0'..='9') => return Some((Token::Minus, start_pos)), ('-', '0'..='9') => return Some((Token::Minus, start_pos)),
('-', '=') => { ('-', '=') => {
eat_next(stream, pos); eat_next(stream, pos);