Relationship To Other Parsers
An operator-precedence parser is a simple shift-reduce parser that is capable of parsing a subset of LR(1) grammars. More precisely, the operator-precedence parser can parse all LR(1) grammars where two consecutive nonterminals never appear in the right-hand side of any rule.
Operator-precedence parsers are not used often in practice; however they do have some properties that make them useful within a larger design. First, they are simple enough to write by hand, which is not generally the case with more sophisticated shift-reduce parsers. Second, they can be written to consult an operator table at run time, which makes them suitable for languages that can add to or change their operators while parsing. (An example is Haskell, which allows user-defined infix operators with custom associativity and precedence; consequentially, an operator-precedence parser must be run on the program after parsing of all referenced modules.)
Perl 6 sandwiches an operator-precedence parser between two Recursive descent parsers in order to achieve a balance of speed and dynamism. This is expressed in the virtual machine for Perl 6, Parrot, as the Parser Grammar Engine (PGE). GCC's C and C++ parsers, which are hand-coded recursive descent parsers, are both sped up by an operator-precedence parser that can quickly examine arithmetic expressions. Operator precedence parsers are also embedded within compiler compiler-generated parsers to noticeably speed up the recursive descent approach to expression parsing.
Read more about this topic: Operator-precedence Parser
Famous quotes containing the words relationship to and/or relationship:
“Poetry is above all a concentration of the power of language, which is the power of our ultimate relationship to everything in the universe.”
—Adrienne Rich (b. 1929)
“The proper aim of education is to promote significant learning. Significant learning entails development. Development means successively asking broader and deeper questions of the relationship between oneself and the world. This is as true for first graders as graduate students, for fledging artists as graying accountants.”
—Laurent A. Daloz (20th century)