1 Reply Latest reply: Oct 30, 2010 8:56 PM by EJP RSS

    how do i read a question in javacc and be able to identify key tokens

    809514
      hello everyone....
      I need help. I am still new with javacc, i am trying to generate a parser that will accept a question and be able to recognise the keywords and the askword from the question. e.g a question like "what is HIV" . it is suppose to get "what" as the askword and "HIV" as the key

      another example: "what are arv drug" "what" as the askword and "arv drug" as the key

      below is the code for what i have done so far.... thanx in advance


      Code:

      PARSER_BEGIN(SMS_QUERY)
      import java.io.StringReader;
      public class SMS_QUERY {
      public static void main(String args[]) throws ParseException{

      SMS_QUESTION q = new SMS_QUESTION(System.in);
      q.QUESTION();
      System.out.println(q);
      }
      }

      PARSER_END(SMS_QUERY)
      SKIP :
      {
      " "
      | "\t"
      | "\n"
      | "\r"
      }
      void SMS_QUESTION() : {}
      {
      (NounPhrase())+ | AskWord() | AskWord() (NounPhrase())+ | <EOF>
      }

      void AskWord() : {}
      {
      Awhat()
      }
      void Awhat() : {}
      {
      "what" | "wht" | "wt" | "wyt" | "vat" | "wat"
      }
      void NounPhrase() : {}
      {
      key()
      }
      void key() : {}
      {
      q1key() | q2key() | q3key()
      }
      void q1key() : {}
      {
      "Arv" | "Arv Drugs" | "Arv drgs" | "Arv drgh"
      }
      void q2key() : {}
      {
      "HIV" | "Hi virus"
      }