HOWTOs - Creating and editing grammars
To create a grammar, first execute the Create and add a grammar file on the rules project. The grammar will be associated to a file with extension .fcg.
Double click on the grammar file in the rules project (circled in red in the image below) and the empty grammar editor will open.
A grammar is a list of rules. To add a new rule to the grammar, follow the instructions below:
The root rule is the rule that is invoked when a given target source file is to be parsed. In order to know which root rule reads which target source file, the rule is associated to a file extension. In this example, the extension is abc: this means that the target files having name filename.abc will be parsed by this rule.
Once added, the rule will look like the picture below. The red dotted rectangle means that this rule is incomplete because no rule elements have been added yet:
Rule elements (fields, keywords, references, repetitions, choices and operators) can be addded by selecting the insertion point and opening the right-click menu. Insertion points can be the dotted red-box or any arrow in the diagram. In the picture below, the insertion points have been evicented with a purple dot. Once selected the insertion point and selected the type of element from the menu, the new grammar element will be created and placed at that position. If the grammar element has some configuration parameters, a dialog box will pop up immediately:
Rule parameters can be edited by right-clicking their icon and selecting Edit or simply by double clicking them. To delete them, select and click on Delete or press the shortcut DEL.
To add a branch to a choice rule, right click on the diamond icon and select Add branch; to add the empty choice branch select Activate empty choice branch.
To delete a branch, select the entire branch content and right-click Delete or press the shortcut DEL.