encyclopegia.org

Left recursion

In the formal language theory of computer science, left recursion is a special case of recursion where a string is recognized as part of a language by the fact that it decomposes into a string from that same language (on the left) and a suffix (on the right). For instance, 1+2+3 can be recognized as a sum because it can be broken into 1+2 , also a sum, and {}+3 , a suitable suffix. In terms of context-free grammar, a nonterminal is left-recursive if the leftmost symbol in one of its productions is itself (in the case of direct left recursion) or can be made itself by some sequence of substitutions (in the case of indirect left recursion).

In the formal language theory of computer science, left recursion is a special case of recursion where a string is recognized as part of a language by the fact that it decomposes into a string from that same language (on the left) and a suffix (on the right). For instance, 1+2+3 can be recognized as a sum because it can be broken into 1+2 , also a sum, and {}+3 , a suitable suffix. In terms of context-free grammar, a nonterminal is left-recursive if the leftmost symbol in one of its productions is itself (in the case of direct left recursion) or can be made itself by some sequence of substitutions (in the case of indirect left recursion). void Expression() { Expression(); match('+'); Term(); } and such code would fall into infinite recursion when executed. == Accommodating left recursion in top-down parsing== A formal grammar that contains left recursion cannot be parsed by a LL(k)-parser or other naive recursive descent parser unless it is converted to a weakly equivalent right-recursive form. In contrast, left recursion is preferred for LALR parsers because it results in lower stack usage than right recursion. However, more sophisticated top-down parsers can implement general context-free grammars by use of curtailment. In 2006, Frost and Hafiz described an algorithm which accommodates ambiguous grammars with direct left-recursive production rules. That algorithm was extended to a complete parsing algorithm to accommodate indirect as well as direct left recursion in polynomial time, and to generate compact polynomial-size representations of the potentially exponential number of parse trees for highly ambiguous grammars by Frost, Hafiz and Callaghan in 2007. The authors then implemented the algorithm as a set of parser combinators written in the Haskell programming language.

References

No reference rows published for this article.

Cite this article

MLA

"Left recursion." encyclopegia.org, 2026, https://encyclopegia.org/wiki/left-recursion. Accessed 24 November 2026.

Chicago

"Left recursion." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/left-recursion.

APA

encyclopegia.org. (2026). Left recursion. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/left-recursion

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Morris Cerullo

enwiki · references available

Counting Down the Days

enwiki · references available

Technosoft

enwiki · references available

Christopher Gillberg

enwiki · references available

List of people executed in New Jersey

enwiki · references available

Lee Strobel

enwiki · references available

Magyar Rádió

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1352788040 · 0.5 · snapshot enwiki-001352788040

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.