diff --git a/server/src/parser/tokens.ts b/server/src/parser/tokens.ts index 9a83b887..7774cef2 100644 --- a/server/src/parser/tokens.ts +++ b/server/src/parser/tokens.ts @@ -23,13 +23,13 @@ import { export const BlockComment = createToken({ name: "BlockComment", - pattern: /(?<=\r?\n)\/(?:[ \t]*\r?\n)[^\\]*\\?/, // TODO + pattern: /(?<=(\r?\n|[ \t]*))\/(?:[ \t]*\r?\n)[^\\]*\\?/, group: Lexer.SKIPPED, }); export const LineComment = createToken({ name: "LineComment", - pattern: /(?<=\r?\n|[ \t])\/.*/, // TODO + pattern: /(?:(?<=\r?\n|[ \t])|(? { + describe("comments", () => { + it("should ignore block", () => { + QParser.parse("/\na:\n1\n\\"); + assert.deepEqual(QParser.errors, []); + }); + + it("should ignore line", () => { + QParser.parse("/a:\n"); + assert.deepEqual(QParser.errors, []); + }); + + it("should ignore inline", () => { + QParser.parse("a: 1 /a:\n"); + assert.deepEqual(QParser.errors, []); + }); + + it("should not ignore overloaded slash", () => { + QParser.parse("a: ,/ a:\n"); + assert.strictEqual(QParser.errors.length, 1); + }); + }); + describe("script", () => { it("should parse empty", () => { QParser.parse("");