   JavaCC problem
  Hi!I'm using JavaCC and I’d like to consume all text between two keywords in the same manner as the C language comment where the keyword would be “/*” and “*/”. In my case I’d like to skip all text between “BEGIN” and “END;” The problem is that it is parsing find to the first Callable() “PROCEDURE” but consuming the “FUNCTION” as skipped code. This probably because the lexar finds the longest match between “PROCEDURE” “BEGIN” and “FUNCTION” “END”. I have tried using the “SKIP” sample shown in the JavaCC FAQ but not been able to solve it. I have removed code where I handle C language style comments (I store the comments so I do not want to skip the comments) to make it more simple to read my sample below.Any idea?Input to my parser:---------------------------DEFINE CLASS myClass  DEFINE PROCEDURE myProcedure  BEGINWhatever text goes here I am not interested in…skip it!  END;  DEFINE FUNCTION myFunction  BEGIN Whatever text goes here I am not interested in…skip it!  END;END DEFINE; JavaCC source:----------------------- options {  IGNORE_CASE = true;  JAVA_UNICODE_ESCAPE = true;  STATIC = false;} PARSER_BEGIN(MyParser) import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import org.javacc.parser.JavaCCParser; import java.util.*; public class MyParser {   public static void main(String[] args) {    parse();  }    private static void parse() { try {    MyParser parser = new MyParser(new FileInputStream(new File("small.src")));    parser.Input();} catch (IOException e) {throw new RuntimeException(e.getMessage());} catch (ParseException e2) {}  }} PARSER_END(MyParser) void Input() :{}{  (Define() )* <EOF>} void Define() :{}{   <DEFINE> aClass() ( Subject() )+ <END> <DEFINE> ";"   {   }} void Subject() :{}{   <DEFINE> Callable() skipCode() } void Callable() :{}{   Function() |  Procedure()} void aClass () :{}{  <ACLASS> <IDENTIFIER>   {  System.out.println("Module");  }} void Function() :{}{  <FUNCTION> <IDENTIFIER>  {  System.out.println("Function");  /* Never ends up here…….:-( */  }} void Procedure() :{}{  <PROCEDURE> <IDENTIFIER>  {  System.out.println("Procedure");  }} SKIP : /* WHITE SPACE */{  " "| "\t"| "\n"| "\r"| "\f"| ","} void skipCode() :{}{  <THE_CODE> } TOKEN : /* RESERVED WORDS */{   < DEFINE: "DEFINE" >| < END: "END" >| < FUNCTION: "FUNCTION" >| < ACLASS: "CLASS" >| < PROCEDURE: "PROCEDURE" >| < THE_CODE: "BEGIN" (~[])* "END;" >} TOKEN : /* IDENTIFIERS */{  < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >|  < #LETTER: [  "\u0024",  "\u0041"-"\u005a",  "\u005f",  "\u0061"-"\u007a",  "\u00c0"-"\u00d6",  "\u00d8"-"\u00f6",  "\u00f8"-"\u00ff",  "\u0100"-"\u1fff",  "\u3040"-"\u318f",  "\u3300"-"\u337f",  "\u3400"-"\u3d2d",  "\u4e00"-"\u9fff",  "\uf900"-"\ufaff" ]  >|  < #DIGIT: [  "\u0030"-"\u0039",  "\u0660"-"\u0669",  "\u06f0"-"\u06f9",  "\u0966"-"\u096f",  "\u09e6"-"\u09ef",  "\u0a66"-"\u0a6f",  "\u0ae6"-"\u0aef",  "\u0b66"-"\u0b6f",  "\u0be7"-"\u0bef",  "\u0c66"-"\u0c6f",  "\u0ce6"-"\u0cef",  "\u0d66"-"\u0d6f",  "\u0e50"-"\u0e59",  "\u0ed0"-"\u0ed9",  "\u1040"-"\u1049" ]  >}   