Title:
operator-precedence-parser Download
Description: 1 gives grammar as follows: E [E] E-> T | E+ T T-> F | T* F F-> i (E)
Operator priority table can be constructed as follows:+* () i
+
*
(
)
i
2, the computer indicated above priority, preferential relations machine memory put in two ways 1) Direct storage, 2) as a priority relationship building priority function, here by the students themselves choose a way
3, gives the operator precedence analysis algorithm is as follows:
k: = 1 S [k]: = #
REPEAT read the next input symbol into a medium IF S [k] ∈VT THEN j: = k ELSE j: = k-1 WHILE S [j] a DO BEGIN REPEAT Q: = S [j] IF S [j-1] ∈VT THEN j: = j-1 ELSE j: = j-2 UNTIL S [j] Q to S [j+ 1] ... S [k] is about a normalization N k: = j+1 S [k]: = N END OF WHILE
IF S [j] a OR S [j] a THEN BEGIN k: = k+ 1 S [k]: = a END ELSE ERROR UNTIL a = #
4, according to the given algorithm, using the appropriate data structure to achieve operator priority analysis program
To Search:
File list (Check if you may need any files):
operator precedence parser.cpp