JavaCC Support
JavaCC Support adds editing support for JavaCC and JJTree grammars in VS Code.
It recognizes .jj and .jjt files, provides JavaCC-aware syntax highlighting, and starts a language server that understands common grammar structures well enough to support navigation and authoring workflows.
Features
- Syntax highlighting for JavaCC and JJTree files.
- Go to Definition for token and production references.
- Find References for tokens and productions.
- Rename support for tokens and productions.
- Hover information for token and production definitions.
- Completions for productions and token references.
- Outline view support for productions, tokens, and private tokens.
- Diagnostics for parser problems and some resolved token-definition hints.
- Semantic token highlighting to improve classification beyond what TextMate alone can do.

How It Works
The extension uses two layers:
- A TextMate grammar for fast initial highlighting.
- A language server backed by a tolerant Chevrotain-based parser for navigation, diagnostics, and semantic tokens.
This split is intentional. TextMate gives immediate baseline coloring, while the parser-driven language server can identify productions, token definitions, token references, lexical states, and JJTree node descriptors more accurately.
Current Scope
The extension currently works best for:
- Standard JavaCC token productions such as
TOKEN, SPECIAL_TOKEN, SKIP, and MORE.
- JJTree node descriptors such as
#Node and #void.
- Production declarations and calls.
- Grammars similar in structure to the included Salinas and Java 1.1 fixtures.
Limitations
The parser is intentionally tolerant because this is an editor feature, not a full JavaCC compiler. That means it aims to stay useful while you type, but it does not model the entire JavaCC language perfectly.
Known limitations include:
- Lexical-state handling is currently limited. Lexical-state-prefixed token productions are recognized, highlighted, and surfaced in semantic tokens, but cross-state analysis is not fully state-aware.
- Token and production analysis is heuristic in some contexts, especially around incomplete code, embedded Java, and unusual grammar constructs.
- Semantic tokens improve classification, but they do not replace the underlying TextMate grammar. If a construct is structurally ambiguous, highlighting may still be approximate.
- Embedded Java blocks are not deeply analyzed as JavaCC semantics; they are mostly treated as balanced regions so the editor can keep functioning.
- Real-world grammars outside the currently tested patterns may expose unsupported edge cases.
File Types
The extension registers support for:
Requirements
No extra configuration is currently required.
After installing from source, run npm install in the extension folder and reload the VS Code window so the language server is activated with the installed dependencies.
Extension Settings
This extension does not currently contribute custom VS Code settings.
Development
Useful commands:
The test suite covers parser behavior, fixture parsing, semantic tokens, and TextMate grammar expectations.
Known Issues
- Some JavaCC and JJTree constructs are only partially understood.
- State-sensitive token behavior is not fully modeled yet.
- Highlighting and navigation are strongest on grammars that follow conventional JavaCC formatting and structure.
Release Notes
0.0.1
Initial working release with JavaCC and JJTree language support, LSP-powered navigation, semantic tokens, and regression tests.