From 3bd349debf40ac97806fcb7a6782124e51772c83 Mon Sep 17 00:00:00 2001 From: jiyinyiyong Date: Wed, 21 Apr 2021 20:05:12 +0800 Subject: [PATCH] support single quote in escape; bump 0.0.3 --- package.json | 2 +- src/index.ts | 3 +++ src/parser.test.ts | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 98fc4d5..22e4ad3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cirru/parser.ts", - "version": "0.0.2", + "version": "0.0.3", "description": "Cirru Parser in TypeScript", "main": "lib/index.js", "scripts": { diff --git a/src/index.ts b/src/index.ts index 5373ea1..c1b47ed 100644 --- a/src/index.ts +++ b/src/index.ts @@ -171,6 +171,9 @@ let lex = (initialCode: string) => { case '"': [acc, state, buffer] = [acc, ELexState.string, `${buffer}"`]; break; + case "'": + [acc, state, buffer] = [acc, ELexState.string, `${buffer}'`]; + break; case "t": [acc, state, buffer] = [acc, ELexState.string, `${buffer}\t`]; break; diff --git a/src/parser.test.ts b/src/parser.test.ts index eff9fb1..b0ff926 100644 --- a/src/parser.test.ts +++ b/src/parser.test.ts @@ -2,6 +2,8 @@ let fs = require("fs"); let path = require("path"); let { parse } = require("./index"); +test("single quote", () => expect(parse('a "\\\'"')).toEqual([["a", "'"]])); + test("demo", () => { let code = fs.readFileSync(path.join(__dirname, "../test/cirru/demo.cirru"), "utf8"); let data = require(path.join(__dirname, "../test/ast/demo.json"));