Normative for this tree: compiler/tokens.js + compiler/parser.js (2026.08.28). Spec: spec/PANINI_SELF_HOSTING_SPEC.pni.
PANINI grammar (implemented)
This is the language the interpreter actually accepts. The spec is larger. Gaps are not filled from memory.
Lexical
token = keyword | ident | number | string | op | comment | newline ;
comment = "//" { char - nl } | "#" { char - nl } | "/*" { char } "*/" ;
ident = (letter | "_") { letter | digit | "_" } ;
number = digit { digit } [ "." digit { digit } ] ;
string = '"' { char | escape } '"' ;
op = "..." | ".." | ":=" | "->" | "=>" | "<=" | ">=" | "==" | "!="
| "&&" | "||" | "+" | "-" | "*" | "/" | "%" | "=" | "<" | ">"
| "!" | "." | "(" | ")" | "[" | "]" | "{" | "}" | "," | ":" | "@" | "|" | "?" ;
Phrases (parser)
program = { top } ;
top = module | function | class | type_decl | statement ;
module = ( "MODULE" | "SCOPE" ) name { top } "END" ;
function = "FUNCTION" name [ "(" params ")" ] [ "->" type ] block "END" ;
params = [ param { "," param } ] ;
param = name [ ":" type ] ;
block = { statement } ;
statement = function | if | while | for | try | return | print | assign | expr ;
if = "IF" expr [ "THEN" ] block
{ "ELSEIF" expr [ "THEN" ] block }
[ "ELSE" block ]
"END" ;
while = "WHILE" expr block "END" ;
for = "FOR" name "=" expr "TO" expr [ "STEP" expr ] block "END" ;
return = "RETURN" [ expr ] ;
print = "PRINT" expr { "," expr } ;
assign = name ( "=" | ":=" ) expr ;
expr = or_expr ;
name = ident { "." ident } ;
Keywords (tokens.js)
MODULE SCOPE END CONSTITUTION FUNCTION RETURN IF ELSE ELSEIF ELSIF THEN FOR FOREACH WHILE UNTIL REPEAT CLASS TRAIT INTERFACE TYPE TRY CATCH FINALLY MATCH CASE PRINT LET VAR CONST TRUE FALSE NULL AND OR NOT IMPORT EXPORT THIS NEW ARTIFACT CYCLER STAGE THEOREM INVARIANT … (full set in compiler/tokens.js).
Self-host
src/panini/lexer.pni and src/panini/parser.pni are the same grammar written in PANINI. A=B=C is the theorem that this host lexer, that PANINI lexer, and the spec agree on the token stream.