Usenet.com

www.Usenet.com

Group Index

Comp Thread Archive from Usenet.com

<-- __Chronological__ --> <-- __Thread__ -->

How to get all the text between two tokens



Hello,

I am trying to write a small parser that parses a a file and returns a
list of statements back (and not ignoring newline, spaces etc) that
starts with a given token and end with a ";".

I unable to make any good progress. Can someone tell me if I am doing
something wrong, since the below does not seem to work for me.

Sincerely,

-Mohsin


TOKEN_MGR_DECLS :
{
  StringBuffer myString;
}

MORE :
{
  "BEGIN-STMT" {myString= new StringBuffer();} : IN_TEXT
}

<IN_TEXT>
MORE :
{
    < ~[";"] > { myString.append(image); }
}

<IN_TEXT>
TOKEN :
{
  <MY_TEXT: ";" > : DEFAULT
}


void myStatement() :
{
}
{
    <MY_TEXT>
    {
        System.err.println(token_source.sqlString.toString());
    }
}



<-- __Chronological__ --> <-- __Thread__ -->


Usenet.com



Please check out one of the premium Usenet Newsgroup Service Providers below for access to Usenet.