Skip to content

Repository files navigation

tree-sitter-pop11

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).

Design

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/enddefine in all its shapes (modifiers, :forms, infix operator definitions, = expr value form) with the defined name captured for highlighting;
  • the closed set of core block syntax words and their end… closers, including the archaic until … then … enduntil loop form;
  • declarations (vars/lvars/dlocal/constant/…, procedure typing, syntax-word name lists), uses (bare, parenthesised and hyphenated forms), exload blocks, vedset key maps (where [ is a literal token);
  • quoting semantics: plain [ … ] / { … } quote their contents (any keyword is data inside), % … % sections switch back to evaluation;
  • #_IF family 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.

Development

tree-sitter generate
tree-sitter test
tree-sitter parse path/to/file.p

Corpus 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 --stat

Status

v0.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).

About

Pop-11 (Poplog) grammar for tree-sitter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages