visualize-parse-tree
Visualize parse trees from ANTLR4 grammars in ASCII, JSON, or Lisp formats to understand parsing results and debug grammar structure.
Instructions
Visualize the parse tree structure for a given input.
When to use: Understanding parse results, debugging grammar structure, documentation.
Output formats:
ascii: Text-based tree with indentation (default)
json: Structured JSON tree representation
lisp: S-expression style (rule child1 child2 ...)
Parameters:
grammar_files: Object mapping filename to content
start_rule: Parser rule to start from
input: Sample input text
format: Output format (ascii, json, lisp)
Example: grammar_files: {"Expr.g4": "grammar Expr; ..."} start_rule: "expr" input: "1 + 2 * 3" format: "ascii"
Returns: ASCII example:
expr
├── term
│ └── factor
│ └── NUMBER '1'
├── PLUS '+'
└── term
├── factor
│ └── NUMBER '2'
├── TIMES '*'
└── factor
└── NUMBER '3'Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | Input text to parse | |
| format | No | Output format (default: ascii) | |
| start_rule | Yes | Parser rule to start parsing from | |
| grammar_files | Yes | Map of filename to grammar content |