Re: Tell a rule to shift instead of reduce?

2013-12-24 Thread Akim Demaille
Le 23 déc. 2013 à 14:38, Adam Smalin a écrit : > Oh crap! It's looking at the token ',' and not the other rules (rule 12). > FF > I want to rule 12 to trump rule 15. Rule 15 precedence should definitely > stay the same. F! I don’t understand w

Re: Tell a rule to shift instead of reduce?

2013-12-23 Thread Adam Smalin
Oh crap! It's looking at the token ',' and not the other rules (rule 12). FF I want to rule 12 to trump rule 15. Rule 15 precedence should definitely stay the same. F! So it's impossible for me to ask bison to shift during rule 12 when possible?

Re: Tell a rule to shift instead of reduce?

2013-12-23 Thread Akim Demaille
Le 22 déc. 2013 à 21:17, Adam Smalin a écrit : > > Please, post a self contained and minimal example. > > Ok. I didn't test it by parsing actual code. I only looked at the conflict > %left ',' > %right '=' > %left '.' > > %% > > program: > newline_many global_loop newline_many > global_l

Re: Tell a rule to shift instead of reduce?

2013-12-22 Thread Adam Smalin
> Please, post a self contained and minimal example. Ok. I didn't test it by parsing actual code. I only looked at the conflict %left ',' %right '=' %left '.' %% program: newline_many global_loop newline_many global_loop: global_expr | global_loop global_expr global_expr: VAR

Re: Tell a rule to shift instead of reduce?

2013-12-22 Thread Akim Demaille
Le 22 déc. 2013 à 20:35, Akim Demaille a écrit : > > Le 22 déc. 2013 à 18:40, Adam Smalin a écrit : > >> I forgot to CC this to the group a few days ago. >> >>> The token precedences apply to the tokens immediately before and after the >>> parsing ‘.’ (as in the .output file) in the shift/r

Re: Tell a rule to shift instead of reduce?

2013-12-22 Thread Akim Demaille
Le 22 déc. 2013 à 18:40, Adam Smalin a écrit : > I forgot to CC this to the group a few days ago. > > >The token precedences apply to the tokens immediately before and after the > >parsing ‘.’ (as in the .output file) in the shift/reduce conflicting rules. > >The grammar must be written so th

Re: Tell a rule to shift instead of reduce?

2013-12-22 Thread Akim Demaille
Le 22 déc. 2013 à 18:38, Adam Smalin a écrit : > That's one way to solve my literal problem but I would really like to make > ',' a higher precedence than '=' on that one rule (so it would shift instead > of reducing 100% of the time). > > Both sides should be rvals. What if someone wanted to

Re: Tell a rule to shift instead of reduce?

2013-12-22 Thread Adam Smalin
I forgot to CC this to the group a few days ago. >The token precedences apply to the tokens immediately before and after the parsing ‘.’ (as in the .output file) in the shift/reduce conflicting rules. The grammar must be written so that the tokens appear in such a position. | rval '=' rval %prec

Re: Tell a rule to shift instead of reduce?

2013-12-22 Thread Adam Smalin
That's one way to solve my literal problem but I would really like to make ',' a higher precedence than '=' on that one rule (so it would shift instead of reducing 100% of the time). Both sides should be rvals. What if someone wanted to do something like get_state().member[index].value, new_state

Re: Tell a rule to shift instead of reduce?

2013-12-22 Thread Akim Demaille
Le 17 déc. 2013 à 09:25, Adam Smalin a écrit : > I still need help with this. I rewrote it maybe this will be more clear? > > I want to allow this > > var = var > var, var = var > var = var, var Maybe I am missing something, by how about clearly stating that you can have several lvalues and r

Re: Tell a rule to shift instead of reduce?

2013-12-18 Thread Hans Aberg
[Please cc the list.] On 18 Dec 2013, at 23:45, Adam Smalin wrote: > >The token precedences apply to the tokens immediately before and after the > >parsing ‘.’ (as in the .output file) in the shift/reduce conflicting rules. > >The grammar must be written so that the tokens appear in such a pos

Re: Tell a rule to shift instead of reduce?

2013-12-18 Thread Hans Aberg
[Please cc the list.] On 18 Dec 2013, at 11:05, John P. Hartmann wrote: > Isn't the grammar context sensitive? No way that can be shoehorned into > LALR(1). Computer languages are typically context sensitive, but that is pushed into the actions.

Re: Tell a rule to shift instead of reduce?

2013-12-18 Thread Hans Aberg
[Please avoid styled text.] On 18 Dec 2013, at 02:05, Adam Smalin wrote: > I don't believe that works. According to my rules and the conflict files it > REFUSES to shift. "var, var = var" I think will work but "var = var, var" > will be seen as rval ',' rval which isn't legal. I'm not sure whe

Re: Tell a rule to shift instead of reduce?

2013-12-17 Thread Adam Smalin
I don't believe that works. According to my rules and the conflict files it REFUSES to shift. "var, var = var" I think will work but "var = var, var" will be seen as rval ',' rval which isn't legal. I'm not sure where I can make rval ',' rval legal and have my code work because doing it in rval: wi

Re: Tell a rule to shift instead of reduce?

2013-12-17 Thread Adam Smalin
I tried this | rval '=' rval ',' rval %prec '.' I still get the conflict Conflict between rule 345 and token ',' resolved as reduce (',' < '='). I tried dprec 1 and 2 on the two lines. Then I changed 1 into 3 to flop which one is higher. No dice > A second, more straightforward, idea is to shu

Re: Tell a rule to shift instead of reduce?

2013-12-17 Thread Hans Aberg
On 17 Dec 2013, at 09:25, Adam Smalin wrote: > I still need help with this. I rewrote it maybe this will be more clear? > > I want to allow this > > var = var > var, var = var > var = var, var If you can do dynamic type checking, it suffices to write rules (as in the Bison manual calculator e

Re: Tell a rule to shift instead of reduce?

2013-12-17 Thread Chris verBurg
Hey Adam, I have a couple ideas. First, you might try updating the precedence of ',' for just that one rule: | rvalLoop ',' rval %prec '=' (though you might need to define a precedence-level higher than both ',' and '=' for that to work right). A second, more straightforward, idea is to shuffl

Re: Tell a rule to shift instead of reduce?

2013-12-17 Thread Ron Burk
> because it would be wrong when looking into functions. Is there some reason you need to treat function parameter lists as expressions, rather than comma-separated expression lists? Could you just follow the usual practice of: a) give ',' and '=' the precedence you desire b) break your expressio

Tell a rule to shift instead of reduce?

2013-12-17 Thread Adam Smalin
I still need help with this. I rewrote it maybe this will be more clear? I want to allow this var = var var, var = var var = var, var My rules are similar to the below body: recursive-expr //rval = rval is here | rval '=' rval ',' rvalLoop | rval ',' rvalLoop '=' rval rvalLoop: rva