Advantages
Recognition using the GLR algorithm has the same worst-case time complexity as the CYK algorithm and Earley algorithm: O(n3). However, GLR carries two additional advantages:
- The time required to run the algorithm is proportional to the degree of nondeterminism in the grammar: on deterministic grammars the GLR algorithm runs in O(n) time (this is not true of the Earley and CYK algorithms, but the original Earley algorithms can be modified to ensure it)
- The GLR algorithm is "on-line" – that is, it consumes the input tokens in a specific order and performs as much work as possible after consuming each token.
In practice, the grammars of most programming languages are deterministic or "nearly deterministic", meaning that any nondeterminism is usually resolved within a small (though possibly unbounded) number of tokens. Compared to other algorithms capable of handling the full class of context-free grammars (such as Earley or CYK), the GLR algorithm gives better performance on these "nearly deterministic" grammars, because only a single stack will be active during the majority of the parsing process.
GLR can be combined with the LALR(1) algorithm, in a hybrid parser, allowing still higher performance.
Read more about this topic: GLR Parser
Famous quotes containing the word advantages:
“But there are advantages to being elected President. The day after I was elected, I had my high school grades classified Top Secret.”
—Ronald Reagan (b. 1911)
“There are great advantages to seeing yourself as an accident created by amateur parents as they practiced. You then have been left in an imperfect state and the rest is up to you. Only the most pitifully inept child requires perfection from parents.”
—Frank Pittman (20th century)
“... there are no chains so galling as the chains of ignoranceno fetters so binding as those that bind the soul, and exclude it from the vast field of useful and scientific knowledge. O, had I received the advantages of early education, my ideas would, ere now, have expanded far and wide; but, alas! I possess nothing but moral capabilityno teachings but the teachings of the Holy Spirit.”
—Maria Stewart (18031879)