{"owner":"antlr","repo":"grammars-v4","hasSkills":true,"totalSkillsCount":2,"totalTokensCount":2993,"categories":["plugin-manifest","claude-rule"],"hasMcp":false,"mcpConfig":null,"found":["_scripts/antlr4-tools/README.md","CLAUDE.md"],"skills":{"_scripts/antlr4-tools/README.md":"# antlr4-tools\n\nTools to run antlr4 w/o needing to install java or antlr4! The only requirement is Python3, which is typically installed on all developer machines on all operating systems. \n \n## Install\n\n```bash\n$ pip install antlr4-tools\n```\n\nThat creates `antlr4` and `antlr4-parse` executables. On Windows, of course, this doesn't just work. You need to add the `...\\local-packages\\python38\\scripts` dir to your `PATH`, which itself might require a fun reboot or perhaps reinstall of the OS. haha.\n\n### Windows-specific issues\n\nOn Windows, the `pip` command doesn't just work---you need to add the `...\\local-packages\\python38\\scripts` dir to your `PATH`, which itself might require a fun reboot.  If you use WSL on Windows, then the pip install will also properly at the scripts directly (if you run from bash shell).\n\n\n1. Go to the Microsoft Store\n2. Search in Microsoft Store for Python\n3. Select the newest version of Python (3.10).\n4. Click the \"Get\" button. Store installs python and pip at \"c:\\Users...\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe\" and \"c:\\Users...\\AppData\\Local\\Microsoft\\WindowsApps\\pip.exe\", respectively. And, it updates the search path immediately with the install.\n5. Open a \"cmd\" terminal.\n6. You can now type \"python\" and \"pip\", and \"pip install antlr4-tools\". 7. Unfortunately, it does not add that to the search path.\n7. Update the search path to contain `c:\\Users...\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p8\\LocalCache\\local-packages\\Python310\\Scripts`. You may need to install MSYS2, then do a `find /c/ -name antlr4.exe 2> /dev/null` and enter that path.\n8. Or, you can set up an alias to antlr4.exe on that path.\n\nThe good news is that the ANTLR4 Python tool downloads the ANTLR jar in a standard location, and you don't need to do that manually. It's also possible to go in a browser, go to python.org, and download the python package. But, it's likely you will need to update the path for antlr4.exe as before.\n\n## First run will install Java and ANTLR\n\nIf needed, `antlr4` will download and install Java 11 and the latest ANTLR jar:\n\n```bash\n$ antlr4 \nDownloading antlr4-4.11.1-complete.jar\nANTLR tool needs Java to run; install Java JRE 11 yes/no (default yes)? y\nInstalled Java in /Users/parrt/.jre/jdk-11.0.15+10-jre; remove that dir to uninstall\nANTLR Parser Generator  Version 4.11.1\n -o ___              specify output directory where all output is generated\n -lib ___            specify location of grammars, tokens files\n...\n```\n\nTo override the version of ANTLR jar used, you can pass a `-v <version>` argument or set `ANTLR4_TOOLS_ANTLR_VERSION` environment variable:\n\n```bash\n$ antlr4 -v 4.9.3\nANTLR Parser Generator  Version 4.9.3\n -o ___              specify output directory where all output is generated\n -lib ___            specify location of grammars, tokens files\n...\n$ ANTLR4_TOOLS_ANTLR_VERSION=4.10.1 antlr4\nANTLR Parser Generator  Version 4.10.1\n -o ___              specify output directory where all output is generated\n -lib ___            specify location of grammars, tokens files\n...\n```\n\n## Running ANTLR tool on grammars\n\nThe `antlr4` command forwards all arguments (besides `-v` mentioned above) to the actual ANTLR tool command:\n\n```bash\n$ antlr4 JSON.g4 \n$ ls JSON*.java\nJSONBaseListener.java  JSONLexer.java         JSONListener.java      JSONParser.java\n$ antlr4 -Dlanguage=Python3 -visitor JSON.g4\n$ ls JSON*.py\nJSONLexer.py     JSONListener.py  JSONParser.py    JSONVisitor.py\n```\n\n## Parsing using interpreter\n\nThe `antlr4-parse` command requires ANTLR 4.11 and above (but any version of ANTLR works for the plain `antlr4` command).  It accepts the same `-v` argument or environment variable to override the ANTLR jar version used.  (Note: `^D` means control-D and indicates \"end of input\" on Unix but use `^Z` on Windows.)\n\nLet's play with a simple grammar:\n\n```\ngrammar Expr;\nprog:\texpr EOF ;\nexpr:\texpr ('*'|'/') expr\n    |\texpr ('+'|'-') expr\n    |\tINT\n    |\t'(' expr ')'\n    ;\nNEWLINE : [\\r\\n]+ -> skip;\nINT     : [0-9]+ ;\n```\n\nTo parse and get the parse tree in text form, use:\n\n```bash\n$ antlr4-parse Expr.g4 prog -tree\n10+20*30\n^D\n(prog:1 (expr:2 (expr:3 10) + (expr:1 (expr:3 20) * (expr:3 30))) <EOF>)\n```\n\nHere's how to get the tokens and trace through the parse:\n\n```bash\n$ antlr4-parse Expr.g4 prog -tokens -trace\n10+20*30\n[@0,0:1='10',<INT>,1:0]\n[@1,2:2='+',<'+'>,1:2]\n[@2,3:4='20',<INT>,1:3]\n[@3,5:5='*',<'*'>,1:5]\n[@4,6:7='30',<INT>,1:6]\n[@5,9:8='<EOF>',<EOF>,2:0]\nenter   prog, LT(1)=10\nenter   expr, LT(1)=10\nconsume [@0,0:1='10',<8>,1:0] rule expr\nenter   expr, LT(1)=+\nconsume [@1,2:2='+',<3>,1:2] rule expr\nenter   expr, LT(1)=20\nconsume [@2,3:4='20',<8>,1:3] rule expr\nenter   expr, LT(1)=*\nconsume [@3,5:5='*',<1>,1:5] rule expr\nenter   expr, LT(1)=30\nconsume [@4,6:7='30',<8>,1:6] rule expr\nexit    expr, LT(1)=<EOF>\nexit    expr, LT(1)=<EOF>\nexit    expr, LT(1)=<EOF>\nconsume [@5,9:8='<EOF>',<-1>,2:0] rule prog\nexit    prog, LT(1)=<EOF>\n```\n\nHere's how to get a visual tree view:\n\n```bash\n$ antlr4-parse Expr.g4 prog -gui\n10+20*30\n```\n\nThe following will pop up in a Java-based GUI window:\n\n<img src=\"images/parse-tree.png\" width=\"300\">\n\nOn real grammars, it can be useful to get decision-making profiling info:\n\n```bash\n$ antlr4-parse JavaLexer.g4 JavaParser.g4 compilationUnit -profile dump.csv T.java\n$ open /tmp/dump.csv \n$ head -5 /tmp/dump.csv \nRule,Invocations,Time (ms),Total k,Max k,Ambiguities,DFA cache miss\ncompilationUnit:0,1,0.164791,1,1,0,1\ncompilationUnit:1,42,1.106583,42,1,0,2\ncompilationUnit:2,2,1.73675,2,1,0,2\ncompilationUnit:3,1,3.969,1,1,0,1\n```\n\n","CLAUDE.md":"# Claude Notes\n\n@GLOSSARY.md\n\n## Trash Toolkit\n\nThe Trash Toolkit is a collection of .NET tools for working with Antlr4 grammars.\nSource and documentation: https://github.com/kaby76/Trash\n\nThe tools are declared in `.config/dotnet-tools.json` at the repo root and must be\nrestored once before use (or after a fresh clone):\n\n```sh\ncd <repo-root>       # i.e. the grammars-v4 clone root\ndotnet tool restore\n```\n\nThis installs all `tr*` tools (`trgen`, `trwdog`, `trperf`, `trglob`, `triconv`,\n`trparse`, `trquery`, `trxml2`, etc.) as local .NET tools available via `dotnet <toolname>`.\n\n## Testing a Grammar\n\nTo test a grammar (e.g. `csharp/v8-spec`), follow these steps from the repo root.\n\n**1. Restore the Trash Toolkit (once per clone), and note location:**\n\n```sh\ndotnet tool restore\ncloneroot=`pwd`\n```\n\n**2. Generate the C# sandbox:**\n\n```sh\ncd csharp/v8-spec\ndotnet trash gen -t CSharp\n```\n\n`trgen` reads `desc.xml` in the current directory for grammar and test configuration,\ndiscovers all `.g4` files, resolves their dependencies, and writes the complete driver\napplication into `Generated-CSharp/`.\n\n> **trgen rules:**\n> - Only ever use `-t <target>` — no other options (no `--template-sources-directory`, etc.).\n> - Always run `dotnet trash gen` from the directory that contains `desc.xml` (the grammar dir).\n> - Never run it from the repo root or any other directory.\n> - For Java: `dotnet trash gen -t Java` → generates `Generated-Java/`.\n\n**3. Build the driver:**\n\n```sh\ncd Generated-CSharp\nbash build.sh\n```\n\n`build.sh` runs `antlr4` to regenerate the lexer/parser C# sources from the `.g4`\nfiles, then `dotnet build` to compile the driver. You will need to install prerequisites\nfor building and compiling the generated driver.\n\n**4. Run the test suite, and test individual parses:**\n\n```sh\nbash test.sh\n```\n\n`test.sh` parses all example files listed in `desc.xml`, writes `.tree` and `.errors`\nfiles alongside the inputs, and diffs them against the committed baselines. It prints\n`Test succeeded.` on success or `Test failed.` with a diff on failure.\n\n```sh\nbash run.sh *.txt\n```\n\n`run.sh` parses individual files.\n\n## Maven Antlr4 Tester (old/Java-based)\n\nEach grammar directory contains a `pom.xml` that uses the `antlr4test-maven-plugin`.\nFor the `pom.xml` format, see https://maven.apache.org/guides/introduction/introduction-to-the-pom.html.\n\n**Test a single grammar:**\n\n```sh\ncd <grammar-dir>   # directory containing pom.xml\nmvn clean test\n```\n\n**Test all grammars:**\n\n```sh\ncd <repo-root>\nmvn clean test\n```\n\n**Test only grammars changed in a PR:**\n\n```sh\n_scripts/maven.sh <before-git-sha> <after-git-sha>\n```\n\n### Common Maven test failure: \"no errors found, but errors file exists\"\n\nThis happens when zero-length `.errors` files (generated by the Trash Toolkit test runner)\nare left in the examples directory. The Maven plugin treats any `.errors` file as a baseline\nthat expects parse failures, so if parsing succeeds it fails the test.\n\nFix: delete only the zero-length `.errors` files from the test directory (check `pom.xml` for\n`<exampleFiles>` to confirm the directory; default is `examples/`):\n\n```sh\nfind examples/ -name \"*.errors\" -size 0 -delete\n```\n\nThis is safer than `git clean -f .`, which would remove *all* untracked files (including any\nnew test inputs you've added but not yet staged with `git add`).\n\n### Common Maven test failure: unexpected file extensions in examples/\n\nIf people add test inputs or documentation into `examples/` with extensions that the plugin\ndoesn't expect, the plugin may try to parse them and fail. This is caused by not specifying\n`<testFileExtension>` in `pom.xml`. Check the `pom.xml` for that element; if it's absent,\nthe plugin will attempt to parse every file in the examples directory.\n\n## Checking for Ambiguity (Trash Toolkit / C# target)\n\nThe generated C# test harness is in `.../Generated-CSharp/`.\n\n**Build** (only needed once, or after grammar changes):\n\n```sh\ncd Generated-CSharp\nbash build.sh\n```\n\n**Check a single file for ambiguity:**\n\nUsing the built binary directly:\n\n```sh\n./bin/Debug/net10.0/Test.exe --ambig <file>\n```\n\nThe `--ambig` flag enables ANTLR's profiling mode. After parsing, it reports every\nATN decision where more than one alternative was viable for the actual input (a true\ngrammar ambiguity). For each ambiguity it prints all distinct parse trees, one per\nline, prefixed with `d=<decision>.a=<alt>` (e.g. `d=195.a=1`, `d=195.a=2`).\n\n**Restrict output to specific decisions:**\n\n```sh\n./bin/Debug/net10.0/Test.exe --ambig=195,42 <file>\n```\n\n**Limit the number of parse trees returned:**\n\n```sh\n./bin/Debug/net10.0/Test.exe --ambig --limit=4 <file>\n```\n\n**Using trparse/trtree to show ambiguities:**\n\n```sh\ndotnet trash parse --ambig <file> | dotnet trash tree\n```\n"},"files":{"_scripts/antlr4-tools/README.md":"# antlr4-tools\n\nTools to run antlr4 w/o needing to install java or antlr4! The only requirement is Python3, which is typically installed on all developer machines on all operating systems. \n \n## Install\n\n```bash\n$ pip install antlr4-tools\n```\n\nThat creates `antlr4` and `antlr4-parse` executables. On Windows, of course, this doesn't just work. You need to add the `...\\local-packages\\python38\\scripts` dir to your `PATH`, which itself might require a fun reboot or perhaps reinstall of the OS. haha.\n\n### Windows-specific issues\n\nOn Windows, the `pip` command doesn't just work---you need to add the `...\\local-packages\\python38\\scripts` dir to your `PATH`, which itself might require a fun reboot.  If you use WSL on Windows, then the pip install will also properly at the scripts directly (if you run from bash shell).\n\n\n1. Go to the Microsoft Store\n2. Search in Microsoft Store for Python\n3. Select the newest version of Python (3.10).\n4. Click the \"Get\" button. Store installs python and pip at \"c:\\Users...\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe\" and \"c:\\Users...\\AppData\\Local\\Microsoft\\WindowsApps\\pip.exe\", respectively. And, it updates the search path immediately with the install.\n5. Open a \"cmd\" terminal.\n6. You can now type \"python\" and \"pip\", and \"pip install antlr4-tools\". 7. Unfortunately, it does not add that to the search path.\n7. Update the search path to contain `c:\\Users...\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p8\\LocalCache\\local-packages\\Python310\\Scripts`. You may need to install MSYS2, then do a `find /c/ -name antlr4.exe 2> /dev/null` and enter that path.\n8. Or, you can set up an alias to antlr4.exe on that path.\n\nThe good news is that the ANTLR4 Python tool downloads the ANTLR jar in a standard location, and you don't need to do that manually. It's also possible to go in a browser, go to python.org, and download the python package. But, it's likely you will need to update the path for antlr4.exe as before.\n\n## First run will install Java and ANTLR\n\nIf needed, `antlr4` will download and install Java 11 and the latest ANTLR jar:\n\n```bash\n$ antlr4 \nDownloading antlr4-4.11.1-complete.jar\nANTLR tool needs Java to run; install Java JRE 11 yes/no (default yes)? y\nInstalled Java in /Users/parrt/.jre/jdk-11.0.15+10-jre; remove that dir to uninstall\nANTLR Parser Generator  Version 4.11.1\n -o ___              specify output directory where all output is generated\n -lib ___            specify location of grammars, tokens files\n...\n```\n\nTo override the version of ANTLR jar used, you can pass a `-v <version>` argument or set `ANTLR4_TOOLS_ANTLR_VERSION` environment variable:\n\n```bash\n$ antlr4 -v 4.9.3\nANTLR Parser Generator  Version 4.9.3\n -o ___              specify output directory where all output is generated\n -lib ___            specify location of grammars, tokens files\n...\n$ ANTLR4_TOOLS_ANTLR_VERSION=4.10.1 antlr4\nANTLR Parser Generator  Version 4.10.1\n -o ___              specify output directory where all output is generated\n -lib ___            specify location of grammars, tokens files\n...\n```\n\n## Running ANTLR tool on grammars\n\nThe `antlr4` command forwards all arguments (besides `-v` mentioned above) to the actual ANTLR tool command:\n\n```bash\n$ antlr4 JSON.g4 \n$ ls JSON*.java\nJSONBaseListener.java  JSONLexer.java         JSONListener.java      JSONParser.java\n$ antlr4 -Dlanguage=Python3 -visitor JSON.g4\n$ ls JSON*.py\nJSONLexer.py     JSONListener.py  JSONParser.py    JSONVisitor.py\n```\n\n## Parsing using interpreter\n\nThe `antlr4-parse` command requires ANTLR 4.11 and above (but any version of ANTLR works for the plain `antlr4` command).  It accepts the same `-v` argument or environment variable to override the ANTLR jar version used.  (Note: `^D` means control-D and indicates \"end of input\" on Unix but use `^Z` on Windows.)\n\nLet's play with a simple grammar:\n\n```\ngrammar Expr;\nprog:\texpr EOF ;\nexpr:\texpr ('*'|'/') expr\n    |\texpr ('+'|'-') expr\n    |\tINT\n    |\t'(' expr ')'\n    ;\nNEWLINE : [\\r\\n]+ -> skip;\nINT     : [0-9]+ ;\n```\n\nTo parse and get the parse tree in text form, use:\n\n```bash\n$ antlr4-parse Expr.g4 prog -tree\n10+20*30\n^D\n(prog:1 (expr:2 (expr:3 10) + (expr:1 (expr:3 20) * (expr:3 30))) <EOF>)\n```\n\nHere's how to get the tokens and trace through the parse:\n\n```bash\n$ antlr4-parse Expr.g4 prog -tokens -trace\n10+20*30\n[@0,0:1='10',<INT>,1:0]\n[@1,2:2='+',<'+'>,1:2]\n[@2,3:4='20',<INT>,1:3]\n[@3,5:5='*',<'*'>,1:5]\n[@4,6:7='30',<INT>,1:6]\n[@5,9:8='<EOF>',<EOF>,2:0]\nenter   prog, LT(1)=10\nenter   expr, LT(1)=10\nconsume [@0,0:1='10',<8>,1:0] rule expr\nenter   expr, LT(1)=+\nconsume [@1,2:2='+',<3>,1:2] rule expr\nenter   expr, LT(1)=20\nconsume [@2,3:4='20',<8>,1:3] rule expr\nenter   expr, LT(1)=*\nconsume [@3,5:5='*',<1>,1:5] rule expr\nenter   expr, LT(1)=30\nconsume [@4,6:7='30',<8>,1:6] rule expr\nexit    expr, LT(1)=<EOF>\nexit    expr, LT(1)=<EOF>\nexit    expr, LT(1)=<EOF>\nconsume [@5,9:8='<EOF>',<-1>,2:0] rule prog\nexit    prog, LT(1)=<EOF>\n```\n\nHere's how to get a visual tree view:\n\n```bash\n$ antlr4-parse Expr.g4 prog -gui\n10+20*30\n```\n\nThe following will pop up in a Java-based GUI window:\n\n<img src=\"images/parse-tree.png\" width=\"300\">\n\nOn real grammars, it can be useful to get decision-making profiling info:\n\n```bash\n$ antlr4-parse JavaLexer.g4 JavaParser.g4 compilationUnit -profile dump.csv T.java\n$ open /tmp/dump.csv \n$ head -5 /tmp/dump.csv \nRule,Invocations,Time (ms),Total k,Max k,Ambiguities,DFA cache miss\ncompilationUnit:0,1,0.164791,1,1,0,1\ncompilationUnit:1,42,1.106583,42,1,0,2\ncompilationUnit:2,2,1.73675,2,1,0,2\ncompilationUnit:3,1,3.969,1,1,0,1\n```\n\n","CLAUDE.md":"# Claude Notes\n\n@GLOSSARY.md\n\n## Trash Toolkit\n\nThe Trash Toolkit is a collection of .NET tools for working with Antlr4 grammars.\nSource and documentation: https://github.com/kaby76/Trash\n\nThe tools are declared in `.config/dotnet-tools.json` at the repo root and must be\nrestored once before use (or after a fresh clone):\n\n```sh\ncd <repo-root>       # i.e. the grammars-v4 clone root\ndotnet tool restore\n```\n\nThis installs all `tr*` tools (`trgen`, `trwdog`, `trperf`, `trglob`, `triconv`,\n`trparse`, `trquery`, `trxml2`, etc.) as local .NET tools available via `dotnet <toolname>`.\n\n## Testing a Grammar\n\nTo test a grammar (e.g. `csharp/v8-spec`), follow these steps from the repo root.\n\n**1. Restore the Trash Toolkit (once per clone), and note location:**\n\n```sh\ndotnet tool restore\ncloneroot=`pwd`\n```\n\n**2. Generate the C# sandbox:**\n\n```sh\ncd csharp/v8-spec\ndotnet trash gen -t CSharp\n```\n\n`trgen` reads `desc.xml` in the current directory for grammar and test configuration,\ndiscovers all `.g4` files, resolves their dependencies, and writes the complete driver\napplication into `Generated-CSharp/`.\n\n> **trgen rules:**\n> - Only ever use `-t <target>` — no other options (no `--template-sources-directory`, etc.).\n> - Always run `dotnet trash gen` from the directory that contains `desc.xml` (the grammar dir).\n> - Never run it from the repo root or any other directory.\n> - For Java: `dotnet trash gen -t Java` → generates `Generated-Java/`.\n\n**3. Build the driver:**\n\n```sh\ncd Generated-CSharp\nbash build.sh\n```\n\n`build.sh` runs `antlr4` to regenerate the lexer/parser C# sources from the `.g4`\nfiles, then `dotnet build` to compile the driver. You will need to install prerequisites\nfor building and compiling the generated driver.\n\n**4. Run the test suite, and test individual parses:**\n\n```sh\nbash test.sh\n```\n\n`test.sh` parses all example files listed in `desc.xml`, writes `.tree` and `.errors`\nfiles alongside the inputs, and diffs them against the committed baselines. It prints\n`Test succeeded.` on success or `Test failed.` with a diff on failure.\n\n```sh\nbash run.sh *.txt\n```\n\n`run.sh` parses individual files.\n\n## Maven Antlr4 Tester (old/Java-based)\n\nEach grammar directory contains a `pom.xml` that uses the `antlr4test-maven-plugin`.\nFor the `pom.xml` format, see https://maven.apache.org/guides/introduction/introduction-to-the-pom.html.\n\n**Test a single grammar:**\n\n```sh\ncd <grammar-dir>   # directory containing pom.xml\nmvn clean test\n```\n\n**Test all grammars:**\n\n```sh\ncd <repo-root>\nmvn clean test\n```\n\n**Test only grammars changed in a PR:**\n\n```sh\n_scripts/maven.sh <before-git-sha> <after-git-sha>\n```\n\n### Common Maven test failure: \"no errors found, but errors file exists\"\n\nThis happens when zero-length `.errors` files (generated by the Trash Toolkit test runner)\nare left in the examples directory. The Maven plugin treats any `.errors` file as a baseline\nthat expects parse failures, so if parsing succeeds it fails the test.\n\nFix: delete only the zero-length `.errors` files from the test directory (check `pom.xml` for\n`<exampleFiles>` to confirm the directory; default is `examples/`):\n\n```sh\nfind examples/ -name \"*.errors\" -size 0 -delete\n```\n\nThis is safer than `git clean -f .`, which would remove *all* untracked files (including any\nnew test inputs you've added but not yet staged with `git add`).\n\n### Common Maven test failure: unexpected file extensions in examples/\n\nIf people add test inputs or documentation into `examples/` with extensions that the plugin\ndoesn't expect, the plugin may try to parse them and fail. This is caused by not specifying\n`<testFileExtension>` in `pom.xml`. Check the `pom.xml` for that element; if it's absent,\nthe plugin will attempt to parse every file in the examples directory.\n\n## Checking for Ambiguity (Trash Toolkit / C# target)\n\nThe generated C# test harness is in `.../Generated-CSharp/`.\n\n**Build** (only needed once, or after grammar changes):\n\n```sh\ncd Generated-CSharp\nbash build.sh\n```\n\n**Check a single file for ambiguity:**\n\nUsing the built binary directly:\n\n```sh\n./bin/Debug/net10.0/Test.exe --ambig <file>\n```\n\nThe `--ambig` flag enables ANTLR's profiling mode. After parsing, it reports every\nATN decision where more than one alternative was viable for the actual input (a true\ngrammar ambiguity). For each ambiguity it prints all distinct parse trees, one per\nline, prefixed with `d=<decision>.a=<alt>` (e.g. `d=195.a=1`, `d=195.a=2`).\n\n**Restrict output to specific decisions:**\n\n```sh\n./bin/Debug/net10.0/Test.exe --ambig=195,42 <file>\n```\n\n**Limit the number of parse trees returned:**\n\n```sh\n./bin/Debug/net10.0/Test.exe --ambig --limit=4 <file>\n```\n\n**Using trparse/trtree to show ambiguities:**\n\n```sh\ndotnet trash parse --ambig <file> | dotnet trash tree\n```\n"},"items":[{"name":"CLAUDE.md","path":"CLAUDE.md","rawUrl":"https://raw.githubusercontent.com/antlr/grammars-v4/HEAD/CLAUDE.md","title":"Claude Agent Guidelines & System Prompt","category":"claude-rule","format":"markdown","content":"# Claude Notes\n\n@GLOSSARY.md\n\n## Trash Toolkit\n\nThe Trash Toolkit is a collection of .NET tools for working with Antlr4 grammars.\nSource and documentation: https://github.com/kaby76/Trash\n\nThe tools are declared in `.config/dotnet-tools.json` at the repo root and must be\nrestored once before use (or after a fresh clone):\n\n```sh\ncd <repo-root>       # i.e. the grammars-v4 clone root\ndotnet tool restore\n```\n\nThis installs all `tr*` tools (`trgen`, `trwdog`, `trperf`, `trglob`, `triconv`,\n`trparse`, `trquery`, `trxml2`, etc.) as local .NET tools available via `dotnet <toolname>`.\n\n## Testing a Grammar\n\nTo test a grammar (e.g. `csharp/v8-spec`), follow these steps from the repo root.\n\n**1. Restore the Trash Toolkit (once per clone), and note location:**\n\n```sh\ndotnet tool restore\ncloneroot=`pwd`\n```\n\n**2. Generate the C# sandbox:**\n\n```sh\ncd csharp/v8-spec\ndotnet trash gen -t CSharp\n```\n\n`trgen` reads `desc.xml` in the current directory for grammar and test configuration,\ndiscovers all `.g4` files, resolves their dependencies, and writes the complete driver\napplication into `Generated-CSharp/`.\n\n> **trgen rules:**\n> - Only ever use `-t <target>` — no other options (no `--template-sources-directory`, etc.).\n> - Always run `dotnet trash gen` from the directory that contains `desc.xml` (the grammar dir).\n> - Never run it from the repo root or any other directory.\n> - For Java: `dotnet trash gen -t Java` → generates `Generated-Java/`.\n\n**3. Build the driver:**\n\n```sh\ncd Generated-CSharp\nbash build.sh\n```\n\n`build.sh` runs `antlr4` to regenerate the lexer/parser C# sources from the `.g4`\nfiles, then `dotnet build` to compile the driver. You will need to install prerequisites\nfor building and compiling the generated driver.\n\n**4. Run the test suite, and test individual parses:**\n\n```sh\nbash test.sh\n```\n\n`test.sh` parses all example files listed in `desc.xml`, writes `.tree` and `.errors`\nfiles alongside the inputs, and diffs them against the committed baselines. It prints\n`Test succeeded.` on success or `Test failed.` with a diff on failure.\n\n```sh\nbash run.sh *.txt\n```\n\n`run.sh` parses individual files.\n\n## Maven Antlr4 Tester (old/Java-based)\n\nEach grammar directory contains a `pom.xml` that uses the `antlr4test-maven-plugin`.\nFor the `pom.xml` format, see https://maven.apache.org/guides/introduction/introduction-to-the-pom.html.\n\n**Test a single grammar:**\n\n```sh\ncd <grammar-dir>   # directory containing pom.xml\nmvn clean test\n```\n\n**Test all grammars:**\n\n```sh\ncd <repo-root>\nmvn clean test\n```\n\n**Test only grammars changed in a PR:**\n\n```sh\n_scripts/maven.sh <before-git-sha> <after-git-sha>\n```\n\n### Common Maven test failure: \"no errors found, but errors file exists\"\n\nThis happens when zero-length `.errors` files (generated by the Trash Toolkit test runner)\nare left in the examples directory. The Maven plugin treats any `.errors` file as a baseline\nthat expects parse failures, so if parsing succeeds it fails the test.\n\nFix: delete only the zero-length `.errors` files from the test directory (check `pom.xml` for\n`<exampleFiles>` to confirm the directory; default is `examples/`):\n\n```sh\nfind examples/ -name \"*.errors\" -size 0 -delete\n```\n\nThis is safer than `git clean -f .`, which would remove *all* untracked files (including any\nnew test inputs you've added but not yet staged with `git add`).\n\n### Common Maven test failure: unexpected file extensions in examples/\n\nIf people add test inputs or documentation into `examples/` with extensions that the plugin\ndoesn't expect, the plugin may try to parse them and fail. This is caused by not specifying\n`<testFileExtension>` in `pom.xml`. Check the `pom.xml` for that element; if it's absent,\nthe plugin will attempt to parse every file in the examples directory.\n\n## Checking for Ambiguity (Trash Toolkit / C# target)\n\nThe generated C# test harness is in `.../Generated-CSharp/`.\n\n**Build** (only needed once, or after grammar changes):\n\n```sh\ncd Generated-CSharp\nbash build.sh\n```\n\n**Check a single file for ambiguity:**\n\nUsing the built binary directly:\n\n```sh\n./bin/Debug/net10.0/Test.exe --ambig <file>\n```\n\nThe `--ambig` flag enables ANTLR's profiling mode. After parsing, it reports every\nATN decision where more than one alternative was viable for the actual input (a true\ngrammar ambiguity). For each ambiguity it prints all distinct parse trees, one per\nline, prefixed with `d=<decision>.a=<alt>` (e.g. `d=195.a=1`, `d=195.a=2`).\n\n**Restrict output to specific decisions:**\n\n```sh\n./bin/Debug/net10.0/Test.exe --ambig=195,42 <file>\n```\n\n**Limit the number of parse trees returned:**\n\n```sh\n./bin/Debug/net10.0/Test.exe --ambig --limit=4 <file>\n```\n\n**Using trparse/trtree to show ambiguities:**\n\n```sh\ndotnet trash parse --ambig <file> | dotnet trash tree\n```\n","isInternal":false,"tokens":1261,"sizeBytes":4774},{"name":"README.md","path":"_scripts/antlr4-tools/README.md","rawUrl":"https://raw.githubusercontent.com/antlr/grammars-v4/HEAD/_scripts/antlr4-tools/README.md","title":"antlr4-tools Documentation","category":"plugin-manifest","format":"markdown","content":"# antlr4-tools\n\nTools to run antlr4 w/o needing to install java or antlr4! The only requirement is Python3, which is typically installed on all developer machines on all operating systems. \n \n## Install\n\n```bash\n$ pip install antlr4-tools\n```\n\nThat creates `antlr4` and `antlr4-parse` executables. On Windows, of course, this doesn't just work. You need to add the `...\\local-packages\\python38\\scripts` dir to your `PATH`, which itself might require a fun reboot or perhaps reinstall of the OS. haha.\n\n### Windows-specific issues\n\nOn Windows, the `pip` command doesn't just work---you need to add the `...\\local-packages\\python38\\scripts` dir to your `PATH`, which itself might require a fun reboot.  If you use WSL on Windows, then the pip install will also properly at the scripts directly (if you run from bash shell).\n\n\n1. Go to the Microsoft Store\n2. Search in Microsoft Store for Python\n3. Select the newest version of Python (3.10).\n4. Click the \"Get\" button. Store installs python and pip at \"c:\\Users...\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe\" and \"c:\\Users...\\AppData\\Local\\Microsoft\\WindowsApps\\pip.exe\", respectively. And, it updates the search path immediately with the install.\n5. Open a \"cmd\" terminal.\n6. You can now type \"python\" and \"pip\", and \"pip install antlr4-tools\". 7. Unfortunately, it does not add that to the search path.\n7. Update the search path to contain `c:\\Users...\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p8\\LocalCache\\local-packages\\Python310\\Scripts`. You may need to install MSYS2, then do a `find /c/ -name antlr4.exe 2> /dev/null` and enter that path.\n8. Or, you can set up an alias to antlr4.exe on that path.\n\nThe good news is that the ANTLR4 Python tool downloads the ANTLR jar in a standard location, and you don't need to do that manually. It's also possible to go in a browser, go to python.org, and download the python package. But, it's likely you will need to update the path for antlr4.exe as before.\n\n## First run will install Java and ANTLR\n\nIf needed, `antlr4` will download and install Java 11 and the latest ANTLR jar:\n\n```bash\n$ antlr4 \nDownloading antlr4-4.11.1-complete.jar\nANTLR tool needs Java to run; install Java JRE 11 yes/no (default yes)? y\nInstalled Java in /Users/parrt/.jre/jdk-11.0.15+10-jre; remove that dir to uninstall\nANTLR Parser Generator  Version 4.11.1\n -o ___              specify output directory where all output is generated\n -lib ___            specify location of grammars, tokens files\n...\n```\n\nTo override the version of ANTLR jar used, you can pass a `-v <version>` argument or set `ANTLR4_TOOLS_ANTLR_VERSION` environment variable:\n\n```bash\n$ antlr4 -v 4.9.3\nANTLR Parser Generator  Version 4.9.3\n -o ___              specify output directory where all output is generated\n -lib ___            specify location of grammars, tokens files\n...\n$ ANTLR4_TOOLS_ANTLR_VERSION=4.10.1 antlr4\nANTLR Parser Generator  Version 4.10.1\n -o ___              specify output directory where all output is generated\n -lib ___            specify location of grammars, tokens files\n...\n```\n\n## Running ANTLR tool on grammars\n\nThe `antlr4` command forwards all arguments (besides `-v` mentioned above) to the actual ANTLR tool command:\n\n```bash\n$ antlr4 JSON.g4 \n$ ls JSON*.java\nJSONBaseListener.java  JSONLexer.java         JSONListener.java      JSONParser.java\n$ antlr4 -Dlanguage=Python3 -visitor JSON.g4\n$ ls JSON*.py\nJSONLexer.py     JSONListener.py  JSONParser.py    JSONVisitor.py\n```\n\n## Parsing using interpreter\n\nThe `antlr4-parse` command requires ANTLR 4.11 and above (but any version of ANTLR works for the plain `antlr4` command).  It accepts the same `-v` argument or environment variable to override the ANTLR jar version used.  (Note: `^D` means control-D and indicates \"end of input\" on Unix but use `^Z` on Windows.)\n\nLet's play with a simple grammar:\n\n```\ngrammar Expr;\nprog:\texpr EOF ;\nexpr:\texpr ('*'|'/') expr\n    |\texpr ('+'|'-') expr\n    |\tINT\n    |\t'(' expr ')'\n    ;\nNEWLINE : [\\r\\n]+ -> skip;\nINT     : [0-9]+ ;\n```\n\nTo parse and get the parse tree in text form, use:\n\n```bash\n$ antlr4-parse Expr.g4 prog -tree\n10+20*30\n^D\n(prog:1 (expr:2 (expr:3 10) + (expr:1 (expr:3 20) * (expr:3 30))) <EOF>)\n```\n\nHere's how to get the tokens and trace through the parse:\n\n```bash\n$ antlr4-parse Expr.g4 prog -tokens -trace\n10+20*30\n[@0,0:1='10',<INT>,1:0]\n[@1,2:2='+',<'+'>,1:2]\n[@2,3:4='20',<INT>,1:3]\n[@3,5:5='*',<'*'>,1:5]\n[@4,6:7='30',<INT>,1:6]\n[@5,9:8='<EOF>',<EOF>,2:0]\nenter   prog, LT(1)=10\nenter   expr, LT(1)=10\nconsume [@0,0:1='10',<8>,1:0] rule expr\nenter   expr, LT(1)=+\nconsume [@1,2:2='+',<3>,1:2] rule expr\nenter   expr, LT(1)=20\nconsume [@2,3:4='20',<8>,1:3] rule expr\nenter   expr, LT(1)=*\nconsume [@3,5:5='*',<1>,1:5] rule expr\nenter   expr, LT(1)=30\nconsume [@4,6:7='30',<8>,1:6] rule expr\nexit    expr, LT(1)=<EOF>\nexit    expr, LT(1)=<EOF>\nexit    expr, LT(1)=<EOF>\nconsume [@5,9:8='<EOF>',<-1>,2:0] rule prog\nexit    prog, LT(1)=<EOF>\n```\n\nHere's how to get a visual tree view:\n\n```bash\n$ antlr4-parse Expr.g4 prog -gui\n10+20*30\n```\n\nThe following will pop up in a Java-based GUI window:\n\n<img src=\"images/parse-tree.png\" width=\"300\">\n\nOn real grammars, it can be useful to get decision-making profiling info:\n\n```bash\n$ antlr4-parse JavaLexer.g4 JavaParser.g4 compilationUnit -profile dump.csv T.java\n$ open /tmp/dump.csv \n$ head -5 /tmp/dump.csv \nRule,Invocations,Time (ms),Total k,Max k,Ambiguities,DFA cache miss\ncompilationUnit:0,1,0.164791,1,1,0,1\ncompilationUnit:1,42,1.106583,42,1,0,2\ncompilationUnit:2,2,1.73675,2,1,0,2\ncompilationUnit:3,1,3.969,1,1,0,1\n```\n\n","isInternal":false,"tokens":1732,"sizeBytes":5614}],"systemPromptSnippet":"<yakaai_skills repo=\"antlr/grammars-v4\">\n<!-- File: CLAUDE.md (Tokens: ~1261 | Category: claude-rule) -->\n# Claude Notes\n\n@GLOSSARY.md\n\n## Trash Toolkit\n\nThe Trash Toolkit is a collection of .NET tools for working with Antlr4 grammars.\nSource and documentation: https://github.com/kaby76/Trash\n\nThe tools are declared in `.config/dotnet-tools.json` at the repo root and must be\nrestored once before use (or after a fresh clone):\n\n```sh\ncd <repo-root>       # i.e. the grammars-v4 clone root\ndotnet tool restore\n```\n\nThis installs all `tr*` tools (`trgen`, `trwdog`, `trperf`, `trglob`, `triconv`,\n`trparse`, `trquery`, `trxml2`, etc.) as local .NET tools available via `dotnet <toolname>`.\n\n## Testing a Grammar\n\nTo test a grammar (e.g. `csharp/v8-spec`), follow these steps from the repo root.\n\n**1. Restore the Trash Toolkit (once per clone), and note location:**\n\n```sh\ndotnet tool restore\ncloneroot=`pwd`\n```\n\n**2. Generate the C# sandbox:**\n\n```sh\ncd csharp/v8-spec\ndotnet trash gen -t CSharp\n```\n\n`trgen` reads `desc.xml` in the current directory for grammar and test configuration,\ndiscovers all `.g4` files, resolves their dependencies, and writes the complete driver\napplication into `Generated-CSharp/`.\n\n> **trgen rules:**\n> - Only ever use `-t <target>` — no other options (no `--template-sources-directory`, etc.).\n> - Always run `dotnet trash gen` from the directory that contains `desc.xml` (the grammar dir).\n> - Never run it from the repo root or any other directory.\n> - For Java: `dotnet trash gen -t Java` → generates `Generated-Java/`.\n\n**3. Build the driver:**\n\n```sh\ncd Generated-CSharp\nbash build.sh\n```\n\n`build.sh` runs `antlr4` to regenerate the lexer/parser C# sources from the `.g4`\nfiles, then `dotnet build` to compile the driver. You will need to install prerequisites\nfor building and compiling the generated driver.\n\n**4. Run the test suite, and test individual parses:**\n\n```sh\nbash test.sh\n```\n\n`test.sh` parses all example files listed in `desc.xml`, writes `.tree` and `.errors`\nfiles alongside the inputs, and diffs them against the committed baselines. It prints\n`Test succeeded.` on success or `Test failed.` with a diff on failure.\n\n```sh\nbash run.sh *.txt\n```\n\n`run.sh` parses individual files.\n\n## Maven Antlr4 Tester (old/Java-based)\n\nEach grammar directory contains a `pom.xml` that uses the `antlr4test-maven-plugin`.\nFor the `pom.xml` format, see https://maven.apache.org/guides/introduction/introduction-to-the-pom.html.\n\n**Test a single grammar:**\n\n```sh\ncd <grammar-dir>   # directory containing pom.xml\nmvn clean test\n```\n\n**Test all grammars:**\n\n```sh\ncd <repo-root>\nmvn clean test\n```\n\n**Test only grammars changed in a PR:**\n\n```sh\n_scripts/maven.sh <before-git-sha> <after-git-sha>\n```\n\n### Common Maven test failure: \"no errors found, but errors file exists\"\n\nThis happens when zero-length `.errors` files (generated by the Trash Toolkit test runner)\nare left in the examples directory. The Maven plugin treats any `.errors` file as a baseline\nthat expects parse failures, so if parsing succeeds it fails the test.\n\nFix: delete only the zero-length `.errors` files from the test directory (check `pom.xml` for\n`<exampleFiles>` to confirm the directory; default is `examples/`):\n\n```sh\nfind examples/ -name \"*.errors\" -size 0 -delete\n```\n\nThis is safer than `git clean -f .`, which would remove *all* untracked files (including any\nnew test inputs you've added but not yet staged with `git add`).\n\n### Common Maven test failure: unexpected file extensions in examples/\n\nIf people add test inputs or documentation into `examples/` with extensions that the plugin\ndoesn't expect, the plugin may try to parse them and fail. This is caused by not specifying\n`<testFileExtension>` in `pom.xml`. Check the `pom.xml` for that element; if it's absent,\nthe plugin will attempt to parse every file in the examples directory.\n\n## Checking for Ambiguity (Trash Toolkit / C# target)\n\nThe generated C# test harness is in `.../Generated-CSharp/`.\n\n**Build** (only needed once, or after grammar changes):\n\n```sh\ncd Generated-CSharp\nbash build.sh\n```\n\n**Check a single file for ambiguity:**\n\nUsing the built binary directly:\n\n```sh\n./bin/Debug/net10.0/Test.exe --ambig <file>\n```\n\nThe `--ambig` flag enables ANTLR's profiling mode. After parsing, it reports every\nATN decision where more than one alternative was viable for the actual input (a true\ngrammar ambiguity). For each ambiguity it prints all distinct parse trees, one per\nline, prefixed with `d=<decision>.a=<alt>` (e.g. `d=195.a=1`, `d=195.a=2`).\n\n**Restrict output to specific decisions:**\n\n```sh\n./bin/Debug/net10.0/Test.exe --ambig=195,42 <file>\n```\n\n**Limit the number of parse trees returned:**\n\n```sh\n./bin/Debug/net10.0/Test.exe --ambig --limit=4 <file>\n```\n\n**Using trparse/trtree to show ambiguities:**\n\n```sh\ndotnet trash parse --ambig <file> | dotnet trash tree\n```\n\n<!-- File: _scripts/antlr4-tools/README.md (Tokens: ~1732 | Category: plugin-manifest) -->\n# antlr4-tools\n\nTools to run antlr4 w/o needing to install java or antlr4! The only requirement is Python3, which is typically installed on all developer machines on all operating systems. \n \n## Install\n\n```bash\n$ pip install antlr4-tools\n```\n\nThat creates `antlr4` and `antlr4-parse` executables. On Windows, of course, this doesn't just work. You need to add the `...\\local-packages\\python38\\scripts` dir to your `PATH`, which itself might require a fun reboot or perhaps reinstall of the OS. haha.\n\n### Windows-specific issues\n\nOn Windows, the `pip` command doesn't just work---you need to add the `...\\local-packages\\python38\\scripts` dir to your `PATH`, which itself might require a fun reboot.  If you use WSL on Windows, then the pip install will also properly at the scripts directly (if you run from bash shell).\n\n\n1. Go to the Microsoft Store\n2. Search in Microsoft Store for Python\n3. Select the newest version of Python (3.10).\n4. Click the \"Get\" button. Store installs python and pip at \"c:\\Users...\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe\" and \"c:\\Users...\\AppData\\Local\\Microsoft\\WindowsApps\\pip.exe\", respectively. And, it updates the search path immediately with the install.\n5. Open a \"cmd\" terminal.\n6. You can now type \"python\" and \"pip\", and \"pip install antlr4-tools\". 7. Unfortunately, it does not add that to the search path.\n7. Update the search path to contain `c:\\Users...\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p8\\LocalCache\\local-packages\\Python310\\Scripts`. You may need to install MSYS2, then do a `find /c/ -name antlr4.exe 2> /dev/null` and enter that path.\n8. Or, you can set up an alias to antlr4.exe on that path.\n\nThe good news is that the ANTLR4 Python tool downloads the ANTLR jar in a standard location, and you don't need to do that manually. It's also possible to go in a browser, go to python.org, and download the python package. But, it's likely you will need to update the path for antlr4.exe as before.\n\n## First run will install Java and ANTLR\n\nIf needed, `antlr4` will download and install Java 11 and the latest ANTLR jar:\n\n```bash\n$ antlr4 \nDownloading antlr4-4.11.1-complete.jar\nANTLR tool needs Java to run; install Java JRE 11 yes/no (default yes)? y\nInstalled Java in /Users/parrt/.jre/jdk-11.0.15+10-jre; remove that dir to uninstall\nANTLR Parser Generator  Version 4.11.1\n -o ___              specify output directory where all output is generated\n -lib ___            specify location of grammars, tokens files\n...\n```\n\nTo override the version of ANTLR jar used, you can pass a `-v <version>` argument or set `ANTLR4_TOOLS_ANTLR_VERSION` environment variable:\n\n```bash\n$ antlr4 -v 4.9.3\nANTLR Parser Generator  Version 4.9.3\n -o ___              specify output directory where all output is generated\n -lib ___            specify location of grammars, tokens files\n...\n$ ANTLR4_TOOLS_ANTLR_VERSION=4.10.1 antlr4\nANTLR Parser Generator  Version 4.10.1\n -o ___              specify output directory where all output is generated\n -lib ___            specify location of grammars, tokens files\n...\n```\n\n## Running ANTLR tool on grammars\n\nThe `antlr4` command forwards all arguments (besides `-v` mentioned above) to the actual ANTLR tool command:\n\n```bash\n$ antlr4 JSON.g4 \n$ ls JSON*.java\nJSONBaseListener.java  JSONLexer.java         JSONListener.java      JSONParser.java\n$ antlr4 -Dlanguage=Python3 -visitor JSON.g4\n$ ls JSON*.py\nJSONLexer.py     JSONListener.py  JSONParser.py    JSONVisitor.py\n```\n\n## Parsing using interpreter\n\nThe `antlr4-parse` command requires ANTLR 4.11 and above (but any version of ANTLR works for the plain `antlr4` command).  It accepts the same `-v` argument or environment variable to override the ANTLR jar version used.  (Note: `^D` means control-D and indicates \"end of input\" on Unix but use `^Z` on Windows.)\n\nLet's play with a simple grammar:\n\n```\ngrammar Expr;\nprog:\texpr EOF ;\nexpr:\texpr ('*'|'/') expr\n    |\texpr ('+'|'-') expr\n    |\tINT\n    |\t'(' expr ')'\n    ;\nNEWLINE : [\\r\\n]+ -> skip;\nINT     : [0-9]+ ;\n```\n\nTo parse and get the parse tree in text form, use:\n\n```bash\n$ antlr4-parse Expr.g4 prog -tree\n10+20*30\n^D\n(prog:1 (expr:2 (expr:3 10) + (expr:1 (expr:3 20) * (expr:3 30))) <EOF>)\n```\n\nHere's how to get the tokens and trace through the parse:\n\n```bash\n$ antlr4-parse Expr.g4 prog -tokens -trace\n10+20*30\n[@0,0:1='10',<INT>,1:0]\n[@1,2:2='+',<'+'>,1:2]\n[@2,3:4='20',<INT>,1:3]\n[@3,5:5='*',<'*'>,1:5]\n[@4,6:7='30',<INT>,1:6]\n[@5,9:8='<EOF>',<EOF>,2:0]\nenter   prog, LT(1)=10\nenter   expr, LT(1)=10\nconsume [@0,0:1='10',<8>,1:0] rule expr\nenter   expr, LT(1)=+\nconsume [@1,2:2='+',<3>,1:2] rule expr\nenter   expr, LT(1)=20\nconsume [@2,3:4='20',<8>,1:3] rule expr\nenter   expr, LT(1)=*\nconsume [@3,5:5='*',<1>,1:5] rule expr\nenter   expr, LT(1)=30\nconsume [@4,6:7='30',<8>,1:6] rule expr\nexit    expr, LT(1)=<EOF>\nexit    expr, LT(1)=<EOF>\nexit    expr, LT(1)=<EOF>\nconsume [@5,9:8='<EOF>',<-1>,2:0] rule prog\nexit    prog, LT(1)=<EOF>\n```\n\nHere's how to get a visual tree view:\n\n```bash\n$ antlr4-parse Expr.g4 prog -gui\n10+20*30\n```\n\nThe following will pop up in a Java-based GUI window:\n\n<img src=\"images/parse-tree.png\" width=\"300\">\n\nOn real grammars, it can be useful to get decision-making profiling info:\n\n```bash\n$ antlr4-parse JavaLexer.g4 JavaParser.g4 compilationUnit -profile dump.csv T.java\n$ open /tmp/dump.csv \n$ head -5 /tmp/dump.csv \nRule,Invocations,Time (ms),Total k,Max k,Ambiguities,DFA cache miss\ncompilationUnit:0,1,0.164791,1,1,0,1\ncompilationUnit:1,42,1.106583,42,1,0,2\ncompilationUnit:2,2,1.73675,2,1,0,2\ncompilationUnit:3,1,3.969,1,1,0,1\n```\n</yakaai_skills>"}