td-antlers-parser
v0.1.0
Published
Extracted Antlers parser and lexer sources from Stillat's VS Code Antlers language server.
Readme
Antlers Parser Extract
This repository contains an extracted copy of the Antlers parser and lexer sources from the VS Code Antlers language server:
- Source: https://github.com/Stillat/vscode-antlers-language-server/tree/main/server/src
- Extracted from
mainat commit74d6f49ebf1f102d9128f543c652f78c11ee5765 - Upstream commit date:
2025-05-29 - License: MIT, preserved in LICENSE.md
Layout
src/is the upstreamserver/srctreesrc/runtime/lexer/antlersLexer.tsis the lexersrc/runtime/parser/documentParser.tsis the document parsersrc/runtime/parser/languageParser.tsis the language expression parsersrc/index.tsre-exports the main parser/lexer entrypoints
Build
npm install
npm run buildTests
Run the parser test suite with:
npm testThe current tests are built around examples from the Statamic Antlers documentation:
- Source docs: https://statamic.dev/frontend/antlers
test/statamic-docs.variables.test.jscovers variable, modifier, path access, and expression examplestest/statamic-docs.operators.test.jscovers control flow, assignment, switch, and advanced operator examplestest/statamic-docs.tags-and-escapes.test.jscovers tag pairs, parameters, self-closing tags, escaping, comments, and PHP delimiters
These tests are intended to verify that the extracted parser accepts real-world Antlers syntax shown in the official docs, not just the original upstream unit cases. A few documented behaviors that are not yet modeled by this extraction are noted inline in the test files rather than being asserted as failures.
Notes
The parser and lexer are not isolated single files upstream. They depend on a larger runtime and support tree, so this extraction preserves the upstream source layout rather than trying to hand-prune dependencies.
