Hi.
To figure out what rule causes the conflict, add the `-rall' option to bison:
Code:
$ bison -rall gram.y
gram.y: conflicts: 1 shift/reduce
After that there should be file gram.output. Here is the relevant portion of it:
Code:
State 44 conflicts: 1 shift/reduce
....
state 5
11 symbol: SYMBOL .
$default reduce using rule 11 (symbol)
....
state 44
3 s_expr: . NUMBER
4 | . symbol
5 | . LPAREN SYMBOL s_expr_list RPAREN
5 | LPAREN SYMBOL . s_expr_list RPAREN
6 | . LPAREN COND condition s_expr s_expr RPAREN
7 | . LPAREN let_section s_expr RPAREN
8 | . LPAREN FUNC s_expr s_expr RPAREN
9 | . QUIT
10 | . error
11 symbol: . SYMBOL
11 | SYMBOL . [SYMBOL, RPAREN]
20 s_expr_list: . s_expr s_expr_list
21 | . s_expr
error shift, and go to state 3
NUMBER shift, and go to state 4
SYMBOL shift, and go to state 5
LPAREN shift, and go to state 6
QUIT shift, and go to state 7
SYMBOL [reduce using rule 11 (symbol)]
RPAREN reduce using rule 11 (symbol)
s_expr go to state 17
symbol go to state 9
s_expr_list go to state 18
....
The syntax of this file is outlined
here.
If I interpret it correctly, the conflict here is when there is SYMBOL on top of the stack and another SYMBOL in input stream. Parser can not decide whether to shift SYMBOL to the stack and then interpret it as `symbol' or to reduce SYMBOL on the stack to `symbol' (and keep input stream untouched).
I can't suggest any fix yet, but at least using this method you may analyze further conflicts. Anyway, your grammar looks overcomplicated to me. It looks like you try to impose too much structure on a quite structureless s-expressions, which is hard to do unambiguously (when parsing). Another approach would be to construct an abstract syntax tree of the s-expression using simple parser and then evaluate/analyze it using a dedicated recursive function.
Finally, I'd recommend to replace right recursion by left recursion, for example
Code:
arg_list: arg_list symbol { $$ = argList($1,$2); }
|symbol{ $$ = argList($1,0); }
;
This way parser can process arbitrarily long sequences using bounded stack space.