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 $._heredoc_end
], ],
extras: $ => [
$.comment,
/\s/
],
rules: { rules: {
program: $ => repeat($.command), program: $ => repeat($.command),
@ -111,13 +116,15 @@ 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',
';;' ';;'
) ),
comment: $ => /#.*/,
} }
}); });

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

File diff suppressed because it is too large Load Diff