src/share/classes/com/sun/tools/example/debug/expr/ExpressionParser.java

Print this page


   1 /*
   2  * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


2155     jj_ntk = -1;
2156     if (token.kind == kind) {
2157       jj_gen++;
2158       if (++jj_gc > 100) {
2159         jj_gc = 0;
2160         for (int i = 0; i < jj_2_rtns.length; i++) {
2161           JJCalls c = jj_2_rtns[i];
2162           while (c != null) {
2163             if (c.gen < jj_gen) c.first = null;
2164             c = c.next;
2165           }
2166         }
2167       }
2168       return token;
2169     }
2170     token = oldToken;
2171     jj_kind = kind;
2172     throw generateParseException();
2173   }
2174 

2175   static private final class LookaheadSuccess extends java.lang.Error { }
2176   final private LookaheadSuccess jj_ls = new LookaheadSuccess();
2177   private boolean jj_scan_token(int kind) {
2178     if (jj_scanpos == jj_lastpos) {
2179       jj_la--;
2180       if (jj_scanpos.next == null) {
2181         jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
2182       } else {
2183         jj_lastpos = jj_scanpos = jj_scanpos.next;
2184       }
2185     } else {
2186       jj_scanpos = jj_scanpos.next;
2187     }
2188     if (jj_rescan) {
2189       int i = 0; Token tok = token;
2190       while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
2191       if (tok != null) jj_add_error_token(kind, i);
2192     }
2193     if (jj_scanpos.kind != kind) return true;
2194     if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;


   1 /*
   2  * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


2155     jj_ntk = -1;
2156     if (token.kind == kind) {
2157       jj_gen++;
2158       if (++jj_gc > 100) {
2159         jj_gc = 0;
2160         for (int i = 0; i < jj_2_rtns.length; i++) {
2161           JJCalls c = jj_2_rtns[i];
2162           while (c != null) {
2163             if (c.gen < jj_gen) c.first = null;
2164             c = c.next;
2165           }
2166         }
2167       }
2168       return token;
2169     }
2170     token = oldToken;
2171     jj_kind = kind;
2172     throw generateParseException();
2173   }
2174 
2175   @SuppressWarnings("serial") // JDK implementation class
2176   static private final class LookaheadSuccess extends java.lang.Error { }
2177   final private LookaheadSuccess jj_ls = new LookaheadSuccess();
2178   private boolean jj_scan_token(int kind) {
2179     if (jj_scanpos == jj_lastpos) {
2180       jj_la--;
2181       if (jj_scanpos.next == null) {
2182         jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
2183       } else {
2184         jj_lastpos = jj_scanpos = jj_scanpos.next;
2185       }
2186     } else {
2187       jj_scanpos = jj_scanpos.next;
2188     }
2189     if (jj_rescan) {
2190       int i = 0; Token tok = token;
2191       while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
2192       if (tok != null) jj_add_error_token(kind, i);
2193     }
2194     if (jj_scanpos.kind != kind) return true;
2195     if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;