Skip to content

Commit

Permalink
Merge pull request #20 from vrischmann/empty-script
Browse files Browse the repository at this point in the history
Fix empty script block parsing
  • Loading branch information
vrischmann authored Jan 1, 2024
2 parents 14d1057 + aef2c35 commit f5c56b4
Show file tree
Hide file tree
Showing 5 changed files with 26,101 additions and 26,044 deletions.
18 changes: 18 additions & 0 deletions corpus/script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,21 @@ templ Foobar() {
value: (quoted_attribute_value
(attribute_value)))
(script_element_text)))))

===
Empty script
===

package main

script noScript() {}

---

(source_file
(package_clause
(package_identifier))
(script_declaration
(script_identifier)
(parameter_list)
(script_block)))
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ module.exports = grammar(GO, {
),
script_block: $ => seq(
'{',
$.script_block_text,
optional($.script_block_text),
'}',
),

Expand Down
12 changes: 10 additions & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -7939,8 +7939,16 @@
"value": "{"
},
{
"type": "SYMBOL",
"name": "script_block_text"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "script_block_text"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
Expand Down
2 changes: 1 addition & 1 deletion src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2616,7 +2616,7 @@
"fields": {},
"children": {
"multiple": false,
"required": true,
"required": false,
"types": [
{
"type": "script_block_text",
Expand Down
Loading

0 comments on commit f5c56b4

Please sign in to comment.