Pop-11 (Poplog) grammar for tree-sitter.
Pop-11 is the incremental-native-compilation language at the heart of
Poplog — five languages (Pop-11, Prolog, Common Lisp, SML, Forth) on one
heap, with forty years of AI teaching material behind it. This grammar
gives its .p sources syntax highlighting, folding and structural
editing in tree-sitter consumers (Neovim, Zed, GitHub via linguist).
Pop-11's syntax is user-extensible (programs define new syntax words at compile time), so no static grammar can be complete. This one parses the stable core faithfully and lets everything else degrade to a flat item "soup" rather than derailing:
- comments (
;;; …and nesting/* … */), strings, word literals (closed,""", and the unclosed"ml]shorthand), character constants in all historical forms (`a`,`\{7}\s`,```, legacy unclosed`7), numbers with radix (16:FF); define/enddefinein all its shapes (modifiers,:forms, infix operator definitions,= exprvalue form) with the defined name captured for highlighting;- the closed set of core block syntax words and their
end…closers, including the archaicuntil … then … enduntilloop form; - declarations (
vars/lvars/dlocal/constant/…,proceduretyping, syntax-word name lists),uses(bare, parenthesised and hyphenated forms),exloadblocks,vedsetkey maps (where[is a literal token); - quoting semantics: plain
[ … ]/{ … }quote their contents (any keyword is data inside),% … %sections switch back to evaluation; #_IFfamily compile-time directives and#_< … >_#.
Measured against the full Poplog tree (1,805 files, 270k lines spanning 1985–2026, including the syspop system dialect and the Lisp/Prolog/ML subsystem internals): 95.2 % of files parse without errors; the user-facing library corpus and every modern library parse clean.
tree-sitter generate
tree-sitter test
tree-sitter parse path/to/file.pCorpus tests live in test/corpus/. The parse-rate sweep against a
Poplog checkout:
find poplog/pop/lib -name '*.p' > /tmp/files.txt
tree-sitter parse --paths /tmp/files.txt --quiet --statv0.1 — grammar core + highlight/fold/textobject queries (phase P1 of
the Poplog editor-bindings plan).
Next: Neovim ftdetect + highlighting wiring, Zed extension, linguist
submission (with the .p content heuristics — ;;;, define …;,
enddefine — to disambiguate from Pascal/Gnuplot).