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 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.
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
- 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 · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "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." Aho, Alfred; Ullman, Jeffrey (1972). 2026-11-17. https://en.wikipedia.org/w/index.php?oldid=1371759853. Accessed 24 November 2026.
Chicago "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." Aho, Alfred; Ullman, Jeffrey (1972). 2026-11-17. https://en.wikipedia.org/w/index.php?oldid=1371759853.
APA Aho, Alfred; Ullman, Jeffrey (1972). (2026). 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. Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1371759853
- A Faster Earley Parser · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "A Faster Earley Parser." McLean, Philippe; Horspool, R. 2026-11-17. https://en.wikipedia.org/wiki/Nigel_Horspool. Accessed 24 November 2026.
Chicago "A Faster Earley Parser." McLean, Philippe; Horspool, R. 2026-11-17. https://en.wikipedia.org/wiki/Nigel_Horspool.
APA McLean, Philippe; Horspool, R. (2026). A Faster Earley Parser. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/Nigel_Horspool
- Practical Earley Parsing · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "Practical Earley Parsing." Aycock, John; Horspool, R. 2026-11-17. https://en.wikipedia.org/wiki/Nigel_Horspool. Accessed 24 November 2026.
Chicago "Practical Earley Parsing." Aycock, John; Horspool, R. 2026-11-17. https://en.wikipedia.org/wiki/Nigel_Horspool.
APA Aycock, John; Horspool, R. (2026). Practical Earley Parsing. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/Nigel_Horspool
- Marpa is now O(n) for Right Recursions · retrieved 2026-05-04 · rev 1371759853
Cite this reference
MLA "Marpa is now O(n) for Right Recursions." Jeffrey Kegler (2010-06-05). 2026-05-04. https://jeffreykegler.github.io/Ocean-of-Awareness-blog/individual/2010/06/marpa-is-now-on-for-right-recursions.html. Accessed 24 November 2026.
Chicago "Marpa is now O(n) for Right Recursions." Jeffrey Kegler (2010-06-05). 2026-05-04. https://jeffreykegler.github.io/Ocean-of-Awareness-blog/individual/2010/06/marpa-is-now-on-for-right-recursions.html.
APA Jeffrey Kegler (2010-06-05). (2026). Marpa is now O(n) for Right Recursions. Retrieved November 24, 2026, from https://jeffreykegler.github.io/Ocean-of-Awareness-blog/individual/2010/06/marpa-is-now-on-for-right-recursions.html
- What is the Marpa algorithm? · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "What is the Marpa algorithm?." Kegler, Jeffrey (2011-11-18). 2026-11-17. http://blogs.perl.org/users/jeffrey_kegler/2011/11/what-is-the-marpa-algorithm.html. Accessed 24 November 2026.
Chicago "What is the Marpa algorithm?." Kegler, Jeffrey (2011-11-18). 2026-11-17. http://blogs.perl.org/users/jeffrey_kegler/2011/11/what-is-the-marpa-algorithm.html.
APA Kegler, Jeffrey (2011-11-18). (2026). What is the Marpa algorithm?. Retrieved November 24, 2026, from http://blogs.perl.org/users/jeffrey_kegler/2011/11/what-is-the-marpa-algorithm.html
- Kegler, Jeffrey (2013-05-22), Marpa, A practical general parser: the recognizer Wikipedia revision 1371759853, retrieved 2026-11-18 · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "Kegler, Jeffrey (2013-05-22), Marpa, A practical general parser: the recognizer Wikipedia revision 1371759853, retrieved 2026-11-18." Kegler, Jeffrey (2013-05-22), Marpa, A practical general parser: the recognizer Wikipedia revision 1371759853, retrieved. 2026-11-17. https://www.academia.edu/10341474/Marpa_A_practical_general_parser_the_recognizer. Accessed 24 November 2026.
Chicago "Kegler, Jeffrey (2013-05-22), Marpa, A practical general parser: the recognizer Wikipedia revision 1371759853, retrieved 2026-11-18." Kegler, Jeffrey (2013-05-22), Marpa, A practical general parser: the recognizer Wikipedia revision 1371759853, retrieved. 2026-11-17. https://www.academia.edu/10341474/Marpa_A_practical_general_parser_the_recognizer.
APA Kegler, Jeffrey (2013-05-22), Marpa, A practical general parser: the recognizer Wikipedia revision 1371759853, retrieved. (2026). Kegler, Jeffrey (2013-05-22), Marpa, A practical general parser: the recognizer Wikipedia revision 1371759853, retrieved 2026-11-18. Retrieved November 24, 2026, from https://www.academia.edu/10341474/Marpa_A_practical_general_parser_the_recognizer
- Kegler, Jeffrey (2023-01-27), Marpa, A practical general parser: the recognizer (3rd ed.) Wikipedia revision 1371759853, retrieved 2026-11-18 · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "Kegler, Jeffrey (2023-01-27), Marpa, A practical general parser: the recognizer (3rd ed.) Wikipedia revision 1371759853, retrieved 2026-11-18." Kegler, Jeffrey (2023-01-27), Marpa, A practical general parser: the recognizer (3rd ed. 2026-11-17. https://arxiv.org/abs/1910.08129. Accessed 24 November 2026.
Chicago "Kegler, Jeffrey (2023-01-27), Marpa, A practical general parser: the recognizer (3rd ed.) Wikipedia revision 1371759853, retrieved 2026-11-18." Kegler, Jeffrey (2023-01-27), Marpa, A practical general parser: the recognizer (3rd ed. 2026-11-17. https://arxiv.org/abs/1910.08129.
APA Kegler, Jeffrey (2023-01-27), Marpa, A practical general parser: the recognizer (3rd ed. (2026). Kegler, Jeffrey (2023-01-27), Marpa, A practical general parser: the recognizer (3rd ed.) Wikipedia revision 1371759853, retrieved 2026-11-18. Retrieved November 24, 2026, from https://arxiv.org/abs/1910.08129
- The Marpa parser · retrieved 2026-05-04 · rev 1371759853
Cite this reference
MLA "The Marpa parser." Jeffrey Kegler. 2026-05-04. https://jeffreykegler.github.io/Marpa-web-site/. Accessed 24 November 2026.
Chicago "The Marpa parser." Jeffrey Kegler. 2026-05-04. https://jeffreykegler.github.io/Marpa-web-site/.
APA Jeffrey Kegler. (2026). The Marpa parser. Retrieved November 24, 2026, from https://jeffreykegler.github.io/Marpa-web-site/
- Parsing: a timeline -- V3.1 · retrieved 2026-05-04 · rev 1371759853
Cite this reference
MLA "Parsing: a timeline -- V3.1." Jeffrey Kegler (2023-07-06). 2026-05-04. https://jeffreykegler.github.io/personal/timeline_v3. Accessed 24 November 2026.
Chicago "Parsing: a timeline -- V3.1." Jeffrey Kegler (2023-07-06). 2026-05-04. https://jeffreykegler.github.io/personal/timeline_v3.
APA Jeffrey Kegler (2023-07-06). (2026). Parsing: a timeline -- V3.1. Retrieved November 24, 2026, from https://jeffreykegler.github.io/personal/timeline_v3
- 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 · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "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." John E. 2026-11-17. https://archive.org/details/introductiontoau00hopc. Accessed 24 November 2026.
Chicago "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." John E. 2026-11-17. https://archive.org/details/introductiontoau00hopc.
APA John E. (2026). 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. Retrieved November 24, 2026, from https://archive.org/details/introductiontoau00hopc
- 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 · retrieved 2012-09-11 · rev 1371759853
Cite this reference
MLA "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." Earley, Jay (1968). 2012-09-11. https://web.archive.org/web/20170922004954/http://reports-archive.adm.cs.cmu.edu/anon/anon/usr/ftp/scan/CMU-CS-68-earley.pdf. Accessed 24 November 2026.
Chicago "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." Earley, Jay (1968). 2012-09-11. https://web.archive.org/web/20170922004954/http://reports-archive.adm.cs.cmu.edu/anon/anon/usr/ftp/scan/CMU-CS-68-earley.pdf.
APA Earley, Jay (1968). (2012). 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. Retrieved November 24, 2026, from https://web.archive.org/web/20170922004954/http://reports-archive.adm.cs.cmu.edu/anon/anon/usr/ftp/scan/CMU-CS-68-earley.pdf
- 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 · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "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." Tomita, Masaru (April 17, 2013). 2026-11-17. https://books.google.com/books?id=DAjkBwAAQBAJ&q=Tomita%20Efficient%20Parsing%20for%20natural%20Language&pg=PA74. Accessed 24 November 2026.
Chicago "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." Tomita, Masaru (April 17, 2013). 2026-11-17. https://books.google.com/books?id=DAjkBwAAQBAJ&q=Tomita%20Efficient%20Parsing%20for%20natural%20Language&pg=PA74.
APA Tomita, Masaru (April 17, 2013). (2026). 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. Retrieved November 24, 2026, from https://books.google.com/books?id=DAjkBwAAQBAJ&q=Tomita%20Efficient%20Parsing%20for%20natural%20Language&pg=PA74
- SPPF-Style Parsing From Earley Recognizers · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "SPPF-Style Parsing From Earley Recognizers." Scott, Elizabeth (April 1, 2008). 2026-11-17. https://doi.org/10.1016%2Fj.entcs.2008.03.044. Accessed 24 November 2026.
Chicago "SPPF-Style Parsing From Earley Recognizers." Scott, Elizabeth (April 1, 2008). 2026-11-17. https://doi.org/10.1016%2Fj.entcs.2008.03.044.
APA Scott, Elizabeth (April 1, 2008). (2026). SPPF-Style Parsing From Earley Recognizers. Retrieved November 24, 2026, from https://doi.org/10.1016%2Fj.entcs.2008.03.044
- 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 · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "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." Earley, Jay (1968). 2026-11-17. https://web.archive.org/web/20170922004954/http://reports-archive.adm.cs.cmu.edu/anon/anon/usr/ftp/scan/CMU-CS-68-earley.pdf. Accessed 24 November 2026.
Chicago "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." Earley, Jay (1968). 2026-11-17. https://web.archive.org/web/20170922004954/http://reports-archive.adm.cs.cmu.edu/anon/anon/usr/ftp/scan/CMU-CS-68-earley.pdf.
APA Earley, Jay (1968). (2026). 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. Retrieved November 24, 2026, from https://web.archive.org/web/20170922004954/http://reports-archive.adm.cs.cmu.edu/anon/anon/usr/ftp/scan/CMU-CS-68-earley.pdf
- An efficient context-free parsing algorithm · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "An efficient context-free parsing algorithm." Earley, Jay (1970), "An efficient context-free parsing algorithm" (PDF) , Communications of the ACM , 13 (2): 94– 102, d. 2026-11-17. https://web.archive.org/web/20040708052627/http://www-2.cs.cmu.edu/afs/cs.cmu.edu/project/cmt-55/lti/Courses/711/Class-notes/p94-earley.pdf. Accessed 24 November 2026.
Chicago "An efficient context-free parsing algorithm." Earley, Jay (1970), "An efficient context-free parsing algorithm" (PDF) , Communications of the ACM , 13 (2): 94– 102, d. 2026-11-17. https://web.archive.org/web/20040708052627/http://www-2.cs.cmu.edu/afs/cs.cmu.edu/project/cmt-55/lti/Courses/711/Class-notes/p94-earley.pdf.
APA Earley, Jay (1970), "An efficient context-free parsing algorithm" (PDF) , Communications of the ACM , 13 (2): 94– 102, d. (2026). An efficient context-free parsing algorithm. Retrieved November 24, 2026, from https://web.archive.org/web/20040708052627/http://www-2.cs.cmu.edu/afs/cs.cmu.edu/project/cmt-55/lti/Courses/711/Class-notes/p94-earley.pdf
- 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 · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "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." Jurafsky, D. 2026-11-17. https://books.google.com/books?id=fZmj5UNK8AQC. Accessed 24 November 2026.
Chicago "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." Jurafsky, D. 2026-11-17. https://books.google.com/books?id=fZmj5UNK8AQC.
APA Jurafsky, D. (2026). 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. Retrieved November 24, 2026, from https://books.google.com/books?id=fZmj5UNK8AQC
- A general context-free parsing algorithm running in linear time on every LR( k ) grammar without using lookahead · retrieved 2026-11-17 · rev 1371759853
Cite this reference
MLA "A general context-free parsing algorithm running in linear time on every LR( k ) grammar without using lookahead." a b Leo, Joop M. 2026-11-17. https://en.wikipedia.org/wiki/Theoretical_Computer_Science_(journal). Accessed 24 November 2026.
Chicago "A general context-free parsing algorithm running in linear time on every LR( k ) grammar without using lookahead." a b Leo, Joop M. 2026-11-17. https://en.wikipedia.org/wiki/Theoretical_Computer_Science_(journal).
APA a b Leo, Joop M. (2026). A general context-free parsing algorithm running in linear time on every LR( k ) grammar without using lookahead. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/Theoretical_Computer_Science_(journal)
Cite this article
MLA
"Earley parser." encyclopegia.org, 2026, https://encyclopegia.org/wiki/earley-parser. Accessed 24 November 2026.
Chicago
"Earley parser." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/earley-parser.
APA
encyclopegia.org. (2026). Earley parser. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/earley-parser
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON