Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to understand this EBNF Pascal Definition

Tags:

pascal

ebnf

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.

like image 447
Leandro Caniglia Avatar asked Oct 17 '22 08:10

Leandro Caniglia


1 Answers

Since EBNF doesn't have ordered choices, the longest match is often used to determine which rules apply.

like image 91
Uran Avatar answered Oct 21 '22 01:10

Uran