Commit Graph

7 Commits

Author SHA1 Message Date
kistaro 446a7972a4 Repin grammar revs to the leading-blanks fix commit
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 12:57:06 -07:00
kistaro 7557a34c89 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>
2026-05-01 12:56:59 -07:00
kistaro 445aac4e30 Pin grammar revs to v0.2 commit
Both [grammars.*] blocks now reference the v0.2 SHA, so a fresh
`zed: install dev extension` clones each grammar from the right
revision via its `path` subdirectory.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 12:54:15 -07:00
kistaro 39d77a8cae v0.2: Pico-8 Lua dialect grammar and language
Reorganize into grammars/<name>/ subdirs ( Zed's [grammars.*] supports
a `path` field, so both grammars ship from this repo without a sibling-
repo split ). Vendor tree-sitter-lua as the fork base for tree-sitter-
pico8-lua; upstream MIT license preserved at grammars/pico-8-lua/
UPSTREAM-LICENSE.md.

Dialect features added: != as ~= alias, \ integer divide, ^^ binary xor,
>>> / <<> / >>< shifts and rotates, compound-assignment statements,
memory peek prefixes @ % $ (% coexists with binary modulo), single-line
`if (cond) stmt [else stmt]` and `while (cond) stmt`, statement-level
print shorthand ?, and `#include path` directives. Identifier rule no
longer accepts ! ? @ $ ( upstream did ).

Pico-8 Lua language ( languages/pico-8-lua/, suffix .p8lua ) ships
highlights with the full ~110 PICO-8 builtins as @function.builtin.
The cart injection now hands __lua__ bodies to pico-8-lua, so .p8 carts
and bare .p8lua files share the dialect-aware grammar. Examples updated
to exercise the dialect end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 12:50:41 -07:00
kistaro 04a92fc16e Pin grammar rev to scaffold commit
Zed's [grammars.*] block requires a real Git SHA — "HEAD" does not
resolve. Lock to 3f209ef so a fresh `zed: install dev extension` can
clone the grammar.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 11:51:08 -07:00
kistaro 3f209efa89 Add v0.1 scaffold: tree-sitter-p8-cart grammar and Zed extension
The grammar parses the .p8 cartridge container ( header, version, and
the named __lua__/__gfx__/__gff__/__label__/__map__/__sfx__/__music__
sections, plus a fallback unknown_section ). The Zed language definition
hands the __lua__ body to Zed's built-in Lua via injections.scm, so
non-dialect Lua code highlights correctly today; PICO-8-specific syntax
(?, +=, !=, single-line if, etc.) will fall back to error highlighting
in those regions only — see README roadmap for the dialect grammar fork.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 11:50:47 -07:00
kistaro b4191384e0 Initial commit 2026-05-01 18:18:20 +00:00