compiler construction - Operator Precedence Parser: Where do we keep reduced tokens? -


an op precedence parser has stack , input buffer.

i believe after popping, "id" token reduced variable "e".

for every pop of "id" token stack after seeing mathematical operator in input, popped token kept?

if input id+id*id$ , time $ reached, "id"s have been popped. kept?

assuming goal build ast, ids (and other operand tokens such literal constants) put ast node created reduction.

if you're directly evaluating or generating three-address code or ..., answer differ slightly. however, broad outline same: operator-precedence parsing bottom-up parse algorithm in right-hand side of production reduced corresponding non-terminal (on left-hand side of production) when it's last input symbol has been read (and lookahead indicates correct action reduction).


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -