feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
45
jdkSrc/jdk8/com/sun/java_cup/internal/runtime/Scanner.java
Normal file
45
jdkSrc/jdk8/com/sun/java_cup/internal/runtime/Scanner.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java_cup.internal.runtime;
|
||||
|
||||
/**
|
||||
* Defines the Scanner interface, which CUP uses in the default
|
||||
* implementation of <code>lr_parser.scan()</code>. Integration
|
||||
* of scanners implementing <code>Scanner</code> is facilitated.
|
||||
*
|
||||
* @author David MacMahon <davidm@smartsc.com>
|
||||
*/
|
||||
|
||||
/* *************************************************
|
||||
Interface Scanner
|
||||
|
||||
Declares the next_token() method that should be
|
||||
implemented by scanners. This method is typically
|
||||
called by lr_parser.scan().
|
||||
***************************************************/
|
||||
public interface Scanner {
|
||||
public Symbol next_token() throws java.lang.Exception;
|
||||
}
|
||||
129
jdkSrc/jdk8/com/sun/java_cup/internal/runtime/Symbol.java
Normal file
129
jdkSrc/jdk8/com/sun/java_cup/internal/runtime/Symbol.java
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java_cup.internal.runtime;
|
||||
|
||||
/**
|
||||
* Defines the Symbol class, which is used to represent all terminals
|
||||
* and nonterminals while parsing. The lexer should pass CUP Symbols
|
||||
* and CUP returns a Symbol.
|
||||
*
|
||||
* @author Frank Flannery
|
||||
*/
|
||||
|
||||
/* ****************************************************************
|
||||
Class Symbol
|
||||
what the parser expects to receive from the lexer.
|
||||
the token is identified as follows:
|
||||
sym: the symbol type
|
||||
parse_state: the parse state.
|
||||
value: is the lexical value of type Object
|
||||
left : is the left position in the original input file
|
||||
right: is the right position in the original input file
|
||||
******************************************************************/
|
||||
|
||||
public class Symbol {
|
||||
|
||||
/*******************************
|
||||
Constructor for l,r values
|
||||
*******************************/
|
||||
|
||||
public Symbol(int id, int l, int r, Object o) {
|
||||
this(id);
|
||||
left = l;
|
||||
right = r;
|
||||
value = o;
|
||||
}
|
||||
|
||||
/*******************************
|
||||
Constructor for no l,r values
|
||||
********************************/
|
||||
|
||||
public Symbol(int id, Object o) {
|
||||
this(id);
|
||||
left = -1;
|
||||
right = -1;
|
||||
value = o;
|
||||
}
|
||||
|
||||
/*****************************
|
||||
Constructor for no value
|
||||
***************************/
|
||||
|
||||
public Symbol(int sym_num, int l, int r) {
|
||||
sym = sym_num;
|
||||
left = l;
|
||||
right = r;
|
||||
value = null;
|
||||
}
|
||||
|
||||
/***********************************
|
||||
Constructor for no value or l,r
|
||||
***********************************/
|
||||
|
||||
public Symbol(int sym_num) {
|
||||
this(sym_num, -1);
|
||||
left = -1;
|
||||
right = -1;
|
||||
value = null;
|
||||
}
|
||||
|
||||
/***********************************
|
||||
Constructor to give a start state
|
||||
***********************************/
|
||||
public Symbol(int sym_num, int state)
|
||||
{
|
||||
sym = sym_num;
|
||||
parse_state = state;
|
||||
}
|
||||
|
||||
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
|
||||
|
||||
/** The symbol number of the terminal or non terminal being represented */
|
||||
public int sym;
|
||||
|
||||
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
|
||||
|
||||
/** The parse state to be recorded on the parse stack with this symbol.
|
||||
* This field is for the convenience of the parser and shouldn't be
|
||||
* modified except by the parser.
|
||||
*/
|
||||
public int parse_state;
|
||||
/** This allows us to catch some errors caused by scanners recycling
|
||||
* symbols. For the use of the parser only. [CSA, 23-Jul-1999] */
|
||||
boolean used_by_parser = false;
|
||||
|
||||
/*******************************
|
||||
The data passed to parser
|
||||
*******************************/
|
||||
|
||||
public int left, right;
|
||||
public Object value;
|
||||
|
||||
/*****************************
|
||||
Printing this token out. (Override for pretty-print).
|
||||
****************************/
|
||||
public String toString() { return "#"+sym; }
|
||||
}
|
||||
1312
jdkSrc/jdk8/com/sun/java_cup/internal/runtime/lr_parser.java
Normal file
1312
jdkSrc/jdk8/com/sun/java_cup/internal/runtime/lr_parser.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.java_cup.internal.runtime;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
/** This class implements a temporary or "virtual" parse stack that
|
||||
* replaces the top portion of the actual parse stack (the part that
|
||||
* has been changed by some set of operations) while maintaining its
|
||||
* original contents. This data structure is used when the parse needs
|
||||
* to "parse ahead" to determine if a given error recovery attempt will
|
||||
* allow the parse to continue far enough to consider it successful. Once
|
||||
* success or failure of parse ahead is determined the system then
|
||||
* reverts to the original parse stack (which has not actually been
|
||||
* modified). Since parse ahead does not execute actions, only parse
|
||||
* state is maintained on the virtual stack, not full Symbol objects.
|
||||
*
|
||||
* @see com.sun.java_cup.internal.runtime.lr_parser
|
||||
* @author Frank Flannery
|
||||
*/
|
||||
|
||||
public class virtual_parse_stack {
|
||||
/*-----------------------------------------------------------*/
|
||||
/*--- Constructor(s) ----------------------------------------*/
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/** Constructor to build a virtual stack out of a real stack. */
|
||||
public virtual_parse_stack(Stack shadowing_stack) throws java.lang.Exception
|
||||
{
|
||||
/* sanity check */
|
||||
if (shadowing_stack == null)
|
||||
throw new Exception(
|
||||
"Internal parser error: attempt to create null virtual stack");
|
||||
|
||||
/* set up our internals */
|
||||
real_stack = shadowing_stack;
|
||||
vstack = new Stack();
|
||||
real_next = 0;
|
||||
|
||||
/* get one element onto the virtual portion of the stack */
|
||||
get_from_real();
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
/*--- (Access to) Instance Variables ------------------------*/
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/** The real stack that we shadow. This is accessed when we move off
|
||||
* the bottom of the virtual portion of the stack, but is always left
|
||||
* unmodified.
|
||||
*/
|
||||
protected Stack real_stack;
|
||||
|
||||
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
|
||||
|
||||
/** Top of stack indicator for where we leave off in the real stack.
|
||||
* This is measured from top of stack, so 0 would indicate that no
|
||||
* elements have been "moved" from the real to virtual stack.
|
||||
*/
|
||||
protected int real_next;
|
||||
|
||||
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
|
||||
|
||||
/** The virtual top portion of the stack. This stack contains Integer
|
||||
* objects with state numbers. This stack shadows the top portion
|
||||
* of the real stack within the area that has been modified (via operations
|
||||
* on the virtual stack). When this portion of the stack becomes empty we
|
||||
* transfer elements from the underlying stack onto this stack.
|
||||
*/
|
||||
protected Stack vstack;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
/*--- General Methods ---------------------------------------*/
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/** Transfer an element from the real to the virtual stack. This assumes
|
||||
* that the virtual stack is currently empty.
|
||||
*/
|
||||
protected void get_from_real()
|
||||
{
|
||||
Symbol stack_sym;
|
||||
|
||||
/* don't transfer if the real stack is empty */
|
||||
if (real_next >= real_stack.size()) return;
|
||||
|
||||
/* get a copy of the first Symbol we have not transfered */
|
||||
stack_sym = (Symbol)real_stack.elementAt(real_stack.size()-1-real_next);
|
||||
|
||||
/* record the transfer */
|
||||
real_next++;
|
||||
|
||||
/* put the state number from the Symbol onto the virtual stack */
|
||||
vstack.push(new Integer(stack_sym.parse_state));
|
||||
}
|
||||
|
||||
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
|
||||
|
||||
/** Indicate whether the stack is empty. */
|
||||
public boolean empty()
|
||||
{
|
||||
/* if vstack is empty then we were unable to transfer onto it and
|
||||
the whole thing is empty. */
|
||||
return vstack.empty();
|
||||
}
|
||||
|
||||
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
|
||||
|
||||
/** Return value on the top of the stack (without popping it). */
|
||||
public int top() throws java.lang.Exception
|
||||
{
|
||||
if (vstack.empty())
|
||||
throw new Exception(
|
||||
"Internal parser error: top() called on empty virtual stack");
|
||||
|
||||
return ((Integer)vstack.peek()).intValue();
|
||||
}
|
||||
|
||||
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
|
||||
|
||||
/** Pop the stack. */
|
||||
public void pop() throws java.lang.Exception
|
||||
{
|
||||
if (vstack.empty())
|
||||
throw new Exception(
|
||||
"Internal parser error: pop from empty virtual stack");
|
||||
|
||||
/* pop it */
|
||||
vstack.pop();
|
||||
|
||||
/* if we are now empty transfer an element (if there is one) */
|
||||
if (vstack.empty())
|
||||
get_from_real();
|
||||
}
|
||||
|
||||
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
|
||||
|
||||
/** Push a state number onto the stack. */
|
||||
public void push(int state_num)
|
||||
{
|
||||
vstack.push(new Integer(state_num));
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user