Exemple #1
0
 /** Generate ParseException. */
 public static MiniParseException generateParseException()
 {
     jj_expentries.Clear();
     bool[] la1tokens = new bool[53];
     if (jj_kind >= 0)
     {
         la1tokens[(int)jj_kind] = true;
         jj_kind = MpRegExpId.UNDEFINED;
     }
     for (int i = 0; i < 45; i++)
     {
         if (jj_la1[i] == jj_gen)
         {
             for (int j = 0; j < 32; j++)
             {
                 if ((jj_la1_0[i] & (1<<j)) != 0)
                 {
                     la1tokens[j] = true;
                 }
                 if ((jj_la1_1[i] & (1<<j)) != 0)
                 {
                     la1tokens[32+j] = true;
                 }
             }
         }
     }
     for (int i = 0; i < 53; i++) {
         if (la1tokens[i]) {
             jj_expentry = new int[1];
             jj_expentry[0] = i;
         jj_expentries.Add(jj_expentry);
         }
     }
     jj_endpos = 0;
     jj_rescan_token();
     jj_add_error_token(0, 0);
     int[][] exptokseq = new int[jj_expentries.Count()][];
     for (int i = 0; i < jj_expentries.Count(); i++)
     {
         exptokseq[i] = jj_expentries[i];
     }
     return new MiniParseException(token, exptokseq, tokenImage);
 }
Exemple #2
0
 /** Reinitialise. */
 public static void ReInit(java.io.Reader stream)
 {
     jj_input_stream.ReInit(stream, 1, 1);
     token_source.ReInit(jj_input_stream);
     token = new PsrToken();
     jj_ntk = -1;
     jj_gen = 0;
     for (int i = 0; i < 45; i++) jj_la1[i] = -1;
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
 }
Exemple #3
0
 /** Reinitialise. */
 public void ReInit(miniParserTokenManager tm)
 {
     token_source = tm;
     token = new PsrToken();
     jj_ntk = -1;
     jj_gen = 0;
     for (int i = 0; i < 45; i++) jj_la1[i] = -1;
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
 }
Exemple #4
0
 /** Constructor. */
 public miniParser(java.io.Reader stream)
 {
     if (jj_initialized_once)
     {
         // System.out.println("ERROR: Second call to constructor of static parser. ");
         // System.out.println("       You must either use ReInit() or set the JavaCC option STATIC to false");
         // System.out.println("       during parser generation.");
         // throw new Error();
     }
     jj_initialized_once = true;
     jj_input_stream = new SimpleCharStream(stream, 1, 1);
     token_source = new miniParserTokenManager(jj_input_stream);
     token = new PsrToken();
     jj_ntk = -1;
     jj_gen = 0;
     for (int i = 0; i < 45; i++) jj_la1[i] = -1;
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
 }
Exemple #5
0
 /** Constructor with generated Token Manager. */
 public miniParser(miniParserTokenManager tm)
 {
     if (jj_initialized_once) {
     System.out.println("ERROR: Second call to constructor of static parser. ");
     System.out.println("       You must either use ReInit() or set the JavaCC option STATIC to false");
     System.out.println("       during parser generation.");
     throw new Error();
     }
     jj_initialized_once = true;
     token_source = tm;
     token = new PsrToken();
     jj_ntk = -1;
     jj_gen = 0;
     for (int i = 0; i < 45; i++) jj_la1[i] = -1;
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
 }
Exemple #6
0
 private static MpRegExpId jj_ntk_fn()
 {
     if ((jj_nt = token.next) == null)
         return (jj_ntk = (token.next = MiniParserTokenManager.getNextToken()).kind);
     else
         return (jj_ntk = jj_nt.kind);
 }
Exemple #7
0
 private static bool jj_scan_token(MpRegExpId kind)
 {
     if (jj_scanpos == jj_lastpos)
     {
         jj_la--;
         if (jj_scanpos.next == null)
         {
             jj_lastpos = jj_scanpos = jj_scanpos.next = MiniParserTokenManager.getNextToken();
         }
         else
         {
             jj_lastpos = jj_scanpos = jj_scanpos.next;
         }
     }
     else
     {
         jj_scanpos = jj_scanpos.next;
     }
     if (jj_rescan)
     {
         int i = 0; MiniToken tok = token;
         while (tok != null && tok != jj_scanpos)
         {
             i++; tok = tok.next;
         }
         if (tok != null)
             jj_add_error_token(kind, i);
     }
     if (jj_scanpos.kind != kind) return true;
     if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
     return false;
 }
Exemple #8
0
        /* throws ParseException */
        private static MiniToken jj_consume_token(MpRegExpId kind)
        {
            MiniToken oldToken;

            if ((oldToken = token).next != null)
                token = token.next;
            else
                token = token.next = MiniParserTokenManager.getNextToken();

            jj_ntk = MpRegExpId.UNDEFINED;

            if (token.kind == kind)
            {
                jj_gen++;
                if (++jj_gc > 100)
                {
                    jj_gc = 0;
                    for (int i = 0; i < jj_2_rtns.Length; i++)
                    {
                        JJCalls c = jj_2_rtns[i];
                        while (c != null)
                        {
                            if (c.gen < jj_gen) c.first = null;
                            c = c.next;
                        }
                    }
                }
                return token;
            }
            token = oldToken;
            jj_kind = kind;
            throw generateParseException();
        }
Exemple #9
0
        private static void jj_add_error_token(MpRegExpId kind, int pos)
        {
            if (pos >= 100)
                return;

            if (pos == jj_endpos + 1)
            {
                jj_lasttokens[jj_endpos++] = (int)kind;
            }
            else if (jj_endpos != 0)
            {
                jj_expentry = new int[jj_endpos];
                for (int i = 0; i < jj_endpos; i++)
                {
                    jj_expentry[i] = jj_lasttokens[i];
                }

                //jj_entries_loop:

                /* for (List<int[]>.Enumerator it = jj_expentries.GetEnumerator(); it.hasNext(); )  */
                foreach (int[] oldentry in jj_expentries)
                {
                    /* int[] oldentry = (int[])(it.Current()); it.MoveNext(); */

                    if (oldentry.Length == jj_expentry.Length)
                    {
                        bool found = false;

                        for (int i = 0; (i < jj_expentry.Length) && !found; i++)
                        {
                            if (oldentry[i] != jj_expentry[i])
                            {
                                /* continue jj_entries_loop; */
                                found = true;
                            }
                        }

                        if (!found)
                        {
                            jj_expentries.Add(jj_expentry);
                            break /* jj_entries_loop */;
                        }
                    }
                }

                if (pos != 0)
                    jj_lasttokens[(jj_endpos = pos) - 1] = (int) kind;
            }
        }
Exemple #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);
            }

            MiniParserTokenManager.ReInit(jj_input_stream);
            token = new MiniToken();
            jj_ntk = MpRegExpId.UNDEFINED;
            jj_gen = 0;
            for (int i = 0; i < 45; i++) jj_la1[i] = -1;
            for (int i = 0; i < jj_2_rtns.Length; i++) jj_2_rtns[i] = new JJCalls();
        }
Exemple #11
0
        /** Constructor with InputStream and supplied encoding */
        public MiniParser(Stream stream, Encoding encoding)
        {
            if (jj_initialized_once)
            {
                ReInit(stream, encoding);
                // System.out.println("ERROR: Second call to constructor of static parser.  ");
                // System.out.println("       You must either use ReInit() or set the JavaCC option STATIC to false");
                // System.out.println("       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 MiniParserTokenManager(jj_input_stream);
            }

            token = new MiniToken();
            jj_ntk = MpRegExpId.UNDEFINED;
            jj_gen = 0;
            for (int i = 0; i < 45; i++) jj_la1[i] = -1;
            for (int i = 0; i < jj_2_rtns.Length; i++) jj_2_rtns[i] = new JJCalls();
        }
Exemple #12
0
 /** Get the next Token. */
 /* final */
 public static MiniToken getNextToken()
 {
     if (token.next != null)
         token = token.next;
     else
         token = token.next = MiniParserTokenManager.getNextToken();
     jj_ntk = MpRegExpId.UNDEFINED;
     jj_gen++;
     return token;
 }