Operator-precedence parser: Difference between revisions

Content deleted Content added
Cmbay (talk | contribs)
m Added a full stop in the middle of a confusing paragraph.
Line 89:
There are alternative ways to apply operator precedence rules which do not involve the Shunting Yard algorithm. One is to build a tree of the original expression, then apply tree rewrite rules to it. Another is the algorithm used in the early FORTRAN I compiler, which is to first fully parenthesise the expression by a trivial macro replacement — inserting a number of parentheses around each operator, such that they lead to the correct precedence when parsed with a 'flat' grammar. (A hack which takes longer to explain properly than to write code for - see below!)
 
<source lang="c">
<pre>
#include <stdio.h>
#include <string.h>
Line 107:
return 0;
}
</presource>
Invoke it as: <pre>
$ cc -o parenthesise parenthesise.c