Skip to content

Grammar Definition

Ali Afroozeh edited this page May 16, 2022 · 1 revision

Start Nonterminal

The start nonterminal specifies the nonterminal from which the parsing starts. The user can either specify the start nonterminal in the grammar, or when calling the parse method. If the grammar does not specify the start nonterminal and also the user does not pass it to the parse method, an error is thrown.

start Definition = ...
iguanaParser.parse(input)  // When the start nonterminal is not specified, the one from the grammar will be used.
iguanaParser.parse(input, "Definition")

The start nonterminal is desugared into a grammar rule where layout is inserted after and before the nonterminal. For example, the above example is translated into the following rule:

Start(Definition) = Layout Definition Layout

The Start nonterminal will appear as a separate node (the first node) in the parse tree.

Clone this wiki locally