« Return to Thread: Javacc Eof problem.

Javacc Eof problem.

by netchandri :: Rate this Message:

Reply to Author | View in Thread

Hi There,

I am new to Javacc, please consider.

I am facing problem with EOF for my input stream and I need some assistance for the below problem:
I have a small .jj file with the following code
-------------------------------------------------------
**
 * JavaCC file
 */
 
options {
  JDK_VERSION = "1.5";
}
PARSER_BEGIN(check)
package test1;
import java.io.*;

public class check {
  public static void main(String args[]) throws ParseException {
   BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    check parser = new check(bf);  
    String test = check.event();
    System.out.println("Result:" +test);
  }    
}
PARSER_END(check)

SKIP :
{
        "\r"
| "\t"
| "\n"
}
TOKEN : /* OPERATORS */
{
        < TEXT: "\"" | "(" | ")" | "data.dbxml" >
| < INSERT: "insert" >
| < NODES: "nodes" >
| < TABLE: "Pending" >
| < space : " " >
}
String event()  :
{
Token t;
String i ;
int value ;
}{
t = <INSERT>
{ i = t.image; }
<EOF>
{ System.out.println(i);
        return i ;
}
}
-------------------------------------------------------

When I enter input at the console the console does not exit for the <EOF> tag. For Example for the above program I enter: insert

Now the console just stands there and doesn't provide me with the result. I know I am making a mistake here with the "/r" key as I have allowed the parser to skip this. Now I have no clue how to exit from my user input console. Please help me to understand this.

Thanks.

 « Return to Thread: Javacc Eof problem.