Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## 0.1.1

- fix single line comment bug PR [#171](https://github.com/functionalscript/nanvm/pull/171)
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ members = ["nanvm-lib", "nanvm"]
resolver = "2"

[workspace.package]
version = "0.1.0"
version = "0.1.1"
edition = "2021"
authors = ["Sergey Shandar", "Denys Shandar"]
license = "GPL-3.0-or-later"
repository = "https://github.com/functionalscript/nanvm"

[workspace.dependencies]
nanvm-lib = { path = "nanvm-lib", version = "0.1.0" }
wasm-bindgen-test = "0.3.42"
nanvm-lib = { path = "nanvm-lib", version = "0.1.1" }
wasm-bindgen-test = "0.3.49"
io-trait = "0.11.0"
io-test = "0.11.0"
io-impl = "0.11.0"
16 changes: 15 additions & 1 deletion nanvm-lib/src/tokenizer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ fn operator_to_token<D: Dealloc>(s: String) -> Option<JsonToken<D>> {
}

const WHITE_SPACE_CHARS: [char; 4] = [' ', '\n', '\t', '\r'];
const NEW_LINE_CHARS: [char; 2] = ['\n', '\r'];
const OPERATOR_CHARS: [char; 10] = ['{', '}', '[', ']', ':', ',', '=', ';', '(', ')'];

fn id_start() -> Vec<RangeInclusive<char>> {
Expand Down Expand Up @@ -961,7 +962,7 @@ fn create_singleline_comment_transactions<M: Manager>() -> TransitionMap<(), M>
type Func<M> = TransitionFunc<M, ()>;
TransitionMap {
def: (|_, _, _, _| (default(), TokenizerState::ParseSinglelineComment)) as Func<M>,
rm: create_range_map(set(WHITE_SPACE_CHARS), |_, _, _, _| {
rm: create_range_map(set(NEW_LINE_CHARS), |_, _, _, _| {
(default(), TokenizerState::ParseNewLine)
}),
}
Expand Down Expand Up @@ -1524,6 +1525,19 @@ mod test {
let result = tokenize(GLOBAL, String::from("0//abc/*"));
assert_eq!(&result, &[JsonToken::Number(0.0),]);

let result = tokenize(GLOBAL, String::from("0//abc 1"));
assert_eq!(&result, &[JsonToken::Number(0.0)]);

let result = tokenize(GLOBAL, String::from("0//abc\n1"));
assert_eq!(
&result,
&[
JsonToken::Number(0.0),
JsonToken::NewLine,
JsonToken::Number(1.0)
]
);

let result = tokenize(GLOBAL, String::from("0//"));
assert_eq!(&result, &[JsonToken::Number(0.0),]);

Expand Down
Loading