Handle escape sequences in strings (#7)

This should fix #6
This commit is contained in:
Mads Hartmann 2018-02-28 21:15:05 +01:00 committed by Max Brunsfeld
parent 675a581839
commit c410548caf
4 changed files with 15383 additions and 15340 deletions

View File

@ -160,6 +160,16 @@ find "`dirname $file`" -name "$base"'*'
(string (simple_expansion (variable_name))) (string (simple_expansion (variable_name)))
(raw_string)))) (raw_string))))
=========================================
Strings containing escape sequence
=========================================
echo "\"The great escape\`\${var}"
---
(program (command (command_name (word)) (string)))
========================================= =========================================
Variable declaration: declare & typeset Variable declaration: declare & typeset
========================================= =========================================

View File

@ -269,7 +269,7 @@ module.exports = grammar({
'"' '"'
), ),
_string_content: $ => /[^"`$]+/, _string_content: $ => /([^"`$]|\\.)*/,
array: $ => seq( array: $ => seq(
'(', '(',

2
src/grammar.json vendored
View File

@ -976,7 +976,7 @@
}, },
"_string_content": { "_string_content": {
"type": "PATTERN", "type": "PATTERN",
"value": "[^\"`$]+" "value": "([^\"`$]|\\\\.)*"
}, },
"array": { "array": {
"type": "SEQ", "type": "SEQ",

30709
src/parser.c vendored

File diff suppressed because it is too large Load Diff