Loading ...
Sorry, an error occurred while loading the content.

How to override the default reportError of Parser

Expand Messages
  • macromliu <macromliu@yahoo.com.cn>
    Enviroment: VC++ 6.0 Enterprise(SP5) Win2k SP3(en) JDK 1.3 ANTLR2.7.2RC1 when i tried to override the reportError of the Parser like this:
    Message 1 of 2 , Jan 1, 2003
    • 0 Attachment
      Enviroment:
      VC++ 6.0 Enterprise(SP5) Win2k SP3(en) JDK 1.3 ANTLR2.7.2RC1

      when i tried to override the reportError of the Parser like this:
      //--------------------------------------
      header{
      #include <afxcoll.h> //CPtrList
      #include <iostream>
      #include "antlr/RecognitionException.hpp"
      }
      options{
      language="Cpp";
      }
      class GMSPassParser extends Parser;
      options {
      exportVocab=GMSPass;
      k = 1;
      }
      {
      void reportError(RecognitionException &ex )
      {
      AfxMessageBox(ex.toString().c_str() );
      }

      }
      .........
      ..........
      //---------------------------
      i got the following compile error:
      error C2061: syntax error : identifier 'RecognitionException'

      how to get ride of this compile error???
    • macromliu <macromliu@yahoo.com.cn>
      Enviroment: VC++ 6.0 Enterprise(SP5) Win2k SP3(en) JDK 1.3 ANTLR2.7.2RC1 i ve solve this problem... just like the following...
      Message 2 of 2 , Jan 1, 2003
      • 0 Attachment
        Enviroment:
        VC++ 6.0 Enterprise(SP5) Win2k SP3(en) JDK 1.3 ANTLR2.7.2RC1
        i've solve this problem... just like the following...
        //--------------------------------------
        header{
        #include <afxcoll.h> //CPtrList
        #include <iostream>
        #include "antlr/RecognitionException.hpp"
        ANTLR_USING_NAMESPACE(antlr) //********and this line***********
        }
        options{
        language="Cpp";
        }
        class GMSPassParser extends Parser;
        options {
        exportVocab=GMSPass;
        k = 1;
        }
        {
        void reportError(RecognitionException &ex )
        {
        AfxMessageBox(ex.toString().c_str() );
        }

        }
        ...
        rules.
        ...
        //---------------------------
      Your message has been successfully submitted and would be delivered to recipients shortly.