e01.org

Earley parser

In computer science, the Earley parser is an algorithm for parsing strings that belong to a given context-free language. Named after its inventor Jay Earley, it was first introduced in his dissertation in 1968 (and later appeared in abbreviated, more legible form in a journal). It is a chart parser that uses dynamic programming. Earley parsers are appealing because they can parse all context-free languages, unlike LR parsers and LL parsers, which are more typically used in compilers but which can only handle restricted classes of languages. However, the original Earley algorithm contained a bug, and its run time and memory use were high for the computers available at the time it was published. Earley parsing has since become a viable solution, as corrections and optimizations of the algorithm have been found and computers have become far more powerful. Earley parsers perform particularly well when the rules are written left-recursively. Some grammars can be automatically rewritten...

In computer science, the Earley parser is an algorithm for parsing strings that belong to a given context-free language. Named after its inventor Jay Earley, it was first introduced in his dissertation in 1968 (and later appeared in abbreviated, more legible form in a journal). It is a chart parser that uses dynamic programming. Earley parsers are appealing because they can parse all context-free languages, unlike LR parsers and LL parsers, which are more typically used in compilers but which can only handle restricted classes of languages. However, the original Earley algorithm contained a bug, and its run time and memory use were high for the computers available at the time it was published. Earley parsing has since become a viable solution, as corrections and optimizations of the algorithm have been found and computers have become far more powerful. Earley parsers perform particularly well when the rules are written left-recursively. Some grammars can be automatically rewritten so that the Earley algorithm parses the language they describe more efficiently. The worst-case costs of the original Earley algorithm are: O(n) linear time and space for non-right recursive LR(k) grammars, O(n^2) quadratic time and space for unambiguous grammars, O(n^3) cubic time and O(n^2) quadratic space for all other context-free grammars, where n is the length of the parsed string. DECLARE ARRAY S; function INIT(words) S ← CREATE_ARRAY(LENGTH(words) + 1) for k ← from 0 to LENGTH(words) do S[k] ← EMPTY_ORDERED_SET function EARLEY_PARSE(words, grammar) INIT(words) ADD_TO_SET((γ → •S, 0), S[0]) for k ← from 0 to LENGTH(words) do for each state in S[k] do // S[k] can expand during this loop if not FINISHED(state) then if NEXT_ELEMENT_OF(state) is a nonterminal then PREDICTOR(state, k, grammar) // non_terminal else do SCANNER(state, k, words) // terminal else do COMPLETER(state, k) end end return chart procedure PREDICTOR((A → α•Bβ, j), k, grammar) for each (B → γ) in GRAMMAR_RULES_FOR(B, grammar) do ADD_TO_SET((B → •γ, k), S[k]) end procedure SCANNER((A → α•aβ, j), k, words) if k ::= # the start rule ::= "+" | ::= "*" | ::= "1" | "2" | "3" | "4" With the input: 2 + 3 * 4 This is the sequence of state sets: The state (P → S •, 0) represents a completed parse. This state also appears in S(3) and S(1), which are complete sentences.

References

  1. ^ Aho, Alfred; Ullman, Jeffrey (1972). The theory of parsing, translation, and compiling. Vol. 1 . Prentice Hall. p. 321. Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
  2. ^ McLean, Philippe; Horspool, R. Nigel (1996). "A Faster Earley Parser" (PDF) . LNCS . 1060 : 281– 293. Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
  3. ^ Aycock, John; Horspool, R. Nigel (2002). "Practical Earley Parsing" (PDF) . The Computer Journal . 45 (6): 620– 630. CiteSeerX 10.1.1.12.4254 . doi : 10.1093/comjnl/45.6.620 . {{ cite journal }} : Cite uses deprecated parameter |citeseerx= ( help ) Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
  4. ^ Jeffrey Kegler (2010-06-05). "Marpa is now O(n) for Right Recursions" . Retrieved 2026-05-05 . Wikipedia revision 1371759853, retrieved 2026-11-18 · 1777935600.0
  5. ^ Kegler, Jeffrey (2011-11-18). "What is the Marpa algorithm?" . Retrieved 20 August 2013 . Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
  6. ^ Kegler, Jeffrey (2013-05-22), Marpa, A practical general parser: the recognizer Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
  7. ^ Kegler, Jeffrey (2023-01-27), Marpa, A practical general parser: the recognizer (3rd ed.) Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
  8. ^ Jeffrey Kegler. "The Marpa parser" . Retrieved 2026-05-05 . Wikipedia revision 1371759853, retrieved 2026-11-18 · 1777935600.0
  9. ^ Jeffrey Kegler (2023-07-06). "Parsing: a timeline -- V3.1" . Retrieved 2026-05-05 . Wikipedia revision 1371759853, retrieved 2026-11-18 · 1777935600.0
  10. ^ John E. Hopcroft and Jeffrey D. Ullman (1979). Introduction to Automata Theory, Languages, and Computation . Reading/MA: Addison-Wesley. ISBN 978-0-201-02988-8 . p.145 Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
  11. ^ Earley, Jay (1968). An Efficient Context-Free Parsing Algorithm (PDF) . Carnegie-Mellon Dissertation. p. 106. Archived from the original (PDF) on 2017-09-22 . Retrieved 2012-09-12 . Wikipedia revision 1371759853, retrieved 2026-11-18 · 1347404400.0
  12. ^ Tomita, Masaru (April 17, 2013). Efficient Parsing for Natural Language: A Fast Algorithm for Practical Systems . Springer Science and Business Media. p. 74. ISBN 978-1475718850 . Retrieved 16 September 2015 . Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
  13. ^ Scott, Elizabeth (April 1, 2008). "SPPF-Style Parsing From Earley Recognizers" . Electronic Notes in Theoretical Computer Science . 203 (2): 53– 67. doi : 10.1016/j.entcs.2008.03.044 . Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
  14. ^ Earley, Jay (1968). An Efficient Context-Free Parsing Algorithm (PDF) . Carnegie-Mellon Dissertation. Archived from the original (PDF) on 2017-09-22. Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
  15. ^ Earley, Jay (1970), "An efficient context-free parsing algorithm" (PDF) , Communications of the ACM , 13 (2): 94– 102, doi : 10.1145/362007.362035 , S2CID 47032707 , archived from the original (PDF) on 2004-07-08 Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
  16. ^ Jurafsky, D. (2009). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition . Pearson Prentice Hall. ISBN 9780131873216 . Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
  17. ^ a b Leo, Joop M.I.M. (1991), "A general context-free parsing algorithm running in linear time on every LR( k ) grammar without using lookahead", Theoretical Computer Science , 82 (1): 165– 176, doi : 10.1016/0304-3975(91)90180-A , MR 1112117 Wikipedia revision 1371759853, retrieved 2026-11-18 · 1794956400.0
source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Earley parser". 1787896498. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1371759853

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·