Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Earley's Algorithm

created by fibonaci

(idea) by fibonaci (2.7 y) (print)   ?   (I like it!) Sun Oct 20 2002 at 20:29:44

A revolutionary parsing algorithm for context-free grammars, published in 1986 by Jay Earley. It has the ability to accept or reject any input for a grammar correctly. With a small augmentation, it can also extract all possible parse trees for that input.

It operates on a set of parsing states, which include the following: The rule: This is a standard context-free production. The dot: A position within the rule that indicates how much of the text of that rule has been seen so far. The reference: A pointer to the set which generated this rule.

The algorithm works as follows:

Start with a "start state," usually something like S → statement. For each item in the current set (where capitals represent nonterminals, and lowercase terminals, and • the dot):

If it matches "A → P • Q R", then add all rules which match "Q → S" to the current set (unless it's already there). In english, add all rules whose left side are the same as the nonterminal to the right of the dot. This stage is called the "Predictor."

If it matches "A → P • q R" and the next input symbol matches q, then add "A → P q • R" to the following set. That is, if we're expecting a terminal, find out if the input matches what we're expecting. This stage is called the "Scanner."

If it matches "A → R •" then add all items from this rule's reference set matching "B → P • A Q" to the current set as "B → P A • Q". Basically, if we've matched an entire rule, update all rules expecting the nonterminal we completed. This stage is called the "Completer."

If the input has been exhausted, and the final set contains something that would complete your start state (eg. "S → statement •", then the input is accepted. Otherwise it is rejected.

An earley parser that shows the parse trees can be found at http://fibonaci.babylonia.flatirons.org/earley.html.


printable version
chaos

context-free grammar blab! context-free language Rammstein
algorithm parser Guide to Chord Formation : Appendix B : List of All Major and Minor Triads Perl 6
pointer Parse
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Drink up!
The Tesla Coil made me cry, but I got a free lunch out of it.
FINALLY, a New Orleans gathering: music, mayhem, beer snobs, and Bourbon Street
Chihiro Iwasaki
New York subway
CIA World Factbook - Hell
supernova
Your first writeup will be nuked: Don't give up
Kim Il Sung
Morrowind
Miami Herald, 2/13/96
Politeness is always in order
There's nothing noble about being a soldier
Look, look! I can write inane bullshit too!
New Writeups
trixingee
Dungeon Mastering for the first time(idea)
Netrat0
It's Called Subtext, Honey(person)
eyeofthebeholder
The Dragon(idea)
Heitah
consist, comprise, constitute, or compose(idea)
Meezzio
Gotlandssnus(thing)
argv
Astral Plane(idea)
Madara
One Winged Angel(fiction)
Tom Rook
Talk is cheap(poetry)
shaogo
Adelle Davis(person)
Aerobe
race car g sfjsgsd(poetry)
Binah
Dream Log: July 5, 2008(dream)
StrawberryFrog
Forgotten things in space(idea)
antigravpussy
velvet revolution fairy tale(idea)
Heitah
Nerve agent VX(thing)
Pavlovna
shite(idea)
This page courtesy of The Everything Development Company