Bison, action at the beginning of a rule -


i'm trying build grammar subset of c language. in of rules have following (pnode being pointer defined in union):

rule : { $<pnode>$ = $<pnode>0; } rest 

however, after reading bison docs, seems action omitted, because $<pnode>0 refers the previous symbol in stack. right?

it great able omit action, because it's causing shift/reduce conflicts otherwise not appear.

this code duplicates top value on value stack (making duplicate $1 rule), possible unneccessary -- if code uses either of duplicated values can changed instead use unduplicated value, , if none of code attempts modify value on stack (possible, rare , considered poor style).

the problem comes in actions the rest -- if refer $0 , $-1 may have problem. if refer $0 (and don't modify it) you're fine removing action.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -