groff
[Top][All Lists]
Advanced

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

Re: [Groff] parsing a corner specification


From: Yu Zhao
Subject: Re: [Groff] parsing a corner specification
Date: Sat, 18 Aug 2007 15:46:09 -0700

Look into src/preproc/pic/pic.y, that your first example goes to "label"
because of the lower precedence of "left", and causes an error.

In the second one, "upper", which has higher precedence than "CHOP",  works
well since it is "label corner" rather than "label".

%left LEFT ...
/* Give attributes that take an optional expression a higher
precedence than left and right, so that eg `line chop left'
parses properly. */
%left CHOP ...
/* these must have higher precedence than CHOP so that `label %prec CHOP'
works */
%left UPPER ...

...

place:
        /* line at A left == line (at A) left */
        label                                                   %prec CHOP
                { $$ = $1; }
        | label corner
                {
                  path pth($2);
                  if (!pth.follow($1, & $$))
                    YYABORT;
                }


corner:
...
        | LEFT
                { $$ = &object::west; }
        | RIGHT
                { $$ = &object::east; }
        | UPPER LEFT
                { $$ = &object::north_west; }


----- Original Message ----- 
From: "Joel E. Denny" <address@hidden>
To: <address@hidden>
Sent: Saturday, August 18, 2007 1:40 PM
Subject: [Groff] parsing a corner specification


> I am trying to understand GNU pic's parser as it relates to an extension I
> am working on for Bison.  However, I've never used pic before, so some of
> my questions may be naive.
>
> I checked out Groff from CVS and built it.  The most recent ChangeLog
> entry at the time was 2007-07-15.
>
> I then ran:
>
>   % cat > test.pic
>   .PS
>   A: circle "A"
>   B: A left
>   circle "B" at B
>   .PE
>   % src/preproc/pic/pic test.pic > test.groff
>   src/preproc/pic/pic:test.pic:4: syntax error before `left'
>   src/preproc/pic/pic:test.pic:4: giving up on this picture
>
> However:
>
>   % cat > test.pic
>   .PS
>   A: circle "A"
>   B: A upper left
>   circle "B" at B
>   .PE
>   % src/preproc/pic/pic test.pic > test.groff
>
> There is no error, and the circle labeled B is positioned at the upper
> left corner of the circle labeled A.
>
> The only difference in the input is the word "upper".  Is this apparent
> discrepancy in behavior intended?  If not, should both or neither of these
> inputs be a syntax error?
>
> I've searched the web and Open Group for some roff or pic standards
> document.  So far, I haven't found one.  Does one exist?  `man roff' says
> Groff is the de facto standard.  Is that still the closest we have to a
> formal standard?
>
> Thanks.
>
>





reply via email to

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