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

View File

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

File diff suppressed because it is too large Load Diff