help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bison info doc - precedence in recursive parsing


From: Anand Akhare
Subject: Re: bison info doc - precedence in recursive parsing
Date: Mon, 4 Feb 2019 09:10:20 +0530

Pasting link of info doc
https://www.gnu.org/software/bison/manual/html_node/How-Precedence.html#How-Precedence


> On 03-Feb-2019, at 12:20 PM, <address@hidden> <address@hidden> wrote:
> 
> 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?
>  
> Regards,
> Anand


reply via email to

[Prev in Thread] Current Thread [Next in Thread]