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: Adam Smalin
Subject: Re: %prec doesn't seem to work?
Date: Tue, 2 Apr 2013 22:52:06 -0400

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.



On Tue, Apr 2, 2013 at 3:18 AM, Akim Demaille <address@hidden> wrote:

>
> Le 31 mars 2013 à 17:15, Adam Smalin <address@hidden> a écrit :
>
> > Report what? I was just saying I didn't notice any errors/warnings (I
> don't remember if I tried to compile all of it) and that I am positive I
> compiled it right.
>
> Well, IMHO Bison should warn against multiple %prec for a rule,
> and arguably warn against weird locations for %prec (and the
> other %directives).
>
> > FYI I AM using a glr parser. My first line is %glr-parser
>
> Good.
>
> > Is the code at the bottom the recommended way? I wrote out %left and
> %right which seemed to resolve all of that.
> > My bison file is roughly 1200 so I rather not rewrite it if I don't need
> to
>
> Have a look at %dprec.


reply via email to

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