Friday 15 January 2010

JavaCC - How to store tokens for later parse? -


I'm trying to parse my input partially, so that I stored some sections for later paras Can do

  Zero start (): {} {stmt () *} void stmt (): {} {"parse:" expr_later () ";" } Void expr_later (): {} {(expr (); // Store fork from expr () in a list for processing later ....) *}}}}}}}} "{" expr (): {} ) "}" | & Lt; Any: ~ []> }   

In this case, "any" token will be valid only if the last token will not match anything else, but assume that I have many token definitions, not grammar above

I know that ~ [] matches any characters and not no token.

Next, let's say that I use tokens states instead (they work with Javadoc, Progama etc), in part because I do not have a token to set up my special token state There may be a problem in capturing. Apart from this, setting the token status through the parser, according to the FAQ of the Jawansasi, is poor practice, since the token manager may already have some tokens in its line.

So I am thinking that anybody has at least one idea about any concurrent token or how to remove my problem in a different way?

Of course, one way to do this is to produce a bigger, except that "{" and "}" List all types of tokens

  Any token (): {token t;} {(T = <<> | =} | ID = | (= |) |   

But it is not quite elegant.

Instead, you can write a JAVACODE Which uses the token till the end of the end - the brace has been found. See for a similar example.

No comments:

Post a Comment