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,],];