Add escaped newlines

This commit is contained in:
Max Brunsfeld 2017-07-14 14:39:28 -07:00
parent 5a9bfe1571
commit d68e65d8f9
4 changed files with 1554 additions and 1436 deletions

View File

@ -10,3 +10,33 @@ Comments
(program
(comment)
(comment))
===============================
Escaped newlines
===============================
abc \
d \
e
f=g \
h=i \
j \
--k
---
(program
(command (simple_command
(command_name)
(argument)
(argument)))
(command (simple_command
(environment_variable_assignment
(variable_name)
(argument))
(environment_variable_assignment
(variable_name)
(argument))
(command_name)
(argument))))

View File

@ -12,7 +12,7 @@ module.exports = grammar({
extras: $ => [
$.comment,
/\s/
token(choice(/\s/, '\\\n')),
],
rules: {
@ -116,9 +116,9 @@ module.exports = grammar({
file_descriptor: $ => token(prec(1, /\d+/)),
leading_word: $ => /[^\s#=|;:{}]+/,
leading_word: $ => /[^\\\s#=|;:{}]+/,
word: $ => /[^# \s$<>{}&]+/,
word: $ => /[^#\\\s$<>{}&]+/,
control_operator: $ => choice(
'\n',

View File

@ -435,11 +435,11 @@
},
"leading_word": {
"type": "PATTERN",
"value": "[^\\s#=|;:{}]+"
"value": "[^\\\\\\s#=|;:{}]+"
},
"word": {
"type": "PATTERN",
"value": "[^# \\s$<>{}&]+"
"value": "[^#\\\\\\s$<>{}&]+"
},
"control_operator": {
"type": "CHOICE",
@ -465,8 +465,20 @@
"name": "comment"
},
{
"type": "PATTERN",
"value": "\\s"
"type": "TOKEN",
"content": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "\\s"
},
{
"type": "STRING",
"value": "\\\n"
}
]
}
}
],
"conflicts": [],

File diff suppressed because it is too large Load Diff