feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,533 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2011, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This source code is provided to illustrate the usage of a given feature
|
||||
* or technique and has been deliberately simplified. Additional steps
|
||||
* required for a production-quality application, such as security checks,
|
||||
* input validation and proper error handling, might not be present in
|
||||
* this sample code.
|
||||
*/
|
||||
|
||||
|
||||
/* Generated By:JavaCC: Do not edit this line. ASCII_UCodeESC_CharStream.java Version 0.7pre6 */
|
||||
|
||||
package com.sun.tools.example.debug.expr;
|
||||
|
||||
/**
|
||||
* An implementation of interface CharStream, where the stream is assumed to
|
||||
* contain only ASCII characters (with java-like unicode escape processing).
|
||||
*/
|
||||
|
||||
public final class ASCII_UCodeESC_CharStream
|
||||
{
|
||||
public static final boolean staticFlag = false;
|
||||
static final int hexval(char c) throws java.io.IOException {
|
||||
switch(c)
|
||||
{
|
||||
case '0' :
|
||||
return 0;
|
||||
case '1' :
|
||||
return 1;
|
||||
case '2' :
|
||||
return 2;
|
||||
case '3' :
|
||||
return 3;
|
||||
case '4' :
|
||||
return 4;
|
||||
case '5' :
|
||||
return 5;
|
||||
case '6' :
|
||||
return 6;
|
||||
case '7' :
|
||||
return 7;
|
||||
case '8' :
|
||||
return 8;
|
||||
case '9' :
|
||||
return 9;
|
||||
|
||||
case 'a' :
|
||||
case 'A' :
|
||||
return 10;
|
||||
case 'b' :
|
||||
case 'B' :
|
||||
return 11;
|
||||
case 'c' :
|
||||
case 'C' :
|
||||
return 12;
|
||||
case 'd' :
|
||||
case 'D' :
|
||||
return 13;
|
||||
case 'e' :
|
||||
case 'E' :
|
||||
return 14;
|
||||
case 'f' :
|
||||
case 'F' :
|
||||
return 15;
|
||||
}
|
||||
|
||||
throw new java.io.IOException(); // Should never come here
|
||||
}
|
||||
|
||||
public int bufpos = -1;
|
||||
int bufsize;
|
||||
int available;
|
||||
int tokenBegin;
|
||||
private int bufline[];
|
||||
private int bufcolumn[];
|
||||
|
||||
private int column = 0;
|
||||
private int line = 1;
|
||||
|
||||
private java.io.InputStream inputStream;
|
||||
|
||||
private boolean prevCharIsCR = false;
|
||||
private boolean prevCharIsLF = false;
|
||||
|
||||
private byte[] nextCharBuf;
|
||||
private char[] buffer;
|
||||
private int maxNextCharInd = 0;
|
||||
private int nextCharInd = -1;
|
||||
private int inBuf = 0;
|
||||
|
||||
private final void ExpandBuff(boolean wrapAround)
|
||||
{
|
||||
char[] newbuffer = new char[bufsize + 2048];
|
||||
int newbufline[] = new int[bufsize + 2048];
|
||||
int newbufcolumn[] = new int[bufsize + 2048];
|
||||
|
||||
try
|
||||
{
|
||||
if (wrapAround)
|
||||
{
|
||||
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
|
||||
System.arraycopy(buffer, 0, newbuffer,
|
||||
bufsize - tokenBegin, bufpos);
|
||||
buffer = newbuffer;
|
||||
|
||||
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
|
||||
System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
|
||||
bufline = newbufline;
|
||||
|
||||
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
|
||||
System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
|
||||
bufcolumn = newbufcolumn;
|
||||
|
||||
bufpos += (bufsize - tokenBegin);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
|
||||
buffer = newbuffer;
|
||||
|
||||
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
|
||||
bufline = newbufline;
|
||||
|
||||
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
|
||||
bufcolumn = newbufcolumn;
|
||||
|
||||
bufpos -= tokenBegin;
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new Error(t.getMessage());
|
||||
}
|
||||
|
||||
available = (bufsize += 2048);
|
||||
tokenBegin = 0;
|
||||
}
|
||||
|
||||
private final void FillBuff() throws java.io.IOException
|
||||
{
|
||||
int i;
|
||||
if (maxNextCharInd == 4096)
|
||||
maxNextCharInd = nextCharInd = 0;
|
||||
|
||||
try {
|
||||
if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
|
||||
4096 - maxNextCharInd)) == -1)
|
||||
{
|
||||
inputStream.close();
|
||||
throw new java.io.IOException();
|
||||
}
|
||||
else
|
||||
maxNextCharInd += i;
|
||||
return;
|
||||
}
|
||||
catch(java.io.IOException e) {
|
||||
if (bufpos != 0)
|
||||
{
|
||||
--bufpos;
|
||||
backup(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bufline[bufpos] = line;
|
||||
bufcolumn[bufpos] = column;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private final byte ReadByte() throws java.io.IOException
|
||||
{
|
||||
if (++nextCharInd >= maxNextCharInd)
|
||||
FillBuff();
|
||||
|
||||
return nextCharBuf[nextCharInd];
|
||||
}
|
||||
|
||||
public final char BeginToken() throws java.io.IOException
|
||||
{
|
||||
if (inBuf > 0)
|
||||
{
|
||||
--inBuf;
|
||||
return buffer[tokenBegin = (bufpos == bufsize - 1) ? (bufpos = 0)
|
||||
: ++bufpos];
|
||||
}
|
||||
|
||||
tokenBegin = 0;
|
||||
bufpos = -1;
|
||||
|
||||
return readChar();
|
||||
}
|
||||
|
||||
private final void AdjustBuffSize()
|
||||
{
|
||||
if (available == bufsize)
|
||||
{
|
||||
if (tokenBegin > 2048)
|
||||
{
|
||||
bufpos = 0;
|
||||
available = tokenBegin;
|
||||
}
|
||||
else
|
||||
ExpandBuff(false);
|
||||
}
|
||||
else if (available > tokenBegin)
|
||||
available = bufsize;
|
||||
else if ((tokenBegin - available) < 2048)
|
||||
ExpandBuff(true);
|
||||
else
|
||||
available = tokenBegin;
|
||||
}
|
||||
|
||||
private final void UpdateLineColumn(char c)
|
||||
{
|
||||
column++;
|
||||
|
||||
if (prevCharIsLF)
|
||||
{
|
||||
prevCharIsLF = false;
|
||||
line += (column = 1);
|
||||
}
|
||||
else if (prevCharIsCR)
|
||||
{
|
||||
prevCharIsCR = false;
|
||||
if (c == '\n')
|
||||
{
|
||||
prevCharIsLF = true;
|
||||
}
|
||||
else
|
||||
line += (column = 1);
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '\r' :
|
||||
prevCharIsCR = true;
|
||||
break;
|
||||
case '\n' :
|
||||
prevCharIsLF = true;
|
||||
break;
|
||||
case '\t' :
|
||||
column--;
|
||||
column += (8 - (column & 07));
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
bufline[bufpos] = line;
|
||||
bufcolumn[bufpos] = column;
|
||||
}
|
||||
|
||||
public final char readChar() throws java.io.IOException
|
||||
{
|
||||
if (inBuf > 0)
|
||||
{
|
||||
--inBuf;
|
||||
return buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos];
|
||||
}
|
||||
|
||||
char c;
|
||||
|
||||
if (++bufpos == available)
|
||||
AdjustBuffSize();
|
||||
|
||||
if (((buffer[bufpos] = c = (char)((char)0xff & ReadByte())) == '\\'))
|
||||
{
|
||||
UpdateLineColumn(c);
|
||||
|
||||
int backSlashCnt = 1;
|
||||
|
||||
for (;;) // Read all the backslashes
|
||||
{
|
||||
if (++bufpos == available)
|
||||
AdjustBuffSize();
|
||||
|
||||
try
|
||||
{
|
||||
if ((buffer[bufpos] = c = (char)((char)0xff & ReadByte())) != '\\')
|
||||
{
|
||||
UpdateLineColumn(c);
|
||||
// found a non-backslash char.
|
||||
if ((c == 'u') && ((backSlashCnt & 1) == 1))
|
||||
{
|
||||
if (--bufpos < 0)
|
||||
bufpos = bufsize - 1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
backup(backSlashCnt);
|
||||
return '\\';
|
||||
}
|
||||
}
|
||||
catch(java.io.IOException e)
|
||||
{
|
||||
if (backSlashCnt > 1)
|
||||
backup(backSlashCnt);
|
||||
|
||||
return '\\';
|
||||
}
|
||||
|
||||
UpdateLineColumn(c);
|
||||
backSlashCnt++;
|
||||
}
|
||||
|
||||
// Here, we have seen an odd number of backslash's followed by a 'u'
|
||||
try
|
||||
{
|
||||
while ((c = (char)((char)0xff & ReadByte())) == 'u')
|
||||
++column;
|
||||
|
||||
buffer[bufpos] = c = (char)(hexval(c) << 12 |
|
||||
hexval((char)((char)0xff & ReadByte())) << 8 |
|
||||
hexval((char)((char)0xff & ReadByte())) << 4 |
|
||||
hexval((char)((char)0xff & ReadByte())));
|
||||
|
||||
column += 4;
|
||||
}
|
||||
catch(java.io.IOException e)
|
||||
{
|
||||
throw new Error("Invalid escape character at line " + line +
|
||||
" column " + column + ".");
|
||||
}
|
||||
|
||||
if (backSlashCnt == 1)
|
||||
return c;
|
||||
else
|
||||
{
|
||||
backup(backSlashCnt - 1);
|
||||
return '\\';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateLineColumn(c);
|
||||
return (c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @see #getEndColumn
|
||||
*/
|
||||
@Deprecated
|
||||
public final int getColumn() {
|
||||
return bufcolumn[bufpos];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @see #getEndLine
|
||||
*/
|
||||
@Deprecated
|
||||
public final int getLine() {
|
||||
return bufline[bufpos];
|
||||
}
|
||||
|
||||
public final int getEndColumn() {
|
||||
return bufcolumn[bufpos];
|
||||
}
|
||||
|
||||
public final int getEndLine() {
|
||||
return bufline[bufpos];
|
||||
}
|
||||
|
||||
public final int getBeginColumn() {
|
||||
return bufcolumn[tokenBegin];
|
||||
}
|
||||
|
||||
public final int getBeginLine() {
|
||||
return bufline[tokenBegin];
|
||||
}
|
||||
|
||||
public final void backup(int amount) {
|
||||
|
||||
inBuf += amount;
|
||||
if ((bufpos -= amount) < 0)
|
||||
bufpos += bufsize;
|
||||
}
|
||||
|
||||
public ASCII_UCodeESC_CharStream(java.io.InputStream dstream,
|
||||
int startline, int startcolumn, int buffersize)
|
||||
{
|
||||
inputStream = dstream;
|
||||
line = startline;
|
||||
column = startcolumn - 1;
|
||||
|
||||
available = bufsize = buffersize;
|
||||
buffer = new char[buffersize];
|
||||
bufline = new int[buffersize];
|
||||
bufcolumn = new int[buffersize];
|
||||
nextCharBuf = new byte[4096];
|
||||
}
|
||||
|
||||
public ASCII_UCodeESC_CharStream(java.io.InputStream dstream,
|
||||
int startline, int startcolumn)
|
||||
{
|
||||
this(dstream, startline, startcolumn, 4096);
|
||||
}
|
||||
public void ReInit(java.io.InputStream dstream,
|
||||
int startline, int startcolumn, int buffersize)
|
||||
{
|
||||
inputStream = dstream;
|
||||
line = startline;
|
||||
column = startcolumn - 1;
|
||||
|
||||
if (buffer == null || buffersize != buffer.length)
|
||||
{
|
||||
available = bufsize = buffersize;
|
||||
buffer = new char[buffersize];
|
||||
bufline = new int[buffersize];
|
||||
bufcolumn = new int[buffersize];
|
||||
nextCharBuf = new byte[4096];
|
||||
}
|
||||
prevCharIsLF = prevCharIsCR = false;
|
||||
tokenBegin = inBuf = maxNextCharInd = 0;
|
||||
nextCharInd = bufpos = -1;
|
||||
}
|
||||
|
||||
public void ReInit(java.io.InputStream dstream,
|
||||
int startline, int startcolumn)
|
||||
{
|
||||
ReInit(dstream, startline, startcolumn, 4096);
|
||||
}
|
||||
|
||||
public final String GetImage()
|
||||
{
|
||||
if (bufpos >= tokenBegin)
|
||||
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
|
||||
else
|
||||
return new String(buffer, tokenBegin, bufsize - tokenBegin) +
|
||||
new String(buffer, 0, bufpos + 1);
|
||||
}
|
||||
|
||||
public final char[] GetSuffix(int len)
|
||||
{
|
||||
char[] ret = new char[len];
|
||||
|
||||
if ((bufpos + 1) >= len)
|
||||
System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
|
||||
else
|
||||
{
|
||||
System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
|
||||
len - bufpos - 1);
|
||||
System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void Done()
|
||||
{
|
||||
nextCharBuf = null;
|
||||
buffer = null;
|
||||
bufline = null;
|
||||
bufcolumn = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to adjust line and column numbers for the start of a token.<BR>
|
||||
*/
|
||||
public void adjustBeginLineColumn(int newLine, int newCol)
|
||||
{
|
||||
int start = tokenBegin;
|
||||
int len;
|
||||
|
||||
if (bufpos >= tokenBegin)
|
||||
{
|
||||
len = bufpos - tokenBegin + inBuf + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
|
||||
}
|
||||
|
||||
int i = 0, j = 0, k = 0;
|
||||
int nextColDiff = 0, columnDiff = 0;
|
||||
|
||||
while (i < len &&
|
||||
bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
|
||||
{
|
||||
bufline[j] = newLine;
|
||||
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
|
||||
bufcolumn[j] = newCol + columnDiff;
|
||||
columnDiff = nextColDiff;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i < len)
|
||||
{
|
||||
bufline[j] = newLine++;
|
||||
bufcolumn[j] = newCol + columnDiff;
|
||||
|
||||
while (i++ < len)
|
||||
{
|
||||
if (bufline[j = start % bufsize] != bufline[++start % bufsize])
|
||||
bufline[j] = newLine++;
|
||||
else
|
||||
bufline[j] = newLine;
|
||||
}
|
||||
}
|
||||
|
||||
line = bufline[j];
|
||||
column = bufcolumn[j];
|
||||
}
|
||||
|
||||
}
|
||||
2350
jdkSrc/jdk8/com/sun/tools/example/debug/expr/ExpressionParser.java
Normal file
2350
jdkSrc/jdk8/com/sun/tools/example/debug/expr/ExpressionParser.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,382 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, 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.
|
||||
*/
|
||||
|
||||
/* Generated By:JavaCC: Do not edit this line. ExpressionParserConstants.java */
|
||||
package com.sun.tools.example.debug.expr;
|
||||
|
||||
|
||||
/**
|
||||
* Token literal values and constants.
|
||||
* Generated by org.javacc.parser.OtherFilesGen#start()
|
||||
*/
|
||||
public interface ExpressionParserConstants {
|
||||
|
||||
/** End of File. */
|
||||
int EOF = 0;
|
||||
/** RegularExpression Id. */
|
||||
int SINGLE_LINE_COMMENT = 6;
|
||||
/** RegularExpression Id. */
|
||||
int FORMAL_COMMENT = 7;
|
||||
/** RegularExpression Id. */
|
||||
int MULTI_LINE_COMMENT = 8;
|
||||
/** RegularExpression Id. */
|
||||
int ABSTRACT = 9;
|
||||
/** RegularExpression Id. */
|
||||
int BOOLEAN = 10;
|
||||
/** RegularExpression Id. */
|
||||
int BREAK = 11;
|
||||
/** RegularExpression Id. */
|
||||
int BYTE = 12;
|
||||
/** RegularExpression Id. */
|
||||
int CASE = 13;
|
||||
/** RegularExpression Id. */
|
||||
int CATCH = 14;
|
||||
/** RegularExpression Id. */
|
||||
int CHAR = 15;
|
||||
/** RegularExpression Id. */
|
||||
int CLASS = 16;
|
||||
/** RegularExpression Id. */
|
||||
int CONST = 17;
|
||||
/** RegularExpression Id. */
|
||||
int CONTINUE = 18;
|
||||
/** RegularExpression Id. */
|
||||
int _DEFAULT = 19;
|
||||
/** RegularExpression Id. */
|
||||
int DO = 20;
|
||||
/** RegularExpression Id. */
|
||||
int DOUBLE = 21;
|
||||
/** RegularExpression Id. */
|
||||
int ELSE = 22;
|
||||
/** RegularExpression Id. */
|
||||
int EXTENDS = 23;
|
||||
/** RegularExpression Id. */
|
||||
int FALSE = 24;
|
||||
/** RegularExpression Id. */
|
||||
int FINAL = 25;
|
||||
/** RegularExpression Id. */
|
||||
int FINALLY = 26;
|
||||
/** RegularExpression Id. */
|
||||
int FLOAT = 27;
|
||||
/** RegularExpression Id. */
|
||||
int FOR = 28;
|
||||
/** RegularExpression Id. */
|
||||
int GOTO = 29;
|
||||
/** RegularExpression Id. */
|
||||
int IF = 30;
|
||||
/** RegularExpression Id. */
|
||||
int IMPLEMENTS = 31;
|
||||
/** RegularExpression Id. */
|
||||
int IMPORT = 32;
|
||||
/** RegularExpression Id. */
|
||||
int INSTANCEOF = 33;
|
||||
/** RegularExpression Id. */
|
||||
int INT = 34;
|
||||
/** RegularExpression Id. */
|
||||
int INTERFACE = 35;
|
||||
/** RegularExpression Id. */
|
||||
int LONG = 36;
|
||||
/** RegularExpression Id. */
|
||||
int NATIVE = 37;
|
||||
/** RegularExpression Id. */
|
||||
int NEW = 38;
|
||||
/** RegularExpression Id. */
|
||||
int NULL = 39;
|
||||
/** RegularExpression Id. */
|
||||
int PACKAGE = 40;
|
||||
/** RegularExpression Id. */
|
||||
int PRIVATE = 41;
|
||||
/** RegularExpression Id. */
|
||||
int PROTECTED = 42;
|
||||
/** RegularExpression Id. */
|
||||
int PUBLIC = 43;
|
||||
/** RegularExpression Id. */
|
||||
int RETURN = 44;
|
||||
/** RegularExpression Id. */
|
||||
int SHORT = 45;
|
||||
/** RegularExpression Id. */
|
||||
int STATIC = 46;
|
||||
/** RegularExpression Id. */
|
||||
int SUPER = 47;
|
||||
/** RegularExpression Id. */
|
||||
int SWITCH = 48;
|
||||
/** RegularExpression Id. */
|
||||
int SYNCHRONIZED = 49;
|
||||
/** RegularExpression Id. */
|
||||
int THIS = 50;
|
||||
/** RegularExpression Id. */
|
||||
int THROW = 51;
|
||||
/** RegularExpression Id. */
|
||||
int THROWS = 52;
|
||||
/** RegularExpression Id. */
|
||||
int TRANSIENT = 53;
|
||||
/** RegularExpression Id. */
|
||||
int TRUE = 54;
|
||||
/** RegularExpression Id. */
|
||||
int TRY = 55;
|
||||
/** RegularExpression Id. */
|
||||
int VOID = 56;
|
||||
/** RegularExpression Id. */
|
||||
int VOLATILE = 57;
|
||||
/** RegularExpression Id. */
|
||||
int WHILE = 58;
|
||||
/** RegularExpression Id. */
|
||||
int INTEGER_LITERAL = 59;
|
||||
/** RegularExpression Id. */
|
||||
int DECIMAL_LITERAL = 60;
|
||||
/** RegularExpression Id. */
|
||||
int HEX_LITERAL = 61;
|
||||
/** RegularExpression Id. */
|
||||
int OCTAL_LITERAL = 62;
|
||||
/** RegularExpression Id. */
|
||||
int FLOATING_POINT_LITERAL = 63;
|
||||
/** RegularExpression Id. */
|
||||
int EXPONENT = 64;
|
||||
/** RegularExpression Id. */
|
||||
int CHARACTER_LITERAL = 65;
|
||||
/** RegularExpression Id. */
|
||||
int STRING_LITERAL = 66;
|
||||
/** RegularExpression Id. */
|
||||
int IDENTIFIER = 67;
|
||||
/** RegularExpression Id. */
|
||||
int LETTER = 68;
|
||||
/** RegularExpression Id. */
|
||||
int DIGIT = 69;
|
||||
/** RegularExpression Id. */
|
||||
int LPAREN = 70;
|
||||
/** RegularExpression Id. */
|
||||
int RPAREN = 71;
|
||||
/** RegularExpression Id. */
|
||||
int LBRACE = 72;
|
||||
/** RegularExpression Id. */
|
||||
int RBRACE = 73;
|
||||
/** RegularExpression Id. */
|
||||
int LBRACKET = 74;
|
||||
/** RegularExpression Id. */
|
||||
int RBRACKET = 75;
|
||||
/** RegularExpression Id. */
|
||||
int SEMICOLON = 76;
|
||||
/** RegularExpression Id. */
|
||||
int COMMA = 77;
|
||||
/** RegularExpression Id. */
|
||||
int DOT = 78;
|
||||
/** RegularExpression Id. */
|
||||
int ASSIGN = 79;
|
||||
/** RegularExpression Id. */
|
||||
int GT = 80;
|
||||
/** RegularExpression Id. */
|
||||
int LT = 81;
|
||||
/** RegularExpression Id. */
|
||||
int BANG = 82;
|
||||
/** RegularExpression Id. */
|
||||
int TILDE = 83;
|
||||
/** RegularExpression Id. */
|
||||
int HOOK = 84;
|
||||
/** RegularExpression Id. */
|
||||
int COLON = 85;
|
||||
/** RegularExpression Id. */
|
||||
int EQ = 86;
|
||||
/** RegularExpression Id. */
|
||||
int LE = 87;
|
||||
/** RegularExpression Id. */
|
||||
int GE = 88;
|
||||
/** RegularExpression Id. */
|
||||
int NE = 89;
|
||||
/** RegularExpression Id. */
|
||||
int SC_OR = 90;
|
||||
/** RegularExpression Id. */
|
||||
int SC_AND = 91;
|
||||
/** RegularExpression Id. */
|
||||
int INCR = 92;
|
||||
/** RegularExpression Id. */
|
||||
int DECR = 93;
|
||||
/** RegularExpression Id. */
|
||||
int PLUS = 94;
|
||||
/** RegularExpression Id. */
|
||||
int MINUS = 95;
|
||||
/** RegularExpression Id. */
|
||||
int STAR = 96;
|
||||
/** RegularExpression Id. */
|
||||
int SLASH = 97;
|
||||
/** RegularExpression Id. */
|
||||
int BIT_AND = 98;
|
||||
/** RegularExpression Id. */
|
||||
int BIT_OR = 99;
|
||||
/** RegularExpression Id. */
|
||||
int XOR = 100;
|
||||
/** RegularExpression Id. */
|
||||
int REM = 101;
|
||||
/** RegularExpression Id. */
|
||||
int LSHIFT = 102;
|
||||
/** RegularExpression Id. */
|
||||
int RSIGNEDSHIFT = 103;
|
||||
/** RegularExpression Id. */
|
||||
int RUNSIGNEDSHIFT = 104;
|
||||
/** RegularExpression Id. */
|
||||
int PLUSASSIGN = 105;
|
||||
/** RegularExpression Id. */
|
||||
int MINUSASSIGN = 106;
|
||||
/** RegularExpression Id. */
|
||||
int STARASSIGN = 107;
|
||||
/** RegularExpression Id. */
|
||||
int SLASHASSIGN = 108;
|
||||
/** RegularExpression Id. */
|
||||
int ANDASSIGN = 109;
|
||||
/** RegularExpression Id. */
|
||||
int ORASSIGN = 110;
|
||||
/** RegularExpression Id. */
|
||||
int XORASSIGN = 111;
|
||||
/** RegularExpression Id. */
|
||||
int REMASSIGN = 112;
|
||||
/** RegularExpression Id. */
|
||||
int LSHIFTASSIGN = 113;
|
||||
/** RegularExpression Id. */
|
||||
int RSIGNEDSHIFTASSIGN = 114;
|
||||
/** RegularExpression Id. */
|
||||
int RUNSIGNEDSHIFTASSIGN = 115;
|
||||
|
||||
/** Lexical state. */
|
||||
int DEFAULT = 0;
|
||||
|
||||
/** Literal token values. */
|
||||
String[] tokenImage = {
|
||||
"<EOF>",
|
||||
"\" \"",
|
||||
"\"\\t\"",
|
||||
"\"\\n\"",
|
||||
"\"\\r\"",
|
||||
"\"\\f\"",
|
||||
"<SINGLE_LINE_COMMENT>",
|
||||
"<FORMAL_COMMENT>",
|
||||
"<MULTI_LINE_COMMENT>",
|
||||
"\"abstract\"",
|
||||
"\"boolean\"",
|
||||
"\"break\"",
|
||||
"\"byte\"",
|
||||
"\"case\"",
|
||||
"\"catch\"",
|
||||
"\"char\"",
|
||||
"\"class\"",
|
||||
"\"const\"",
|
||||
"\"continue\"",
|
||||
"\"default\"",
|
||||
"\"do\"",
|
||||
"\"double\"",
|
||||
"\"else\"",
|
||||
"\"extends\"",
|
||||
"\"false\"",
|
||||
"\"final\"",
|
||||
"\"finally\"",
|
||||
"\"float\"",
|
||||
"\"for\"",
|
||||
"\"goto\"",
|
||||
"\"if\"",
|
||||
"\"implements\"",
|
||||
"\"import\"",
|
||||
"\"instanceof\"",
|
||||
"\"int\"",
|
||||
"\"interface\"",
|
||||
"\"long\"",
|
||||
"\"native\"",
|
||||
"\"new\"",
|
||||
"\"null\"",
|
||||
"\"package\"",
|
||||
"\"private\"",
|
||||
"\"protected\"",
|
||||
"\"public\"",
|
||||
"\"return\"",
|
||||
"\"short\"",
|
||||
"\"static\"",
|
||||
"\"super\"",
|
||||
"\"switch\"",
|
||||
"\"synchronized\"",
|
||||
"\"this\"",
|
||||
"\"throw\"",
|
||||
"\"throws\"",
|
||||
"\"transient\"",
|
||||
"\"true\"",
|
||||
"\"try\"",
|
||||
"\"void\"",
|
||||
"\"volatile\"",
|
||||
"\"while\"",
|
||||
"<INTEGER_LITERAL>",
|
||||
"<DECIMAL_LITERAL>",
|
||||
"<HEX_LITERAL>",
|
||||
"<OCTAL_LITERAL>",
|
||||
"<FLOATING_POINT_LITERAL>",
|
||||
"<EXPONENT>",
|
||||
"<CHARACTER_LITERAL>",
|
||||
"<STRING_LITERAL>",
|
||||
"<IDENTIFIER>",
|
||||
"<LETTER>",
|
||||
"<DIGIT>",
|
||||
"\"(\"",
|
||||
"\")\"",
|
||||
"\"{\"",
|
||||
"\"}\"",
|
||||
"\"[\"",
|
||||
"\"]\"",
|
||||
"\";\"",
|
||||
"\",\"",
|
||||
"\".\"",
|
||||
"\"=\"",
|
||||
"\">\"",
|
||||
"\"<\"",
|
||||
"\"!\"",
|
||||
"\"~\"",
|
||||
"\"?\"",
|
||||
"\":\"",
|
||||
"\"==\"",
|
||||
"\"<=\"",
|
||||
"\">=\"",
|
||||
"\"!=\"",
|
||||
"\"||\"",
|
||||
"\"&&\"",
|
||||
"\"++\"",
|
||||
"\"--\"",
|
||||
"\"+\"",
|
||||
"\"-\"",
|
||||
"\"*\"",
|
||||
"\"/\"",
|
||||
"\"&\"",
|
||||
"\"|\"",
|
||||
"\"^\"",
|
||||
"\"%\"",
|
||||
"\"<<\"",
|
||||
"\">>\"",
|
||||
"\">>>\"",
|
||||
"\"+=\"",
|
||||
"\"-=\"",
|
||||
"\"*=\"",
|
||||
"\"/=\"",
|
||||
"\"&=\"",
|
||||
"\"|=\"",
|
||||
"\"^=\"",
|
||||
"\"%=\"",
|
||||
"\"<<=\"",
|
||||
"\">>=\"",
|
||||
"\">>>=\"",
|
||||
};
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
642
jdkSrc/jdk8/com/sun/tools/example/debug/expr/JavaCharStream.java
Normal file
642
jdkSrc/jdk8/com/sun/tools/example/debug/expr/JavaCharStream.java
Normal file
@@ -0,0 +1,642 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, 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.
|
||||
*/
|
||||
|
||||
/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 5.0 */
|
||||
/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
|
||||
package com.sun.tools.example.debug.expr;
|
||||
|
||||
/**
|
||||
* An implementation of interface CharStream, where the stream is assumed to
|
||||
* contain only ASCII characters (with java-like unicode escape processing).
|
||||
*/
|
||||
|
||||
public
|
||||
class JavaCharStream
|
||||
{
|
||||
/** Whether parser is static. */
|
||||
public static final boolean staticFlag = false;
|
||||
|
||||
static final int hexval(char c) throws java.io.IOException {
|
||||
switch(c)
|
||||
{
|
||||
case '0' :
|
||||
return 0;
|
||||
case '1' :
|
||||
return 1;
|
||||
case '2' :
|
||||
return 2;
|
||||
case '3' :
|
||||
return 3;
|
||||
case '4' :
|
||||
return 4;
|
||||
case '5' :
|
||||
return 5;
|
||||
case '6' :
|
||||
return 6;
|
||||
case '7' :
|
||||
return 7;
|
||||
case '8' :
|
||||
return 8;
|
||||
case '9' :
|
||||
return 9;
|
||||
|
||||
case 'a' :
|
||||
case 'A' :
|
||||
return 10;
|
||||
case 'b' :
|
||||
case 'B' :
|
||||
return 11;
|
||||
case 'c' :
|
||||
case 'C' :
|
||||
return 12;
|
||||
case 'd' :
|
||||
case 'D' :
|
||||
return 13;
|
||||
case 'e' :
|
||||
case 'E' :
|
||||
return 14;
|
||||
case 'f' :
|
||||
case 'F' :
|
||||
return 15;
|
||||
}
|
||||
|
||||
throw new java.io.IOException(); // Should never come here
|
||||
}
|
||||
|
||||
/** Position in buffer. */
|
||||
public int bufpos = -1;
|
||||
int bufsize;
|
||||
int available;
|
||||
int tokenBegin;
|
||||
protected int bufline[];
|
||||
protected int bufcolumn[];
|
||||
|
||||
protected int column = 0;
|
||||
protected int line = 1;
|
||||
|
||||
protected boolean prevCharIsCR = false;
|
||||
protected boolean prevCharIsLF = false;
|
||||
|
||||
protected java.io.Reader inputStream;
|
||||
|
||||
protected char[] nextCharBuf;
|
||||
protected char[] buffer;
|
||||
protected int maxNextCharInd = 0;
|
||||
protected int nextCharInd = -1;
|
||||
protected int inBuf = 0;
|
||||
protected int tabSize = 8;
|
||||
|
||||
protected void setTabSize(int i) { tabSize = i; }
|
||||
protected int getTabSize(int i) { return tabSize; }
|
||||
|
||||
protected void ExpandBuff(boolean wrapAround)
|
||||
{
|
||||
char[] newbuffer = new char[bufsize + 2048];
|
||||
int newbufline[] = new int[bufsize + 2048];
|
||||
int newbufcolumn[] = new int[bufsize + 2048];
|
||||
|
||||
try
|
||||
{
|
||||
if (wrapAround)
|
||||
{
|
||||
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
|
||||
System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
|
||||
buffer = newbuffer;
|
||||
|
||||
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
|
||||
System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
|
||||
bufline = newbufline;
|
||||
|
||||
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
|
||||
System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
|
||||
bufcolumn = newbufcolumn;
|
||||
|
||||
bufpos += (bufsize - tokenBegin);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
|
||||
buffer = newbuffer;
|
||||
|
||||
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
|
||||
bufline = newbufline;
|
||||
|
||||
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
|
||||
bufcolumn = newbufcolumn;
|
||||
|
||||
bufpos -= tokenBegin;
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new Error(t.getMessage());
|
||||
}
|
||||
|
||||
available = (bufsize += 2048);
|
||||
tokenBegin = 0;
|
||||
}
|
||||
|
||||
protected void FillBuff() throws java.io.IOException
|
||||
{
|
||||
int i;
|
||||
if (maxNextCharInd == 4096)
|
||||
maxNextCharInd = nextCharInd = 0;
|
||||
|
||||
try {
|
||||
if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
|
||||
4096 - maxNextCharInd)) == -1)
|
||||
{
|
||||
inputStream.close();
|
||||
throw new java.io.IOException();
|
||||
}
|
||||
else
|
||||
maxNextCharInd += i;
|
||||
return;
|
||||
}
|
||||
catch(java.io.IOException e) {
|
||||
if (bufpos != 0)
|
||||
{
|
||||
--bufpos;
|
||||
backup(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bufline[bufpos] = line;
|
||||
bufcolumn[bufpos] = column;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
protected char ReadByte() throws java.io.IOException
|
||||
{
|
||||
if (++nextCharInd >= maxNextCharInd)
|
||||
FillBuff();
|
||||
|
||||
return nextCharBuf[nextCharInd];
|
||||
}
|
||||
|
||||
/** @return starting character for token. */
|
||||
public char BeginToken() throws java.io.IOException
|
||||
{
|
||||
if (inBuf > 0)
|
||||
{
|
||||
--inBuf;
|
||||
|
||||
if (++bufpos == bufsize)
|
||||
bufpos = 0;
|
||||
|
||||
tokenBegin = bufpos;
|
||||
return buffer[bufpos];
|
||||
}
|
||||
|
||||
tokenBegin = 0;
|
||||
bufpos = -1;
|
||||
|
||||
return readChar();
|
||||
}
|
||||
|
||||
protected void AdjustBuffSize()
|
||||
{
|
||||
if (available == bufsize)
|
||||
{
|
||||
if (tokenBegin > 2048)
|
||||
{
|
||||
bufpos = 0;
|
||||
available = tokenBegin;
|
||||
}
|
||||
else
|
||||
ExpandBuff(false);
|
||||
}
|
||||
else if (available > tokenBegin)
|
||||
available = bufsize;
|
||||
else if ((tokenBegin - available) < 2048)
|
||||
ExpandBuff(true);
|
||||
else
|
||||
available = tokenBegin;
|
||||
}
|
||||
|
||||
protected void UpdateLineColumn(char c)
|
||||
{
|
||||
column++;
|
||||
|
||||
if (prevCharIsLF)
|
||||
{
|
||||
prevCharIsLF = false;
|
||||
line += (column = 1);
|
||||
}
|
||||
else if (prevCharIsCR)
|
||||
{
|
||||
prevCharIsCR = false;
|
||||
if (c == '\n')
|
||||
{
|
||||
prevCharIsLF = true;
|
||||
}
|
||||
else
|
||||
line += (column = 1);
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '\r' :
|
||||
prevCharIsCR = true;
|
||||
break;
|
||||
case '\n' :
|
||||
prevCharIsLF = true;
|
||||
break;
|
||||
case '\t' :
|
||||
column--;
|
||||
column += (tabSize - (column % tabSize));
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
bufline[bufpos] = line;
|
||||
bufcolumn[bufpos] = column;
|
||||
}
|
||||
|
||||
/** Read a character. */
|
||||
public char readChar() throws java.io.IOException
|
||||
{
|
||||
if (inBuf > 0)
|
||||
{
|
||||
--inBuf;
|
||||
|
||||
if (++bufpos == bufsize)
|
||||
bufpos = 0;
|
||||
|
||||
return buffer[bufpos];
|
||||
}
|
||||
|
||||
char c;
|
||||
|
||||
if (++bufpos == available)
|
||||
AdjustBuffSize();
|
||||
|
||||
if ((buffer[bufpos] = c = ReadByte()) == '\\')
|
||||
{
|
||||
UpdateLineColumn(c);
|
||||
|
||||
int backSlashCnt = 1;
|
||||
|
||||
for (;;) // Read all the backslashes
|
||||
{
|
||||
if (++bufpos == available)
|
||||
AdjustBuffSize();
|
||||
|
||||
try
|
||||
{
|
||||
if ((buffer[bufpos] = c = ReadByte()) != '\\')
|
||||
{
|
||||
UpdateLineColumn(c);
|
||||
// found a non-backslash char.
|
||||
if ((c == 'u') && ((backSlashCnt & 1) == 1))
|
||||
{
|
||||
if (--bufpos < 0)
|
||||
bufpos = bufsize - 1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
backup(backSlashCnt);
|
||||
return '\\';
|
||||
}
|
||||
}
|
||||
catch(java.io.IOException e)
|
||||
{
|
||||
// We are returning one backslash so we should only backup (count-1)
|
||||
if (backSlashCnt > 1)
|
||||
backup(backSlashCnt-1);
|
||||
|
||||
return '\\';
|
||||
}
|
||||
|
||||
UpdateLineColumn(c);
|
||||
backSlashCnt++;
|
||||
}
|
||||
|
||||
// Here, we have seen an odd number of backslash's followed by a 'u'
|
||||
try
|
||||
{
|
||||
while ((c = ReadByte()) == 'u')
|
||||
++column;
|
||||
|
||||
buffer[bufpos] = c = (char)(hexval(c) << 12 |
|
||||
hexval(ReadByte()) << 8 |
|
||||
hexval(ReadByte()) << 4 |
|
||||
hexval(ReadByte()));
|
||||
|
||||
column += 4;
|
||||
}
|
||||
catch(java.io.IOException e)
|
||||
{
|
||||
throw new Error("Invalid escape character at line " + line +
|
||||
" column " + column + ".");
|
||||
}
|
||||
|
||||
if (backSlashCnt == 1)
|
||||
return c;
|
||||
else
|
||||
{
|
||||
backup(backSlashCnt - 1);
|
||||
return '\\';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateLineColumn(c);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* @deprecated
|
||||
* @see #getEndColumn
|
||||
*/
|
||||
public int getColumn() {
|
||||
return bufcolumn[bufpos];
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* @deprecated
|
||||
* @see #getEndLine
|
||||
*/
|
||||
public int getLine() {
|
||||
return bufline[bufpos];
|
||||
}
|
||||
|
||||
/** Get end column. */
|
||||
public int getEndColumn() {
|
||||
return bufcolumn[bufpos];
|
||||
}
|
||||
|
||||
/** Get end line. */
|
||||
public int getEndLine() {
|
||||
return bufline[bufpos];
|
||||
}
|
||||
|
||||
/** @return column of token start */
|
||||
public int getBeginColumn() {
|
||||
return bufcolumn[tokenBegin];
|
||||
}
|
||||
|
||||
/** @return line number of token start */
|
||||
public int getBeginLine() {
|
||||
return bufline[tokenBegin];
|
||||
}
|
||||
|
||||
/** Retreat. */
|
||||
public void backup(int amount) {
|
||||
|
||||
inBuf += amount;
|
||||
if ((bufpos -= amount) < 0)
|
||||
bufpos += bufsize;
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public JavaCharStream(java.io.Reader dstream,
|
||||
int startline, int startcolumn, int buffersize)
|
||||
{
|
||||
inputStream = dstream;
|
||||
line = startline;
|
||||
column = startcolumn - 1;
|
||||
|
||||
available = bufsize = buffersize;
|
||||
buffer = new char[buffersize];
|
||||
bufline = new int[buffersize];
|
||||
bufcolumn = new int[buffersize];
|
||||
nextCharBuf = new char[4096];
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public JavaCharStream(java.io.Reader dstream,
|
||||
int startline, int startcolumn)
|
||||
{
|
||||
this(dstream, startline, startcolumn, 4096);
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public JavaCharStream(java.io.Reader dstream)
|
||||
{
|
||||
this(dstream, 1, 1, 4096);
|
||||
}
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.Reader dstream,
|
||||
int startline, int startcolumn, int buffersize)
|
||||
{
|
||||
inputStream = dstream;
|
||||
line = startline;
|
||||
column = startcolumn - 1;
|
||||
|
||||
if (buffer == null || buffersize != buffer.length)
|
||||
{
|
||||
available = bufsize = buffersize;
|
||||
buffer = new char[buffersize];
|
||||
bufline = new int[buffersize];
|
||||
bufcolumn = new int[buffersize];
|
||||
nextCharBuf = new char[4096];
|
||||
}
|
||||
prevCharIsLF = prevCharIsCR = false;
|
||||
tokenBegin = inBuf = maxNextCharInd = 0;
|
||||
nextCharInd = bufpos = -1;
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.Reader dstream,
|
||||
int startline, int startcolumn)
|
||||
{
|
||||
ReInit(dstream, startline, startcolumn, 4096);
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.Reader dstream)
|
||||
{
|
||||
ReInit(dstream, 1, 1, 4096);
|
||||
}
|
||||
/** Constructor. */
|
||||
public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
|
||||
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public JavaCharStream(java.io.InputStream dstream, int startline,
|
||||
int startcolumn, int buffersize)
|
||||
{
|
||||
this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
|
||||
int startcolumn) throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
this(dstream, encoding, startline, startcolumn, 4096);
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public JavaCharStream(java.io.InputStream dstream, int startline,
|
||||
int startcolumn)
|
||||
{
|
||||
this(dstream, startline, startcolumn, 4096);
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
this(dstream, encoding, 1, 1, 4096);
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public JavaCharStream(java.io.InputStream dstream)
|
||||
{
|
||||
this(dstream, 1, 1, 4096);
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream dstream, String encoding, int startline,
|
||||
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream dstream, int startline,
|
||||
int startcolumn, int buffersize)
|
||||
{
|
||||
ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
|
||||
}
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream dstream, String encoding, int startline,
|
||||
int startcolumn) throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
ReInit(dstream, encoding, startline, startcolumn, 4096);
|
||||
}
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream dstream, int startline,
|
||||
int startcolumn)
|
||||
{
|
||||
ReInit(dstream, startline, startcolumn, 4096);
|
||||
}
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
ReInit(dstream, encoding, 1, 1, 4096);
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream dstream)
|
||||
{
|
||||
ReInit(dstream, 1, 1, 4096);
|
||||
}
|
||||
|
||||
/** @return token image as String */
|
||||
public String GetImage()
|
||||
{
|
||||
if (bufpos >= tokenBegin)
|
||||
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
|
||||
else
|
||||
return new String(buffer, tokenBegin, bufsize - tokenBegin) +
|
||||
new String(buffer, 0, bufpos + 1);
|
||||
}
|
||||
|
||||
/** @return suffix */
|
||||
public char[] GetSuffix(int len)
|
||||
{
|
||||
char[] ret = new char[len];
|
||||
|
||||
if ((bufpos + 1) >= len)
|
||||
System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
|
||||
else
|
||||
{
|
||||
System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
|
||||
len - bufpos - 1);
|
||||
System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** Set buffers back to null when finished. */
|
||||
public void Done()
|
||||
{
|
||||
nextCharBuf = null;
|
||||
buffer = null;
|
||||
bufline = null;
|
||||
bufcolumn = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to adjust line and column numbers for the start of a token.
|
||||
*/
|
||||
public void adjustBeginLineColumn(int newLine, int newCol)
|
||||
{
|
||||
int start = tokenBegin;
|
||||
int len;
|
||||
|
||||
if (bufpos >= tokenBegin)
|
||||
{
|
||||
len = bufpos - tokenBegin + inBuf + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
|
||||
}
|
||||
|
||||
int i = 0, j = 0, k = 0;
|
||||
int nextColDiff = 0, columnDiff = 0;
|
||||
|
||||
while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
|
||||
{
|
||||
bufline[j] = newLine;
|
||||
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
|
||||
bufcolumn[j] = newCol + columnDiff;
|
||||
columnDiff = nextColDiff;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i < len)
|
||||
{
|
||||
bufline[j] = newLine++;
|
||||
bufcolumn[j] = newCol + columnDiff;
|
||||
|
||||
while (i++ < len)
|
||||
{
|
||||
if (bufline[j = start % bufsize] != bufline[++start % bufsize])
|
||||
bufline[j] = newLine++;
|
||||
else
|
||||
bufline[j] = newLine;
|
||||
}
|
||||
}
|
||||
|
||||
line = bufline[j];
|
||||
column = bufcolumn[j];
|
||||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=17a580b005f6229e8445521923427bab (do not edit this line) */
|
||||
1163
jdkSrc/jdk8/com/sun/tools/example/debug/expr/LValue.java
Normal file
1163
jdkSrc/jdk8/com/sun/tools/example/debug/expr/LValue.java
Normal file
File diff suppressed because it is too large
Load Diff
212
jdkSrc/jdk8/com/sun/tools/example/debug/expr/ParseException.java
Normal file
212
jdkSrc/jdk8/com/sun/tools/example/debug/expr/ParseException.java
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, 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.
|
||||
*/
|
||||
|
||||
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
|
||||
/* JavaCCOptions:KEEP_LINE_COL=null */
|
||||
package com.sun.tools.example.debug.expr;
|
||||
|
||||
/**
|
||||
* This exception is thrown when parse errors are encountered.
|
||||
* You can explicitly create objects of this exception type by
|
||||
* calling the method generateParseException in the generated
|
||||
* parser.
|
||||
*
|
||||
* You can modify this class to customize your error reporting
|
||||
* mechanisms so long as you retain the public fields.
|
||||
*/
|
||||
public class ParseException extends Exception {
|
||||
|
||||
/**
|
||||
* The version identifier for this Serializable class.
|
||||
* Increment only if the <i>serialized</i> form of the
|
||||
* class changes.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* This constructor is used by the method "generateParseException"
|
||||
* in the generated parser. Calling this constructor generates
|
||||
* a new object of this type with the fields "currentToken",
|
||||
* "expectedTokenSequences", and "tokenImage" set.
|
||||
*/
|
||||
public ParseException(Token currentTokenVal,
|
||||
int[][] expectedTokenSequencesVal,
|
||||
String[] tokenImageVal
|
||||
)
|
||||
{
|
||||
super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));
|
||||
currentToken = currentTokenVal;
|
||||
expectedTokenSequences = expectedTokenSequencesVal;
|
||||
tokenImage = tokenImageVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* The following constructors are for use by you for whatever
|
||||
* purpose you can think of. Constructing the exception in this
|
||||
* manner makes the exception behave in the normal way - i.e., as
|
||||
* documented in the class "Throwable". The fields "errorToken",
|
||||
* "expectedTokenSequences", and "tokenImage" do not contain
|
||||
* relevant information. The JavaCC generated code does not use
|
||||
* these constructors.
|
||||
*/
|
||||
|
||||
public ParseException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/** Constructor with message. */
|
||||
public ParseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is the last token that has been consumed successfully. If
|
||||
* this object has been created due to a parse error, the token
|
||||
* followng this token will (therefore) be the first error token.
|
||||
*/
|
||||
public Token currentToken;
|
||||
|
||||
/**
|
||||
* Each entry in this array is an array of integers. Each array
|
||||
* of integers represents a sequence of tokens (by their ordinal
|
||||
* values) that is expected at this point of the parse.
|
||||
*/
|
||||
public int[][] expectedTokenSequences;
|
||||
|
||||
/**
|
||||
* This is a reference to the "tokenImage" array of the generated
|
||||
* parser within which the parse error occurred. This array is
|
||||
* defined in the generated ...Constants interface.
|
||||
*/
|
||||
public String[] tokenImage;
|
||||
|
||||
/**
|
||||
* It uses "currentToken" and "expectedTokenSequences" to generate a parse
|
||||
* error message and returns it. If this object has been created
|
||||
* due to a parse error, and you do not catch it (it gets thrown
|
||||
* from the parser) the correct error message
|
||||
* gets displayed.
|
||||
*/
|
||||
private static String initialise(Token currentToken,
|
||||
int[][] expectedTokenSequences,
|
||||
String[] tokenImage) {
|
||||
String eol = System.getProperty("line.separator", "\n");
|
||||
StringBuffer expected = new StringBuffer();
|
||||
int maxSize = 0;
|
||||
for (int i = 0; i < expectedTokenSequences.length; i++) {
|
||||
if (maxSize < expectedTokenSequences[i].length) {
|
||||
maxSize = expectedTokenSequences[i].length;
|
||||
}
|
||||
for (int j = 0; j < expectedTokenSequences[i].length; j++) {
|
||||
expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
|
||||
}
|
||||
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
|
||||
expected.append("...");
|
||||
}
|
||||
expected.append(eol).append(" ");
|
||||
}
|
||||
String retval = "Encountered \"";
|
||||
Token tok = currentToken.next;
|
||||
for (int i = 0; i < maxSize; i++) {
|
||||
if (i != 0) retval += " ";
|
||||
if (tok.kind == 0) {
|
||||
retval += tokenImage[0];
|
||||
break;
|
||||
}
|
||||
retval += " " + tokenImage[tok.kind];
|
||||
retval += " \"";
|
||||
retval += add_escapes(tok.image);
|
||||
retval += " \"";
|
||||
tok = tok.next;
|
||||
}
|
||||
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
|
||||
retval += "." + eol;
|
||||
if (expectedTokenSequences.length == 1) {
|
||||
retval += "Was expecting:" + eol + " ";
|
||||
} else {
|
||||
retval += "Was expecting one of:" + eol + " ";
|
||||
}
|
||||
retval += expected.toString();
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* The end of line string for this machine.
|
||||
*/
|
||||
protected String eol = System.getProperty("line.separator", "\n");
|
||||
|
||||
/**
|
||||
* Used to convert raw characters to their escaped version
|
||||
* when these raw version cannot be used as part of an ASCII
|
||||
* string literal.
|
||||
*/
|
||||
static String add_escapes(String str) {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
char ch;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
switch (str.charAt(i))
|
||||
{
|
||||
case 0 :
|
||||
continue;
|
||||
case '\b':
|
||||
retval.append("\\b");
|
||||
continue;
|
||||
case '\t':
|
||||
retval.append("\\t");
|
||||
continue;
|
||||
case '\n':
|
||||
retval.append("\\n");
|
||||
continue;
|
||||
case '\f':
|
||||
retval.append("\\f");
|
||||
continue;
|
||||
case '\r':
|
||||
retval.append("\\r");
|
||||
continue;
|
||||
case '\"':
|
||||
retval.append("\\\"");
|
||||
continue;
|
||||
case '\'':
|
||||
retval.append("\\\'");
|
||||
continue;
|
||||
case '\\':
|
||||
retval.append("\\\\");
|
||||
continue;
|
||||
default:
|
||||
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
|
||||
String s = "0000" + Integer.toString(ch, 16);
|
||||
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
|
||||
} else {
|
||||
retval.append(ch);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return retval.toString();
|
||||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=3c9f049ed2bb6ade635c5bf58a386169 (do not edit this line) */
|
||||
156
jdkSrc/jdk8/com/sun/tools/example/debug/expr/Token.java
Normal file
156
jdkSrc/jdk8/com/sun/tools/example/debug/expr/Token.java
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, 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.
|
||||
*/
|
||||
|
||||
/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
|
||||
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
|
||||
package com.sun.tools.example.debug.expr;
|
||||
|
||||
/**
|
||||
* Describes the input token stream.
|
||||
*/
|
||||
|
||||
public class Token implements java.io.Serializable {
|
||||
|
||||
/**
|
||||
* The version identifier for this Serializable class.
|
||||
* Increment only if the <i>serialized</i> form of the
|
||||
* class changes.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* An integer that describes the kind of this token. This numbering
|
||||
* system is determined by JavaCCParser, and a table of these numbers is
|
||||
* stored in the file ...Constants.java.
|
||||
*/
|
||||
public int kind;
|
||||
|
||||
/** The line number of the first character of this Token. */
|
||||
public int beginLine;
|
||||
/** The column number of the first character of this Token. */
|
||||
public int beginColumn;
|
||||
/** The line number of the last character of this Token. */
|
||||
public int endLine;
|
||||
/** The column number of the last character of this Token. */
|
||||
public int endColumn;
|
||||
|
||||
/**
|
||||
* The string image of the token.
|
||||
*/
|
||||
public String image;
|
||||
|
||||
/**
|
||||
* A reference to the next regular (non-special) token from the input
|
||||
* stream. If this is the last token from the input stream, or if the
|
||||
* token manager has not read tokens beyond this one, this field is
|
||||
* set to null. This is true only if this token is also a regular
|
||||
* token. Otherwise, see below for a description of the contents of
|
||||
* this field.
|
||||
*/
|
||||
public Token next;
|
||||
|
||||
/**
|
||||
* This field is used to access special tokens that occur prior to this
|
||||
* token, but after the immediately preceding regular (non-special) token.
|
||||
* If there are no such special tokens, this field is set to null.
|
||||
* When there are more than one such special token, this field refers
|
||||
* to the last of these special tokens, which in turn refers to the next
|
||||
* previous special token through its specialToken field, and so on
|
||||
* until the first special token (whose specialToken field is null).
|
||||
* The next fields of special tokens refer to other special tokens that
|
||||
* immediately follow it (without an intervening regular token). If there
|
||||
* is no such token, this field is null.
|
||||
*/
|
||||
public Token specialToken;
|
||||
|
||||
/**
|
||||
* An optional attribute value of the Token.
|
||||
* Tokens which are not used as syntactic sugar will often contain
|
||||
* meaningful values that will be used later on by the compiler or
|
||||
* interpreter. This attribute value is often different from the image.
|
||||
* Any subclass of Token that actually wants to return a non-null value can
|
||||
* override this method as appropriate.
|
||||
*/
|
||||
public Object getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* No-argument constructor
|
||||
*/
|
||||
public Token() {}
|
||||
|
||||
/**
|
||||
* Constructs a new token for the specified Image.
|
||||
*/
|
||||
public Token(int kind)
|
||||
{
|
||||
this(kind, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new token for the specified Image and Kind.
|
||||
*/
|
||||
public Token(int kind, String image)
|
||||
{
|
||||
this.kind = kind;
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new Token object, by default. However, if you want, you
|
||||
* can create and return subclass objects based on the value of ofKind.
|
||||
* Simply add the cases to the switch for all those special cases.
|
||||
* For example, if you have a subclass of Token called IDToken that
|
||||
* you want to create if ofKind is ID, simply add something like :
|
||||
*
|
||||
* case MyParserConstants.ID : return new IDToken(ofKind, image);
|
||||
*
|
||||
* to the following switch statement. Then you can cast matchedToken
|
||||
* variable to the appropriate type and use sit in your lexical actions.
|
||||
*/
|
||||
public static Token newToken(int ofKind, String image)
|
||||
{
|
||||
switch(ofKind)
|
||||
{
|
||||
default : return new Token(ofKind, image);
|
||||
}
|
||||
}
|
||||
|
||||
public static Token newToken(int ofKind)
|
||||
{
|
||||
return newToken(ofKind, null);
|
||||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=1f1783cae2d4cc94bc225889842dfa8b (do not edit this line) */
|
||||
172
jdkSrc/jdk8/com/sun/tools/example/debug/expr/TokenMgrError.java
Normal file
172
jdkSrc/jdk8/com/sun/tools/example/debug/expr/TokenMgrError.java
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, 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.
|
||||
*/
|
||||
|
||||
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
|
||||
/* JavaCCOptions: */
|
||||
package com.sun.tools.example.debug.expr;
|
||||
|
||||
/** Token Manager Error. */
|
||||
public class TokenMgrError extends Error
|
||||
{
|
||||
|
||||
/**
|
||||
* The version identifier for this Serializable class.
|
||||
* Increment only if the <i>serialized</i> form of the
|
||||
* class changes.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Ordinals for various reasons why an Error of this type can be thrown.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lexical error occurred.
|
||||
*/
|
||||
static final int LEXICAL_ERROR = 0;
|
||||
|
||||
/**
|
||||
* An attempt was made to create a second instance of a static token manager.
|
||||
*/
|
||||
static final int STATIC_LEXER_ERROR = 1;
|
||||
|
||||
/**
|
||||
* Tried to change to an invalid lexical state.
|
||||
*/
|
||||
static final int INVALID_LEXICAL_STATE = 2;
|
||||
|
||||
/**
|
||||
* Detected (and bailed out of) an infinite loop in the token manager.
|
||||
*/
|
||||
static final int LOOP_DETECTED = 3;
|
||||
|
||||
/**
|
||||
* Indicates the reason why the exception is thrown. It will have
|
||||
* one of the above 4 values.
|
||||
*/
|
||||
int errorCode;
|
||||
|
||||
/**
|
||||
* Replaces unprintable characters by their escaped (or unicode escaped)
|
||||
* equivalents in the given string
|
||||
*/
|
||||
protected static final String addEscapes(String str) {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
char ch;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
switch (str.charAt(i))
|
||||
{
|
||||
case 0 :
|
||||
continue;
|
||||
case '\b':
|
||||
retval.append("\\b");
|
||||
continue;
|
||||
case '\t':
|
||||
retval.append("\\t");
|
||||
continue;
|
||||
case '\n':
|
||||
retval.append("\\n");
|
||||
continue;
|
||||
case '\f':
|
||||
retval.append("\\f");
|
||||
continue;
|
||||
case '\r':
|
||||
retval.append("\\r");
|
||||
continue;
|
||||
case '\"':
|
||||
retval.append("\\\"");
|
||||
continue;
|
||||
case '\'':
|
||||
retval.append("\\\'");
|
||||
continue;
|
||||
case '\\':
|
||||
retval.append("\\\\");
|
||||
continue;
|
||||
default:
|
||||
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
|
||||
String s = "0000" + Integer.toString(ch, 16);
|
||||
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
|
||||
} else {
|
||||
retval.append(ch);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return retval.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a detailed message for the Error when it is thrown by the
|
||||
* token manager to indicate a lexical error.
|
||||
* Parameters :
|
||||
* EOFSeen : indicates if EOF caused the lexical error
|
||||
* curLexState : lexical state in which this error occurred
|
||||
* errorLine : line number when the error occurred
|
||||
* errorColumn : column number when the error occurred
|
||||
* errorAfter : prefix that was seen before this error occurred
|
||||
* curchar : the offending character
|
||||
* Note: You can customize the lexical error message by modifying this method.
|
||||
*/
|
||||
protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
|
||||
return("Lexical error at line " +
|
||||
errorLine + ", column " +
|
||||
errorColumn + ". Encountered: " +
|
||||
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
|
||||
"after : \"" + addEscapes(errorAfter) + "\"");
|
||||
}
|
||||
|
||||
/**
|
||||
* You can also modify the body of this method to customize your error messages.
|
||||
* For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
|
||||
* of end-users concern, so you can return something like :
|
||||
*
|
||||
* "Internal Error : Please file a bug report .... "
|
||||
*
|
||||
* from this method for such cases in the release version of your parser.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return super.getMessage();
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructors of various flavors follow.
|
||||
*/
|
||||
|
||||
/** No arg constructor. */
|
||||
public TokenMgrError() {
|
||||
}
|
||||
|
||||
/** Constructor with message and reason. */
|
||||
public TokenMgrError(String message, int reason) {
|
||||
super(message);
|
||||
errorCode = reason;
|
||||
}
|
||||
|
||||
/** Full Constructor. */
|
||||
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
|
||||
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
|
||||
}
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=9b5d040f247411cad7f77688386c48e7 (do not edit this line) */
|
||||
Reference in New Issue
Block a user