[Mono-list] I want to get in on this.
Jay Freeman (saurik)
saurik@saurik.com
Fri, 13 Jul 2001 01:18:57 -0500
Miguel:
Well, maybe I'm just doing this wrong, but I decided to try this and it
doesn't work. I even made it easy on it, my test has EXPR and var_list be
tokens rather than complex expressions. I copied this from a terminal
window, so the tabs aren't right, but here is the base of my test:
<file name="vb.y">
%token FOR VAR EXPR SOMETHING TO NEXT var_list
%%
body:
/* nothing */
| statement body
;
statement:
for_statement
| SOMETHING
;
for_statement:
FOR VAR '=' EXPR TO EXPR body opt_next
;
opt_next:
/* nothing */
| NEXT var_list
;
</file>
I am pretty sure I got this right. This yields 5 shift/reduce conflicts.
If you put a defined deliniator around "body" in for_staement, such as '('
and ')', you can get it to work. VB has statements that have to end in '\n'
or be separated by ':', so that helps a little, but I can't come up with a
good organization of separators that makes it both work _and_ not require
that there be two separators somewhere (example, if you are willing to
always have two enters at the end of for statements, that could work, but I
bet when you start adding more types even that would only be a temporary
hack).
Note that if you remove the empty expansion of opt_next (thereby requiring
separate Next statements) it works fine. If need be I can do more research
and attempt to explain exactly _why_ this doesn't work, but for now all I
can really do is state that it doesn't.
Sincerely,
Jay Freeman (saurik)
saurik@saurik.com
----- Original Message -----
From: "Miguel de Icaza" <miguel@ximian.com>
To: "Jay Freeman (saurik)" <saurik@saurik.com>
Cc: "mono-list" <mono-list@ximian.com>
Sent: Friday, July 13, 2001 12:20 AM
Subject: Re: [Mono-list] I want to get in on this.
...
>
> Of course it can be parsed by yacc.
>
> The grammar is not deterministic, and that is what you use the actions
> for.
>
> Indeed, you can not use yacc to build an error checking C# parser, nor
> a Java one. You need to delay those actions to the `actions'. Just
> like you would with the grammar I showed you for the for next.
>
> Miguel.