I'm implementing a Pascal parser from this EBNF defintion. There is something I don't understand in the following specifications:
variable
entire-variable | component-variable | referenced-variable
entire-variable
variable-identifier | field-identifier
component-variable
indexed-variable | field-designator | file-buffer
field-designator
record-variable "." field-identifier
Assume we want to apply the variable
production on a.b[0]
. Since a
conforms to the entire-variable
production, this will prevent component-variable
from detecting the field-designator
a.b
and therefore the .
following a
will stop the parser.
Since EBNF doesn't have ordered choices, the longest match is often used to determine which rules apply.