Add comments

This commit is contained in:
Max Brunsfeld 2017-07-14 14:34:49 -07:00
parent a46748839e
commit 5a9bfe1571
4 changed files with 1634 additions and 1424 deletions

12
corpus/programs.txt Normal file
View File

@ -0,0 +1,12 @@
===============================
Comments
===============================
#!/bin/bash
# hi
---
(program
(comment)
(comment))

View File

@ -10,6 +10,11 @@ module.exports = grammar({
$._heredoc_end
],
extras: $ => [
$.comment,
/\s/
],
rules: {
program: $ => repeat($.command),
@ -111,13 +116,15 @@ module.exports = grammar({
file_descriptor: $ => token(prec(1, /\d+/)),
leading_word: $ => /[^\s=|;:{}]+/,
leading_word: $ => /[^\s#=|;:{}]+/,
word: $ => /[^\s$<>{}&]+/,
word: $ => /[^# \s$<>{}&]+/,
control_operator: $ => choice(
'\n',
';;'
)
),
comment: $ => /#.*/,
}
});

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",
@ -453,9 +453,17 @@
"value": ";;"
}
]
},
"comment": {
"type": "PATTERN",
"value": "#.*"
}
},
"extras": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "PATTERN",
"value": "\\s"

File diff suppressed because it is too large Load Diff