Cart grammar: tolerate leading blank lines before the magic header
`extras: $ => []` in the cart grammar made the parser fail at byte 0 on any whitespace-only or empty line before `pico-8 cartridge //...`. Real PICO-8 carts always start with the header at byte 0 so this rarely surfaced in production, but it ( a ) broke the `tree-sitter test` corpus harness, which prepends a newline to each fixture, and ( b ) would mis-flag a hand-edited cart that gained an accidental blank line up top. Fix: prefix the `cartridge` rule with `repeat($._blank_line)` and add a hidden `_blank_line` token matching `[ \t]*\n`. Junk content before the header ( a non-blank, non-magic line ) still produces an ERROR. Restores the test corpus that was dropped in v0.1 ( previously failing on this same edge case ) and adds a fixture for the unknown_section fallback while the corpus is being rebuilt. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,13 @@
|
||||
"cartridge": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_blank_line"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
@@ -38,6 +45,13 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"_blank_line": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[ \\t]*\\n"
|
||||
}
|
||||
},
|
||||
"header": {
|
||||
"type": "PATTERN",
|
||||
"value": "pico-8 cartridge \\/\\/[^\\n]*\\n"
|
||||
|
||||
+1042
-889
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user