ANTLRWorks: Editor
The Editor
ANTLRWorks displays one editor window per grammar file. The editor is subdivided into zones, as shown in this image:

The main zones are:
- Editor zone: zone where you edit the grammar. It has real-time syntax coloring and various way of displaying errors in the grammar.
- Gutter: the gutter shows the line number, the rule limits and any breakpoint.
- Analysis column: this column shows any error or warning in the grammar.
- Rules list: this list is updated while you edit the grammar. It shows the list of all parser and lexer rules in the grammar. Click on a item in the list to jump to that particular rule. You can also use drag and drop to rearrange the rules in the list (the corresponding piece of grammar will be moved too). The rules can also be grouped: select one or more rules and use the contextual menu to access the Group command.
- Toolbar: provide access to commonly used operations. Move the mouse over each button to have its tooltip displayed.
- Bottom panels: panels containing the syntax diagram, interpreter, debugger, console and other panels to display the result of some operations (i.e. code generation, find usages).
emacs key-bindings
The following emacs key-bindings are implemented in the editor:
|
Key-binding
|
Description
|
|
Control-e
|
Move cursor to end of line
|
|
Control-a
|
Move cursor to beginning of line
|
|
Control-f
|
Move cursor forward
|
|
Control-b
|
Move cursor backward
|
|
Control-p
|
Go up one line
|
|
Control-n
|
Go down one line
|
|
Control-d
|
Delete the character under the cursor
|
|
Control-k
|
Delete characters from cursor position to end of line
|
Auto-completion
Press Control-space to invoke the auto-completion menu: it will display the list of all rules and tokens starting with the same typed prefix. Press Return to insert an item in the text.
Rearrange rules
It is possible to move rule by dragging their name in the rules list. The corresponding text will be moved in the grammar. To move the current rule using the keyboard only, press Control-Up Arrow or Control-Down Arrow to move a rule up or down.
Errors and warnings
ANTLRWorks uses several ways to display errors and warnings in the grammar. Let's take for example a left-recursive rule in a grammar. The following elements are used to indicate this problem (see picture below):
- The analysis status is yellow (warning only). It will be red for errors.
- The analysis column has a blue indicator. Click on that indicator to jump to the corresponding location in the grammar.
- The rule is underlined: moving the mouse over it will display an explanation message

ANTLRWorks proposes for most of the warnings and errors some operations to correct it. To see if an operation is available for a particular error or warning, click in the corresponding element (in this example, the rule name) and wait 1 second: a warning icon will be displayed if an operation is available. Click again on this icon to display the list of operations: click finally on the operation to run. In this example, the operation available for a left-recursive rule is to remove this left-recursion: clicking on the operation displayed below will remove the left recursion.
