Talk:Operator-precedence parser

message: The current pseudocode algorithm in the article doesn't correctly handle low-precedence unary operators. For example, "-x^2" is parsed as (-x)^2 instead of -(x^2), which is probably what would be intended. More generally, let "&" be an arbitrary prefix unary operator, and "#" be a binary operator with higher precedence than "&". Then "&x # y" should be parsed as &(x#y) but the posted algorithm parses it as (&x)#y.
Furthermore, suppose "$" is a unary postfix operator with higher precedence than "&". Then "&x$" should be parsed as &(x$) but the algorithm parses it as (&x)$, which is wrong.
Now I'm sure this problem must have been already solved in the field (or in research), but I don't know any references to a correct precedence-climbing algorithm that correctly processes unary prefix and postfix operators. In any case, though, readers should be aware that the current version of the algorithm does not handle the above cases correctly.—Tetracube (talk) 01:19, 8 October 2012 (UTC)
replies: text: P.S. The algorithm explained in the link posted by User:80.254.190.93 does handle unary operators correctly (at least, unary prefix operators). Maybe it should be worked into the article somehow?—Tetracube (talk) 01:45, 8 October 2012 (UTC)
replies: text:  Prefix operators are like binary operators that are missing an operand. Both prefix and postfix operators of any precedence can be handled by precedence climbing. I'll implement your suggestion. Theodore.norvell (talk) 01:42, 11 April 2013 (UTC)
replies: text:  For anyone interested in postfix operators, I've shown how to implement them at http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm . Theodore.norvell (talk) 21:27, 17 March 2014 (UTC)
thread_title:  The posted algorithm doesn't correctly handle low-precedence unary operators 

message: This rule will allow unused (and invalid?) expressions like "- - - 5":
   primary ::= '(' expression ')' | NUMBER | VARIABLE | '-' primary  — Preceding unsigned comment added by Ngocminh.oss (talk • contribs) 08:21, 25 April 2013 (UTC)
thread_title:  Primary 

message: The article begins by telling us that "an operator precedence parser is a bottom-up parser...." A few sentences later we learn: "Edsger Dijkstra's shunting yard algorithm is commonly used to implement operator precedence parsers. Other algorithms include the precedence climbing method and the top down operator precedence method." This article appears to confuse three concepts with each other:
* parsers/parsing algorithms
* grammars
* the class of languages described by a grammar/parsable by an algorithm.
I propose removing "bottom-up" from the first sentence. Subsequent sections need to specify which algorithm is being considered (e.g. "An operator-precedence parser is a simple shift-reduce parser..."). Moreover, an article on operator-precedence parsers should at least name the most common algorithms and link to their corresponding wiki pages.
--Rljacobson (talk) 02:32, 11 August 2017 (UTC)
thread_title:  A bottom-up parser than can be implemented with the top down operator precedence method? 

message: I propose merging Simple precedence parser into Operator-precedence parser. I think the content in Simple precedence parser can easily be explained in the context of Operator-precedence parser, and a merger would not cause any article-size or weighting problems in Operator-precedence parser.Helphelp101 (talk) 22:30, 9 April 2023 (UTC)
thread_title:  Merger proposal