From e5e53a82653bf8e9890c86f18832ee4406795e35 Mon Sep 17 00:00:00 2001 From: Mikhail Katychev Date: Sun, 4 Aug 2024 20:30:37 -0500 Subject: [PATCH] added to test --- grammar.js | 2 +- src/grammar.json | 4 ++++ test/corpus/literals.txt | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/grammar.js b/grammar.js index 2104a48..afea8d2 100644 --- a/grammar.js +++ b/grammar.js @@ -377,7 +377,7 @@ module.exports = grammar({ special_variable: $ => seq('$', $.identifier), _variable_name: $ => choice($.identifier, $.special_variable), - string: _ => token(seq('"', repeat(choice(/[^"]/, '\\"')), '"')), + string: _ => token(seq('"', repeat(choice(/[^"]/, '\\"', "\\\\")), '"')), number: $ => choice($.decimal, $.float), decimal: _ => token(/-?\d+/), float: _ => token(/-?(\d+(\.\d+)?|\.\d+)(e-?\d+)?/), diff --git a/src/grammar.json b/src/grammar.json index daba493..91fcce6 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -2015,6 +2015,10 @@ { "type": "STRING", "value": "\\\"" + }, + { + "type": "STRING", + "value": "\\\\" } ] } diff --git a/test/corpus/literals.txt b/test/corpus/literals.txt index 6a62363..a3f3166 100644 --- a/test/corpus/literals.txt +++ b/test/corpus/literals.txt @@ -2,8 +2,8 @@ All Literals ================================================================================ num = -4.3; -escape = "\\"; name = "Karl"; +esc = "\\"; boolean = true; list = [1, 2, each [3, 4], [5, 6]]; trailing_comma_list = [[1, 2,],];