Tree-sitter grammar for the current Peeper language revision.
This grammar targets the new Peeper syntax in this repo, not the older Peeper compiler syntax.
- imports
- top-level
let/const struct,interface, and payload-awareenumdeclarationsimpl T { ... }- plain function declarations
- generic type/function syntax with
<T> let/let mutif/else- fully named
Enum::Variant with expressionconstruction andiscase tests - statement
matchwith whole-payload bindings or struct field patterns *Towned pointer types,rawptr, and?Toptionals- array literals and indexing
- postfix
++/-- - named struct literals:
Point.{ x = 1, y = 2 },Box<i32>.{ value = 1 },geometry::Point.{ x = 1 } - inferred struct literals:
.{ x = 1, y = 2 } - field access and method calls
comptimeparameters and prefix expressions- structural
struct/interface/enumtype expressions !!,??,catch
Use Type.{ field = value }, not .Type{ field = value }. The old named spelling is rejected; inferred .{ ... } and = field initializers are unchanged. Named types may be generic or ::-qualified, including pkg::Box<i32>.{ value = 1 }.
The dot distinguishes literals from control-flow blocks, so if Point.{ x = 1 }.ready() {} and for item in Box<i32>.{ value = 1 }.items() {} parse without parentheses. Enum payload construction remains Result<Point>::Ok with Point.{ x = 1 } or Result<Point>::Ok with .{ x = 1 }.
The grammar is configured for .peep files.
tree-sitter generate
tree-sitter testTo validate the grammar against the compiler sample file:
tree-sitter parse ../PeeperCompiler/x_test/struct_runtime.peep