lab06.txt"
with your answers to the numbered questions below.
It should be submitted via the usual submit script, and you must
include both of your names in the file!
/* This file is ex1.ypp */ %% %token ARROW OR SYM ; s: s rule | rule rule: SYM ARROW rlist rlist: rlist OR rhs | rhs rhs: rhs SYM | SYM %%Run it through bison and you should see an error/warning message. 1 What is it? Run as bison -v ex1.ypp and the file ex1.output is produced. It lists the states of the parser's CFSM along with the actions for each state, and if there are conflicts it should appear as multiple actions from the same state & lookahead. 2 Which states have conflicts? Explain the conflicts for each such state, i.e. why is there ambiguity about which action to take? 3 Would more than one lookahead symbol help? Explain!
What I'd recommend you do is to consider the following valid input:
X -> a b Y -> c dwhere X,Y,a,b,c,d are all SYM tokens and -> is an ARROW token. Trace through the parse modelling the stack (which remember contains states as well as grammar symbols) at each step. Determine where you first run into a conflict, and try to figure out why it really happens.
3*(2 - 7)^3 + 2^3/19;
/* This file is ex2.ypp */ %token NUM %token OPA OPM LP RP STOP EXP %% run: res run | res res: exp STOP exp: exp OPA term | term term: term OPM factor | sfactor sfactor: OPA factor | factor factor: NUM | LP exp RP | factor EXP factor %%Run
bison -v ex2.ypp
6
Choose one state with a conflict and
explain why that conflict arises.
7
What, in general, is the problem with
this grammar?