[antlr-interest] Re: bug in java.g?

SainTiss saintiss at arklinux.org
Wed Feb 4 02:30:58 PST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

On Wednesday 04 February 2004 01:48, lgcraymer wrote:
> --- In antlr-interest at yahoogroups.com, SainTiss <saintiss at a...> wrote:
> > I told it to match one statement indeed, but the problem is that it does
> > *not* seem to ignore everything else... With this input:
> > m = (TEST) n;
> > there is one statement, but the parser crashes.
> > With this input:
> > m = (TEST) n;
> > tessmklj
> > The parser successfully parses the first statement, and does not crash...
> > So that does look quite odd, no?
>
> If you are using the statement rule directly to match this, you expect this
> behavior--there is a lookahead set for statement which is checked and the
> "tessmklj" satisfies the lookahead.
>
> You really need a "statementComplete" rule such as Monty suggested _without
> the EOF_, but called by no rule within your grammar (EOF makes sense if you
> are sure to get an EOF as the next token, but not if you may have
> extraneous garbage).

Ah, it *does* seem to work now (forgot to ignore whitespace once more)... 
Thanks... Interesting enough, adding a statementComplete rule is the key, but 
it doesn't matter if you call statement() or statementComplete() afterwards 
so it seems!
Does that mean that the mere fact of there being a rule which calls statement 
and is itself never called suffices to not have the lookahead set?

>
> BTW, why are you doing single statement matches?  If you are doing
> interpretation of phrases, I have a string InputBuffer class which can be
> refilled.  That will be included with the 2.8 distribution--I need it to
> support testing--but that won't be until after 2.7.3 is officially
> released.  I can send you a copy if you would like.

In fact, what I want to do is parse some user code, which must be a number of 
statements, and transform the declaration statements into assignment 
statements. Should work fine with the TokenStreamRewriteEngine by Terence... 
So I think an InputBuffer which can be refilled is not of much use in this 
case... Unless I'm missing your point?

>
> --Loring
>
>
>
>
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
>  http://groups.yahoo.com/group/antlr-interest/
>
> To unsubscribe from this group, send an email to:
>  antlr-interest-unsubscribe at yahoogroups.com
>
> Your use of Yahoo! Groups is subject to:
>  http://docs.yahoo.com/info/terms/

- -- 
Ark Linux - Linux for the Masses (http://arklinux.org)

Capitalism: 
You don't have any cows. The bank will not lend you money to buy cows, 
because you don't have any cows to put up as collateral.

Representative Democracy:
You have two cows. Your neighbors pick someone to tell you who gets the milk. 

In a world without walls and fences, who needs windows and gates?

Hans Schippers
2LIC INF
UA 2003-2004
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAIMnkXlnUYIbmLOQRAikBAJ4hhelis0TW9QkobRsbbjltW5MBlgCfVf5G
ZYTEWVhOudxeQ/QcsfDm55g=
=7Z4z
-----END PGP SIGNATURE-----


 

Yahoo! Groups Links

To visit your group on the web, go to:
 http://groups.yahoo.com/group/antlr-interest/

To unsubscribe from this group, send an email to:
 antlr-interest-unsubscribe at yahoogroups.com

Your use of Yahoo! Groups is subject to:
 http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list