help-bison
[Top][All Lists]
Advanced

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

Re: %prec doesn't seem to work?


From: Akim Demaille
Subject: Re: %prec doesn't seem to work?
Date: Wed, 3 Apr 2013 06:39:32 +0200

Le 3 avr. 2013 à 04:52, Adam Smalin <address@hidden> a écrit :

> It didnt seem to do anything. First i wrote
> 
>    | rval '<' rval
>    | rval '<' '<' rval %dprec 1
>    | rval '>' rval %dprec 1
>    | rval '>' '>' rval
> 
> than after not getting the results i tried adding %dprec 2 to the other two
> lines. Then i changed one to 3s wondering if that would solve it. All in
> all it didnt seem to do anything :| is it because i already have precedence
> rules on '<' and '>'?
> 
> I than tried moving the above out of my main expression and doing something
> similar with your sum/prod example. The problem is if i hide rval in the
> prod (pretend i'm doing addition/multiplication) I
> 
> 1) have to go straight to literals which means higher precedence wont work
> because i'm not using rval
> 2) use rval which would break everything because you cant have a rval rval
> in the language and actually that rule would mean rval+ where + means one
> or more
> 3) rewrite all my rules to be like the prod/sum example. The expr rule (am
> i calling it right?) is 150lines so that is going to be brutal to rewrite.
> 
> The way i been checking if this works is by looking at 1>2< <3>4 and seeing
> if the left (and right) are both literals (vs an expression for failure). I
> checked with << and saw it pass. Than  did < < and saw it fail with %prec,
> %dprec 1/3 (with the other having no dprec and a 2)
> 
> crap. I have no idea how i can fix this without rewriting it all.
> If %left and %right seem to do things why doesnt %prec seem to do what i
> need. There must be a way? I'm just going to pretend i will have to rewrite
> this because now after going through the above i think i need to rewrite
> those 150+ lines which is going to be difficult.

You should post a small, self contained, example, if you'd like people
to give a try to your problem.  No need for the whole set of operators,
just a few.

For %dprec to be useful, you need to leave conflicts for the given
tokens, if you "fix" everything with %left and others, it cannot come into
action.




reply via email to

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