Skip to content

GrunWin.exe

Thad Ryker edited this page Mar 19, 2020 · 5 revisions

The GrunWin exe is a graphical tool for testing Antlr4 grammars. It accepts a number of optional command line flags that can be passed in if you wish it to load a specific grammar, rule or source file. The usage is as follows

GrunWin.exe [Option flags]

The supported command line option flags are as follows:

--grammar <grammar name> = The name of the grammar you wish to load.

--rule <rule name> = The parser rule you wish to load and parse with.

--file <file name> = The source file you wish to load for parsing.

--SLL = Turns on Simple LL prediction mode for parsing.

--diagnostics = Turns on LL exact ambiguous detection prediction mode for parsing. (Note that if you specify this option and the SLL option, SLL will take precedence)

--encoding <encoding name> = Instructs GrunWin to use the specified file encoding when loading the specified input file. If no input file was specified, this option gets ignored.

--trace = Turns on trace mode, demonstrating the the parser's logic when evaluating the tokens and rules.

--help = Displays the usage help message for the tool.

--version = Displays version information for the tool.

The GrunWin program features a robust text editor, a list of parser erorrs and tabs for display of lexer tokens, the parse tree and trace events. The editor window supports a heuristic syntax highlighting system that will attempt to identify and color keywords, literals and comments in your source code. GrunWin uses a naive token based approach to syntax highlighting, so don't expect anything super fancy. Most panels in the editor are interactive allowing you to select the source in the text editor that corresponds to the entity you are selecting, whether that is an error, lexer token or parse tree node.

You may drag and drop grammar assemblies or source files onto the text editor to quickly load new grammars or source. Once a grammar is loaded, GrunWin will monitor the source assembly for changes and automatically reload the grammar as needed. The tool is designed to allow you leave it open while you work on and recompile your grammar assembly.

The editor also supports custom syntax highlighting guides. Anyone may implement a custom syntax guide to specify custom colors for the various tokens in their grammar. To do this you simply need to Implement the ISyntaxGuide interface from the Edgerunner.ANTLR4.Tools.Common.dll assembly. The moment a new grammar is loaded, GrunWin will first search all assemblies in the same directory as the grammar assembly, looking for any implementations of ISyntaxGuide. It will then look in the "Guides" folder within the GrunWin installation folder and load any guides found there as well. It will then search all ISyntaxGuides found for one that matches the current grammar. GrunWin will use the first syntax guide it finds for the grammar. Syntax guides will also be monitored and reloaded the moment they change, just as grammar assemblies.

Clone this wiki locally