Re: bison info doc - precedence in recursive parsing
> On 3 Feb 2019, at 07:50, an...@aakhare.in wrote: > > The first effect of the precedence declarations is to assign precedence > levels to the terminal symbols declared. The second effect is to assign > precedence levels to certain rules: each rule gets its precedence from the > last terminal symbol mentioned in the components. If you write the .output file using --verbose or %verbose, the precedence makes a choice at the parsing dot "." in the case of a shift/reduce conflict, see the Bison manual, sec. 5.2. I thought it was between the lookahead token and the token before the dot, but perhaps Akim can clarify. ___ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison
Re: bison info doc - precedence in recursive parsing
Hi Anand, > Le 3 févr. 2019 à 07:50, a écrit : > > Hello, >in info doc of bison, it is mentioned that rule gets its precendence from > last terminal symbol. > pasted below: > The first effect of the precedence declarations is to assign precedence > levels to the terminal symbols declared. The second effect is to assign > precedence levels to certain rules: each rule gets its precedence from the > last terminal symbol mentioned in the components. > > For below example, how the parsing will happen if above is the case: > > nonterm1 : nonterm2 > | nonterm1 term1 nonterm3 nonterm4 > | nonterm1 term2 nonterm5 nonterm6 > > One more example: > nonterm1 : nonterm2 nonterm3 > | nonterm1 term1 nonterm2 nonterm3 > | nonterm1 term2 nonterm2 nonterm3 > > Consider first example. First parser will consume nonterm2 then for term1 > rule, nonterm1 will hold nonterm2 value and term2 higher precedence than > term1, parser have to pass value to nonterm1 in term2 rule but it is invalid > if we provide term1 precedence to term1 rule because as the statement > suggests, last terminal token gives rule precedence. Assigning value of > "nonterm3 nonterm4" to nonterm1 in term2 rule is not possible or is it? > Value is for term or nonterm but not partial set of symbols in rule. is it > right? > Does the info doc says last terminal symbol as last but one symbol which if > it is terminal? Your question is a bit confusing, I'm not sure I really understand what you mean. However, note that precedence is *only* about solving shift/reduce conflicts. In your grammar, it is unlikely that you would get a shift/reduce conflict. Rather, the parser will try to follow both "nonterm1 : nonterm1 term1 nonterm3 nonterm4" and "nonterm1 : nonterm1 term2 nonterm5 nonterm6" in parallel, and it will easily see which one to chose when it sees term1 or term2 arriving. So it does not care what precedence you gave to who. Make a full example, feed it to bison with --graph, and look at the resulting graph. You should understand what is going on (provided you understand how LR parsers work). Cheers. ___ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison
Re: bison info doc - precedence in recursive parsing
> On 4 Feb 2019, at 07:32, Akim Demaille wrote: > > Make a full example, feed it to bison with --graph, and look at the resulting > graph. I could not get an output using 'dot -Tpdf parser.dot -O'. — Perhaps the grammar is too large, small .dot examples work. ___ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison
Re: bison info doc - precedence in recursive parsing
Hey, can’t remember any such graphviz failure, even with graphs so large, their output isn't actually useful, unless for navigating with e.g. xdot. I however have only used -Tpng, never -Tpdf. Also no -O, but I guess that’s simply and works the same for all cases. > On 4 Feb 2019, at 21:50, Hans Åberg wrote: > > >> On 4 Feb 2019, at 07:32, Akim Demaille wrote: >> >> Make a full example, feed it to bison with --graph, and look at the >> resulting graph. > > I could not get an output using 'dot -Tpdf parser.dot -O'. — Perhaps the > grammar is too large, small .dot examples work. > > > > ___ > help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison ___ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison
Re: bison info doc - precedence in recursive parsing
> On 4 Feb 2019, at 22:59, Uxio Prego wrote: > > can’t remember any such graphviz failure, even with graphs > so large, their output isn't actually useful, unless for navigating > with e.g. xdot. > > I however have only used -Tpng, never -Tpdf. Also no -O, but I > guess that’s simply and works the same for all cases. It didn't help with PNG, despite running for more than half an hour. Probably too big. ___ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison
Re: bison info doc - precedence in recursive parsing
> Le 4 févr. 2019 à 23:50, Hans Åberg a écrit : > > >> On 4 Feb 2019, at 22:59, Uxio Prego wrote: >> >> can’t remember any such graphviz failure, even with graphs >> so large, their output isn't actually useful, unless for navigating >> with e.g. xdot. >> >> I however have only used -Tpng, never -Tpdf. Also no -O, but I >> guess that’s simply and works the same for all cases. > > It didn't help with PNG, despite running for more than half an hour. Probably > too big. Yes, on "real life grammars", Dot fails to render anything. And the result would probably be useless anyway. This feature is very handy for small grammars, but when it gets too big, you'd better look at the HTML report (or text). ___ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison