Описание тега left-recursion
A special kind of recursion, defined through a particular grammar property: grammar is left-recursive if we can find some non-terminal A which will eventually derive a sentential form with itself as the left-symbol.
Left-recursive
grammar can be immediate or indirect:
Immediate left recursion
Immediate left recursion occurs in rules of the form
A → Aa | b
where a
and b
are sequences of nonterminals and terminals, and b
doesn't start with A
. For example, the rule
Expr → Expr + Term
is immediately left-recursive.
Indirect left recursion
Indirect left recursion in its simplest form could be defined as:
A → Ba | C
B → Ab | D
possibly giving the derivation A ⇒ Ba ⇒ Aba ⇒ ...
More generally, for the nonterminals A0
, A1
,..., An
, indirect left recursion can be defined as being of the form:
A0 → A1a_1 | ...
A1 → A2a_2 | ...
...
An → A0a_n+1 | ...
where a_1
, a_2
,..., a_n
are sequences of nonterminals and terminals.
Source: Wikipedia