Operator-precedence parser: Difference between revisions

Content deleted Content added
corrected spelling of Colin Whitby-Strevens' surname
Ahoogen (talk | contribs)
m "Epsilon" is ambiguous in computer science and doesn't point to an obvious entry point for further information for those who are not familiar.
Line 5:
== Relationship to other parsers ==
 
An operator-precedence parser is a simple [[shift-reduce parser]] that is capable of parsing a subset of [[LR parser|LR(1)]] grammars. More precisely, the operator-precedence parser can parse all LR(1) grammars where two consecutive [[nonterminal]]s and [[empty_string|epsilon]] 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 right shift-reduce parsers. Second, they can be written to consult an operator table at [[Run time (program lifecycle phase)|run time]], which makes them suitable for languages that can add to or change their operators while parsing. (An example is [[Haskell (programming language)|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.)