Skip to content

Commit 2a0567a

Browse files
authored
fix single line comment bug (#171)
* fix single line comment bug * version 0.1.1
1 parent 87f822d commit 2a0567a

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## Unreleased
9+
10+
## 0.1.1
11+
12+
- fix single line comment bug PR [#171](https://github.com/functionalscript/nanvm/pull/171)

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ members = ["nanvm-lib", "nanvm"]
33
resolver = "2"
44

55
[workspace.package]
6-
version = "0.1.0"
6+
version = "0.1.1"
77
edition = "2021"
88
authors = ["Sergey Shandar", "Denys Shandar"]
99
license = "GPL-3.0-or-later"
1010
repository = "https://github.com/functionalscript/nanvm"
1111

1212
[workspace.dependencies]
13-
nanvm-lib = { path = "nanvm-lib", version = "0.1.0" }
14-
wasm-bindgen-test = "0.3.42"
13+
nanvm-lib = { path = "nanvm-lib", version = "0.1.1" }
14+
wasm-bindgen-test = "0.3.49"
1515
io-trait = "0.11.0"
1616
io-test = "0.11.0"
1717
io-impl = "0.11.0"

nanvm-lib/src/tokenizer/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ fn operator_to_token<D: Dealloc>(s: String) -> Option<JsonToken<D>> {
361361
}
362362

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

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

1528+
let result = tokenize(GLOBAL, String::from("0//abc 1"));
1529+
assert_eq!(&result, &[JsonToken::Number(0.0)]);
1530+
1531+
let result = tokenize(GLOBAL, String::from("0//abc\n1"));
1532+
assert_eq!(
1533+
&result,
1534+
&[
1535+
JsonToken::Number(0.0),
1536+
JsonToken::NewLine,
1537+
JsonToken::Number(1.0)
1538+
]
1539+
);
1540+
15271541
let result = tokenize(GLOBAL, String::from("0//"));
15281542
assert_eq!(&result, &[JsonToken::Number(0.0),]);
15291543

0 commit comments

Comments
 (0)