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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# 未リリース分
- `Date:year`系の関数に0を渡すと現在時刻になる問題を修正
- シンタックスエラーなどの位置情報を修正

# 0.18.0
- `Core:abort`でプログラムを緊急停止できるように
Expand Down Expand Up @@ -128,4 +129,4 @@
- 空の関数を定義できない問題を修正
- 空のスクリプトが許可されていない問題を修正
- ネームスペース付き変数のインクリメント、デクリメントを修正
- ネームスペース付き変数への代入ができない問題を修正
- ネームスペース付き変数への代入ができない問題を修正
5 changes: 2 additions & 3 deletions src/parser/parser.peggy
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ PreprocessPart
/ .

Comment
= "//" (!EOL .)* { return ''; }
/ "/*" (!"*/" .)* "*/" { return ''; }

= "//" (!EOL .)* { return ' '.repeat(text().length); }
/ "/*" (!"*/" .)* "*/" { return text().replace(/[^\n]/g, ' '); }

//
// main parser
Expand Down
14 changes: 14 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2399,6 +2399,20 @@ describe('Location', () => {
if (!node.loc) assert.fail();
assert.deepEqual(node.loc, { start: 3, end: 13 });
});
test.concurrent('comment', async () => {
let node: Ast.Node;
const parser = new Parser();
const nodes = parser.parse(`
/*
*/
// hoge
@f(a) { a }
`);
assert.equal(nodes.length, 1);
node = nodes[0];
if (!node.loc) assert.fail();
assert.deepEqual(node.loc, { start: 23, end: 33 });
});
});

describe('Variable declaration', () => {
Expand Down