Esempio n. 1
0
        /** Get the next Token. */
        public static IrToken getNextToken() 
        {
            IrToken matchedToken;
            int curPos = 0;
            int dummy = 0;
            bool continue_loop = false;

            //EOFLoop :
            for (;;)
            {
                try
                {
                    curChar = input_stream.BeginToken();
                }
                catch(IOException e)
                {
                    jjmatchedKind = 0;
                    matchedToken = jjFillToken();
                    return matchedToken;
                }

                image = jjimage;
                //image.setLength(0);
                image.Length = 0;
                jjimageLen = 0;

                try 
                {
                    continue_loop = false;
                    input_stream.backup(0);
                    while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L)
                    curChar = input_stream.BeginToken();
                }
                catch (IOException e1) 
                {
                    continue;
                    //continue_loop = true;
                }

                if (continue_loop)
                    goto EOFLoop_a; // continue EOFLoop;
            
                jjmatchedKind = unchecked((RegExpId)0x7fffffff);
                jjmatchedPos = 0;
                curPos = jjMoveStringLiteralDfa0_0();

                if (jjmatchedKind != unchecked((RegExpId)0x7fffffff))
                {
                    if (jjmatchedPos + 1 < curPos)
                        input_stream.backup(curPos - jjmatchedPos - 1);

                    if ((jjtoToken[(int)jjmatchedKind >> 6] & (1L << ((int)jjmatchedKind & 0x3F))) != 0L)
                    {
                        matchedToken = jjFillToken();
                        TokenLexicalActions(matchedToken);
                        return matchedToken;
                    }
                    else
                    {
                        goto EOFLoop_a; // continue EOFLoop;
                    }
                }

                int error_line = input_stream.getEndLine();
                int error_column = input_stream.getEndColumn();
            
                String error_after = null;
                bool EOFSeen = false;
            
                try
                { 
                    input_stream.readChar(); 
                    input_stream.backup(1); 
                }
                catch (IOException e1) 
                {
                    EOFSeen = true;
                    error_after = curPos <= 1 ? "" : input_stream.GetImage();
                    if (curChar == '\n' || curChar == '\r') {
                    error_line++;
                    error_column = 0;
                }
                else
                    error_column++;
                }
                if (!EOFSeen) 
                {
                    input_stream.backup(1);
                    error_after = curPos <= 1 ? "" : input_stream.GetImage();
                }
                throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);

            EOFLoop_a:
                dummy++; dummy--;
            }
        }
Esempio n. 2
0
 static private int jjStopAtPos(int pos, RegExpId kind)
 {
     jjmatchedKind = kind;
     jjmatchedPos = pos;
     return pos + 1;
 }
Esempio n. 3
0
 static private int jjStartNfaWithStates_0(int pos, RegExpId kind, int state)
 {
     jjmatchedKind = kind;
     jjmatchedPos = pos;
     try { curChar = input_stream.readChar(); }
     catch(IOException e) { return pos + 1; }
     return jjMoveNfa_0(state, pos + 1);
 }
Esempio n. 4
0
 /** Constructor with generated Token Manager. */
 public irParser(irParserTokenManager tm)
 {
     if (jj_initialized_once)
     {
         Console.Out.WriteLine("ERROR: Second call to constructor of static parser. ");
         Console.Out.WriteLine("       You must either use ReInit() or set the JavaCC option STATIC to false");
         Console.Out.WriteLine("       during parser generation.");
         throw new Error();
     }
     jj_initialized_once = true;
     token_source = tm;
     token = new IrToken();
     jj_ntk = RegExpId.UNDEFINED;
     jj_gen = 0;
     for (int i = 0; i < 9; i++) jj_la1[i] = -1;
 }
Esempio n. 5
0
 /** Reinitialise. */
 public void ReInit(irParserTokenManager tm)
 {
     token_source = tm;
     token = new IrToken();
     jj_ntk = RegExpId.UNDEFINED;
     jj_gen = 0;
     for (int i = 0; i < 9; i++) jj_la1[i] = -1;
 }
Esempio n. 6
0
 private static RegExpId jj_ntk_fn()
 {
     if ((jj_nt = token.next) == null)
         //return (jj_ntk = (token.next = token_source.getNextToken()).kind);
         return (jj_ntk = (token.next = IrParserTokenManager.getNextToken()).kind);
     else
         return (jj_ntk = jj_nt.kind);
 }
Esempio n. 7
0
 /** Constructor. */
 public irParser(/* java.io.Reader */ InputStreamReader stream)
 {
     if (jj_initialized_once)
     {
         Console.Out.WriteLine("ERROR: Second call to constructor of static parser. ");
         Console.Out.WriteLine("       You must either use ReInit() or set the JavaCC option STATIC to false");
         Console.Out.WriteLine("       during parser generation.");
         throw new Error();
     }
     jj_initialized_once = true;
     jj_input_stream = new SimpleCharStream(stream, 1, 1);
     token_source = new irParserTokenManager(jj_input_stream);
     token = new IrToken();
     jj_ntk = RegExpId.UNDEFINED;
     jj_gen = 0;
     for (int i = 0; i < 9; i++) jj_la1[i] = -1;
 }
Esempio n. 8
0
 /* throws ParseException */
 private static IrToken jj_consume_token(IrParserConstants.RegExpId kind)
 {
     IrToken oldToken;
     if ((oldToken = token).next != null)
         token = token.next;
     else
     {
         //token = token.next = token_source.getNextToken();
         token.next = IrParserTokenManager.getNextToken();
         token = token.next;
     }
     jj_ntk = RegExpId.UNDEFINED;
     if (token.kind == kind)
     {
         jj_gen++;
         return token;
     }
     token = oldToken;
     jj_kind = kind;
     throw generateParseException();
 }
Esempio n. 9
0
 /** Reinitialise. */
 public static void ReInit(/* java.io.Reader */ StreamReader streamReader)
 {
     jj_input_stream.ReInit(streamReader, 1, 1);
     //token_source.ReInit(jj_input_stream);
     IrParserTokenManager.ReInit(jj_input_stream);
     token = new IrToken();
     jj_ntk = RegExpId.UNDEFINED;
     jj_gen = 0;
     for (int i = 0; i < 9; i++) jj_la1[i] = -1;
 }
Esempio n. 10
0
        /** Reinitialise. */
        public static void ReInit(Stream stream, Encoding encoding)
        {
            try
            {
                jj_input_stream.ReInit(stream, encoding, 1, 1);
            }
            catch (UnsupportedEncodingException e)
            {
                throw new RuntimeException(e);
            }

            //token_source.ReInit(jj_input_stream);
            IrParserTokenManager.ReInit(jj_input_stream);
            token = new IrToken();
            jj_ntk = RegExpId.UNDEFINED;
            jj_gen = 0;
            for (int i = 0; i < 9; i++) jj_la1[i] = -1;
        }
Esempio n. 11
0
 /** Get the next Token. */
 public static IrToken getNextToken()
 {
     if (token.next != null)
         token = token.next;
     else
         //token = token.next = token_source.getNextToken();
         token = token.next = IrParserTokenManager.getNextToken();
     jj_ntk = RegExpId.UNDEFINED;
     jj_gen++;
     return token;
 }
Esempio n. 12
0
        /** Constructor with InputStream and supplied encoding */
        public IrParser(Stream stream, Encoding encoding)
        {
            if (jj_initialized_once)
            {
                ReInit(stream, encoding);
                //Console.Out.WriteLine("ERROR: Second call to constructor of static parser.  ");
                //Console.Out.WriteLine("       You must either use ReInit() or set the JavaCC option STATIC to false");
                //Console.Out.WriteLine("       during parser generation.");
                //throw new Error();
            }
            else
            {
                jj_initialized_once = true;
                try
                {
                    jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1);
                }
                catch (UnsupportedEncodingException e)
                {
                    throw new RuntimeException(e);
                }

                token_source = new IrParserTokenManager(jj_input_stream);
            }

            token = new IrToken();
            jj_ntk = RegExpId.UNDEFINED;
            jj_gen = 0;
            for (int i = 0; i < 9; i++) jj_la1[i] = -1;
        }