- The Eclipse Foundation makes available all content in this plug-in
- ("Content"). Unless otherwise indicated below, the Content
- is provided to you under the terms and conditions of the Eclipse
- Public License Version 2.0 ("EPL"). A copy of the EPL is
- available at http://www.eclipse.org/legal/epl-2.0.
- For purposes of the EPL, "Program" will mean the Content.
-
-
-
- If you did not receive this Content directly from the Eclipse
- Foundation, the Content is being redistributed by another party
- ("Redistributor") and different terms and conditions may
- apply to your use of any object code in the Content. Check the
- Redistributor's license that was provided with the Content. If no such
- license exists, contact the Redistributor. Unless otherwise indicated
- below, the terms and conditions of the EPL still apply to any source
- code in the Content and such source code may be obtained at http://www.eclipse.org.
-
- The Content includes items that have been sourced from third
- parties as set out below. If you did not receive this Content directly
- from the Eclipse Foundation, the following is provided for
- informational purposes only, and you should look to the
- Redistributor’s license for terms and conditions of use.
-
-
-
Eclipse Public License - v 2.0
-
-
-
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
- PUBLIC LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION
- OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
-
-
1. DEFINITIONS
-
“Contribution” means:
-
- - a) in the case of the initial Contributor, the initial content
- Distributed under this Agreement, and
-
- -
- b) in the case of each subsequent Contributor:
-
- - i) changes to the Program, and
- - ii) additions to the Program;
-
- where such changes and/or additions to the Program originate from
- and are Distributed by that particular Contributor. A Contribution
- “originates” from a Contributor if it was added to the Program by such
- Contributor itself or anyone acting on such Contributor's behalf.
- Contributions do not include changes or additions to the Program that
- are not Modified Works.
-
-
-
“Contributor” means any person or entity that Distributes the Program.
-
“Licensed Patents” mean patent claims licensable by a Contributor which
- are necessarily infringed by the use or sale of its Contribution alone
- or when combined with the Program.
-
-
“Program” means the Contributions Distributed in accordance with this
- Agreement.
-
-
“Recipient” means anyone who receives the Program under this Agreement
- or any Secondary License (as applicable), including Contributors.
-
-
“Derivative Works” shall mean any work, whether in Source Code or other
- form, that is based on (or derived from) the Program and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship.
-
-
“Modified Works” shall mean any work in Source Code or other form that
- results from an addition to, deletion from, or modification of the
- contents of the Program, including, for purposes of clarity any new file
- in Source Code form that contains any contents of the Program. Modified
- Works shall not include works that contain only declarations, interfaces,
- types, classes, structures, or files of the Program solely in each case
- in order to link to, bind by name, or subclass the Program or Modified
- Works thereof.
-
-
“Distribute” means the acts of a) distributing or b) making available
- in any manner that enables the transfer of a copy.
-
-
“Source Code” means the form of a Program preferred for making
- modifications, including but not limited to software source code,
- documentation source, and configuration files.
-
-
“Secondary License” means either the GNU General Public License,
- Version 2.0, or any later versions of that license, including any
- exceptions or additional permissions as identified by the initial
- Contributor.
-
-
2. GRANT OF RIGHTS
-
- - a) Subject to the terms of this Agreement, each Contributor hereby
- grants Recipient a non-exclusive, worldwide, royalty-free copyright
- license to reproduce, prepare Derivative Works of, publicly display,
- publicly perform, Distribute and sublicense the Contribution of such
- Contributor, if any, and such Derivative Works.
-
- - b) Subject to the terms of this Agreement, each Contributor hereby
- grants Recipient a non-exclusive, worldwide, royalty-free patent
- license under Licensed Patents to make, use, sell, offer to sell,
- import and otherwise transfer the Contribution of such Contributor,
- if any, in Source Code or other form. This patent license shall
- apply to the combination of the Contribution and the Program if,
- at the time the Contribution is added by the Contributor, such
- addition of the Contribution causes such combination to be covered
- by the Licensed Patents. The patent license shall not apply to any
- other combinations which include the Contribution. No hardware per
- se is licensed hereunder.
-
- - c) Recipient understands that although each Contributor grants the
- licenses to its Contributions set forth herein, no assurances are
- provided by any Contributor that the Program does not infringe the
- patent or other intellectual property rights of any other entity.
- Each Contributor disclaims any liability to Recipient for claims
- brought by any other entity based on infringement of intellectual
- property rights or otherwise. As a condition to exercising the rights
- and licenses granted hereunder, each Recipient hereby assumes sole
- responsibility to secure any other intellectual property rights needed,
- if any. For example, if a third party patent license is required to
- allow Recipient to Distribute the Program, it is Recipient's
- responsibility to acquire that license before distributing the Program.
-
- - d) Each Contributor represents that to its knowledge it has sufficient
- copyright rights in its Contribution, if any, to grant the copyright
- license set forth in this Agreement.
-
- - e) Notwithstanding the terms of any Secondary License, no Contributor
- makes additional grants to any Recipient (other than those set forth
- in this Agreement) as a result of such Recipient's receipt of the
- Program under the terms of a Secondary License (if permitted under
- the terms of Section 3).
-
-
-
3. REQUIREMENTS
-
3.1 If a Contributor Distributes the Program in any form, then:
-
- - a) the Program must also be made available as Source Code, in
- accordance with section 3.2, and the Contributor must accompany
- the Program with a statement that the Source Code for the Program
- is available under this Agreement, and informs Recipients how to
- obtain it in a reasonable manner on or through a medium customarily
- used for software exchange; and
-
- -
- b) the Contributor may Distribute the Program under a license
- different than this Agreement, provided that such license:
-
- - i) effectively disclaims on behalf of all other Contributors all
- warranties and conditions, express and implied, including warranties
- or conditions of title and non-infringement, and implied warranties
- or conditions of merchantability and fitness for a particular purpose;
-
- - ii) effectively excludes on behalf of all other Contributors all
- liability for damages, including direct, indirect, special, incidental
- and consequential damages, such as lost profits;
-
- - iii) does not attempt to limit or alter the recipients' rights in the
- Source Code under section 3.2; and
-
- - iv) requires any subsequent distribution of the Program by any party
- to be under a license that satisfies the requirements of this section 3.
-
-
-
-
-
3.2 When the Program is Distributed as Source Code:
-
- - a) it must be made available under this Agreement, or if the Program (i)
- is combined with other material in a separate file or files made available
- under a Secondary License, and (ii) the initial Contributor attached to
- the Source Code the notice described in Exhibit A of this Agreement,
- then the Program may be made available under the terms of such
- Secondary Licenses, and
-
- - b) a copy of this Agreement must be included with each copy of the Program.
-
-
3.3 Contributors may not remove or alter any copyright, patent, trademark,
- attribution notices, disclaimers of warranty, or limitations of liability
- (‘notices’) contained within the Program from any copy of the Program which
- they Distribute, provided that Contributors may add their own appropriate
- notices.
-
-
4. COMMERCIAL DISTRIBUTION
-
Commercial distributors of software may accept certain responsibilities
- with respect to end users, business partners and the like. While this
- license is intended to facilitate the commercial use of the Program, the
- Contributor who includes the Program in a commercial product offering should
- do so in a manner which does not create potential liability for other
- Contributors. Therefore, if a Contributor includes the Program in a
- commercial product offering, such Contributor (“Commercial Contributor”)
- hereby agrees to defend and indemnify every other Contributor
- (“Indemnified Contributor”) against any losses, damages and costs
- (collectively “Losses”) arising from claims, lawsuits and other legal actions
- brought by a third party against the Indemnified Contributor to the extent
- caused by the acts or omissions of such Commercial Contributor in connection
- with its distribution of the Program in a commercial product offering.
- The obligations in this section do not apply to any claims or Losses relating
- to any actual or alleged intellectual property infringement. In order to
- qualify, an Indemnified Contributor must: a) promptly notify the
- Commercial Contributor in writing of such claim, and b) allow the Commercial
- Contributor to control, and cooperate with the Commercial Contributor in,
- the defense and any related settlement negotiations. The Indemnified
- Contributor may participate in any such claim at its own expense.
-
-
For example, a Contributor might include the Program
- in a commercial product offering, Product X. That Contributor is then a
- Commercial Contributor. If that Commercial Contributor then makes performance
- claims, or offers warranties related to Product X, those performance claims
- and warranties are such Commercial Contributor's responsibility alone.
- Under this section, the Commercial Contributor would have to defend claims
- against the other Contributors related to those performance claims and
- warranties, and if a court requires any other Contributor to pay any damages
- as a result, the Commercial Contributor must pay those damages.
-
-
5. NO WARRANTY
-
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED
- BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT
- WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
- WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
- solely responsible for determining the appropriateness of using and
- distributing the Program and assumes all risks associated with its
- exercise of rights under this Agreement, including but not limited to the
- risks and costs of program errors, compliance with applicable laws, damage
- to or loss of data, programs or equipment, and unavailability or
- interruption of operations.
-
-
6. DISCLAIMER OF LIABILITY
-
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED
- BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY
- LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS),
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
- GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
-
7. GENERAL
-
If any provision of this Agreement is invalid or unenforceable under
- applicable law, it shall not affect the validity or enforceability of the
- remainder of the terms of this Agreement, and without further action by the
- parties hereto, such provision shall be reformed to the minimum extent
- necessary to make such provision valid and enforceable.
-
-
If Recipient institutes patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Program itself
- (excluding combinations of the Program with other software or hardware)
- infringes such Recipient's patent(s), then such Recipient's rights granted
- under Section 2(b) shall terminate as of the date such litigation is filed.
-
-
All Recipient's rights under this Agreement shall terminate if it fails to
- comply with any of the material terms or conditions of this Agreement and
- does not cure such failure in a reasonable period of time after becoming
- aware of such noncompliance. If all Recipient's rights under this Agreement
- terminate, Recipient agrees to cease use and distribution of the Program
- as soon as reasonably practicable. However, Recipient's obligations under
- this Agreement and any licenses granted by Recipient relating to the
- Program shall continue and survive.
-
-
Everyone is permitted to copy and distribute copies of this Agreement,
- but in order to avoid inconsistency the Agreement is copyrighted and may
- only be modified in the following manner. The Agreement Steward reserves
- the right to publish new versions (including revisions) of this Agreement
- from time to time. No one other than the Agreement Steward has the right
- to modify this Agreement. The Eclipse Foundation is the initial Agreement
- Steward. The Eclipse Foundation may assign the responsibility to serve as
- the Agreement Steward to a suitable separate entity. Each new version of
- the Agreement will be given a distinguishing version number. The Program
- (including Contributions) may always be Distributed subject to the version
- of the Agreement under which it was received. In addition, after a new
- version of the Agreement is published, Contributor may elect to Distribute
- the Program (including its Contributions) under the new version.
-
-
Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
- receives no rights or licenses to the intellectual property of any
- Contributor under this Agreement, whether expressly, by implication,
- estoppel or otherwise. All rights in the Program not expressly granted
- under this Agreement are reserved. Nothing in this Agreement is intended
- to be enforceable by any entity that is not a Contributor or Recipient.
- No third-party beneficiary rights are created under this Agreement.
-
-
Exhibit A – Form of Secondary Licenses Notice
-
“This Source Code may also be made available under the following
- Secondary Licenses when the conditions for such availability set forth
- in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
- version(s), and exceptions or additional permissions here}.”
-
-
- Simply including a copy of this Agreement, including this Exhibit A
- is not sufficient to license the Source Code under Secondary Licenses.
-
- If it is not possible or desirable to put the notice in a particular file,
- then You may include the notice in a location (such as a LICENSE file in a
- relevant directory) where a recipient would be likely to look for
- such a notice.
-
- You may add additional accurate notices of copyright ownership.
-
-
-
-
-
-
-
-
ANTLR 3.5.2 Read Me
-
The ANTLR library (license)
- is included within EclipseLink Project to enable parsing of the Java Persistence
- Query language (JP QL). The ANTLR library is re-packaged within the project
- in the org.eclipse.persistence.internal.libraries.antlr.* packages.
-
The source code is available within the project's git repository.
- The binaries are distributed within the eclipselink.jar and in the
- org.eclipse.persistence.antlr_3.5.2.v*.jar bundle.
-
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/readme.txt b/eclipseLink.backup/org.eclipse.persistence.antlr/readme.txt
deleted file mode 100644
index 0be794968e6..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/readme.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-This directory contains a renamed version of the ANTLR tool's runtime component.
-
-ANTLR is used for JPQL compilation in EclipseLink.
-
-Please do not change these files unless you are either upgrading the ANTLR version or applying a patch that absolutely must be made in ANTLR. The goal is to keep ANTLR the same as a real ANTLR release from http://www.antlr.org/. The current version is 3.0.
-
-The following is checked in:
-
-1. The source code - this can be used for debugging or to regenerate the ANTLR classes
-2. A PDE project - this can be used for OSGI integration
-3. extra-src.jar - this contains some source files that are not included in eclipselink since they are not required at runtime and they depend on components that are shipped with ANTLR v3, that depend on parts of ANTLR that cannot be checked into Eclipse repositories (ANTLR v2 and the String Template library)
-
-Replacing ANTLR requires to following steps
-1. Get the new ANTLR source
-2. Rename it using either the EclipseLink rename utility or some other utility. The rename involves changing the package names from org.antlr.runtime to org.eclipse.persistence.internal.libraries.antlr.runtime
-3. Compile the classes
-4. Check in the new source
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ANTLRFileStream.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ANTLRFileStream.java
deleted file mode 100644
index ad95da4f7f1..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ANTLRFileStream.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-import java.io.*;
-
-/** This is a char buffer stream that is loaded from a file
- * all at once when you construct the object. This looks very
- * much like an ANTLReader or ANTLRInputStream, but it's a special case
- * since we know the exact size of the object to load. We can avoid lots
- * of data copying.
- */
-public class ANTLRFileStream extends ANTLRStringStream {
- protected String fileName;
-
- public ANTLRFileStream(String fileName) throws IOException {
- this(fileName, null);
- }
-
- public ANTLRFileStream(String fileName, String encoding) throws IOException {
- this.fileName = fileName;
- load(fileName, encoding);
- }
-
- public void load(String fileName, String encoding)
- throws IOException
- {
- if ( fileName==null ) {
- return;
- }
- File f = new File(fileName);
- int size = (int)f.length();
- InputStreamReader isr;
- FileInputStream fis = new FileInputStream(fileName);
- if ( encoding!=null ) {
- isr = new InputStreamReader(fis, encoding);
- }
- else {
- isr = new InputStreamReader(fis);
- }
- try {
- data = new char[size];
- super.n = isr.read(data);
- }
- finally {
- isr.close();
- }
- }
-
- @Override
- public String getSourceName() {
- return fileName;
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ANTLRInputStream.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ANTLRInputStream.java
deleted file mode 100644
index f26f61858e5..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ANTLRInputStream.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-import java.io.*;
-
-/** A kind of ReaderStream that pulls from an InputStream.
- * Useful for reading from stdin and specifying file encodings etc...
- */
-public class ANTLRInputStream extends ANTLRReaderStream {
- public ANTLRInputStream() {
- }
-
- public ANTLRInputStream(InputStream input) throws IOException {
- this(input, null);
- }
-
- public ANTLRInputStream(InputStream input, int size) throws IOException {
- this(input, size, null);
- }
-
- public ANTLRInputStream(InputStream input, String encoding) throws IOException {
- this(input, INITIAL_BUFFER_SIZE, encoding);
- }
-
- public ANTLRInputStream(InputStream input, int size, String encoding) throws IOException {
- this(input, size, READ_BUFFER_SIZE, encoding);
- }
-
- public ANTLRInputStream(InputStream input,
- int size,
- int readBufferSize,
- String encoding)
- throws IOException
- {
- InputStreamReader isr;
- if ( encoding!=null ) {
- isr = new InputStreamReader(input, encoding);
- }
- else {
- isr = new InputStreamReader(input);
- }
- load(isr, size, readBufferSize);
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ANTLRReaderStream.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ANTLRReaderStream.java
deleted file mode 100644
index 6d9be149b7e..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ANTLRReaderStream.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-import java.io.*;
-
-/** Vacuum all input from a Reader and then treat it like a StringStream.
- * Manage the buffer manually to avoid unnecessary data copying.
- *
- * If you need encoding, use ANTLRInputStream.
- */
-public class ANTLRReaderStream extends ANTLRStringStream {
- public static final int READ_BUFFER_SIZE = 1024;
- public static final int INITIAL_BUFFER_SIZE = 1024;
-
- public ANTLRReaderStream() {
- }
-
- public ANTLRReaderStream(Reader r) throws IOException {
- this(r, INITIAL_BUFFER_SIZE, READ_BUFFER_SIZE);
- }
-
- public ANTLRReaderStream(Reader r, int size) throws IOException {
- this(r, size, READ_BUFFER_SIZE);
- }
-
- public ANTLRReaderStream(Reader r, int size, int readChunkSize) throws IOException {
- load(r, size, readChunkSize);
- }
-
- public void load(Reader r, int size, int readChunkSize)
- throws IOException
- {
- if ( r==null ) {
- return;
- }
- if ( size<=0 ) {
- size = INITIAL_BUFFER_SIZE;
- }
- if ( readChunkSize<=0 ) {
- readChunkSize = READ_BUFFER_SIZE;
- }
- // System.out.println("load "+size+" in chunks of "+readChunkSize);
- try {
- // alloc initial buffer size.
- data = new char[size];
- // read all the data in chunks of readChunkSize
- int numRead;
- int p = 0;
- do {
- if ( p+readChunkSize > data.length ) { // overflow?
- // System.out.println("### overflow p="+p+", data.length="+data.length);
- char[] newdata = new char[data.length*2]; // resize
- System.arraycopy(data, 0, newdata, 0, data.length);
- data = newdata;
- }
- numRead = r.read(data, p, readChunkSize);
- // System.out.println("read "+numRead+" chars; p was "+p+" is now "+(p+numRead));
- p += numRead;
- } while (numRead!=-1); // while not EOF
- // set the actual size of the data available;
- // EOF subtracted one above in p+=numRead; add one back
- super.n = p+1;
- //System.out.println("n="+n);
- }
- finally {
- r.close();
- }
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ANTLRStringStream.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ANTLRStringStream.java
deleted file mode 100644
index 68a9868d5b4..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ANTLRStringStream.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/** A pretty quick CharStream that pulls all data from an array
- * directly. Every method call counts in the lexer. Java's
- * strings aren't very good so I'm avoiding.
- */
-public class ANTLRStringStream implements CharStream {
- /** The data being scanned */
- protected char[] data;
-
- /** How many characters are actually in the buffer */
- protected int n;
-
- /** 0..n-1 index into string of next char */
- protected int p=0;
-
- /** line number 1..n within the input */
- protected int line = 1;
-
- /** The index of the character relative to the beginning of the line 0..n-1 */
- protected int charPositionInLine = 0;
-
- /** tracks how deep mark() calls are nested */
- protected int markDepth = 0;
-
- /** A list of CharStreamState objects that tracks the stream state
- * values line, charPositionInLine, and p that can change as you
- * move through the input stream. Indexed from 1..markDepth.
- * A null is kept @ index 0. Create upon first call to mark().
- */
- protected List
markers;
-
- /** Track the last mark() call result value for use in rewind(). */
- protected int lastMarker;
-
- /** What is name or source of this char stream? */
- public String name;
-
- public ANTLRStringStream() {
- }
-
- /** Copy data in string to a local char array */
- public ANTLRStringStream(String input) {
- this();
- this.data = input.toCharArray();
- this.n = input.length();
- }
-
- /** This is the preferred constructor as no data is copied */
- public ANTLRStringStream(char[] data, int numberOfActualCharsInArray) {
- this();
- this.data = data;
- this.n = numberOfActualCharsInArray;
- }
-
- /** Reset the stream so that it's in the same state it was
- * when the object was created *except* the data array is not
- * touched.
- */
- public void reset() {
- p = 0;
- line = 1;
- charPositionInLine = 0;
- markDepth = 0;
- }
-
- @Override
- public void consume() {
- //System.out.println("prev p="+p+", c="+(char)data[p]);
- if ( p < n ) {
- charPositionInLine++;
- if ( data[p]=='\n' ) {
- /*
- System.out.println("newline char found on line: "+line+
- "@ pos="+charPositionInLine);
- */
- line++;
- charPositionInLine=0;
- }
- p++;
- //System.out.println("p moves to "+p+" (c='"+(char)data[p]+"')");
- }
- }
-
- @Override
- public int LA(int i) {
- if ( i==0 ) {
- return 0; // undefined
- }
- if ( i<0 ) {
- i++; // e.g., translate LA(-1) to use offset i=0; then data[p+0-1]
- if ( (p+i-1) < 0 ) {
- return CharStream.EOF; // invalid; no char before first char
- }
- }
-
- if ( (p+i-1) >= n ) {
- //System.out.println("char LA("+i+")=EOF; p="+p);
- return CharStream.EOF;
- }
- //System.out.println("char LA("+i+")="+(char)data[p+i-1]+"; p="+p);
- //System.out.println("LA("+i+"); p="+p+" n="+n+" data.length="+data.length);
- return data[p+i-1];
- }
-
- @Override
- public int LT(int i) {
- return LA(i);
- }
-
- /** Return the current input symbol index 0..n where n indicates the
- * last symbol has been read. The index is the index of char to
- * be returned from LA(1).
- */
- @Override
- public int index() {
- return p;
- }
-
- @Override
- public int size() {
- return n;
- }
-
- @Override
- public int mark() {
- if ( markers==null ) {
- markers = new ArrayList();
- markers.add(null); // depth 0 means no backtracking, leave blank
- }
- markDepth++;
- CharStreamState state;
- if ( markDepth>=markers.size() ) {
- state = new CharStreamState();
- markers.add(state);
- }
- else {
- state = markers.get(markDepth);
- }
- state.p = p;
- state.line = line;
- state.charPositionInLine = charPositionInLine;
- lastMarker = markDepth;
- return markDepth;
- }
-
- @Override
- public void rewind(int m) {
- CharStreamState state = markers.get(m);
- // restore stream state
- seek(state.p);
- line = state.line;
- charPositionInLine = state.charPositionInLine;
- release(m);
- }
-
- @Override
- public void rewind() {
- rewind(lastMarker);
- }
-
- @Override
- public void release(int marker) {
- // unwind any other markers made after m and release m
- markDepth = marker;
- // release this marker
- markDepth--;
- }
-
- /** consume() ahead until p==index; can't just set p=index as we must
- * update line and charPositionInLine.
- */
- @Override
- public void seek(int index) {
- if ( index<=p ) {
- p = index; // just jump; don't update stream state (line, ...)
- return;
- }
- // seek forward, consume until p hits index
- while ( p0 ) {
- state.failed = true;
- return matchedSymbol;
- }
- matchedSymbol = recoverFromMismatchedToken(input, ttype, follow);
- return matchedSymbol;
- }
-
- /** Match the wildcard: in a symbol */
- public void matchAny(IntStream input) {
- state.errorRecovery = false;
- state.failed = false;
- input.consume();
- }
-
- public boolean mismatchIsUnwantedToken(IntStream input, int ttype) {
- return input.LA(2)==ttype;
- }
-
- public boolean mismatchIsMissingToken(IntStream input, BitSet follow) {
- if ( follow==null ) {
- // we have no information about the follow; we can only consume
- // a single token and hope for the best
- return false;
- }
- // compute what can follow this grammar element reference
- if ( follow.member(Token.EOR_TOKEN_TYPE) ) {
- BitSet viableTokensFollowingThisRule = computeContextSensitiveRuleFOLLOW();
- follow = follow.or(viableTokensFollowingThisRule);
- if ( state._fsp>=0 ) { // remove EOR if we're not the start symbol
- follow.remove(Token.EOR_TOKEN_TYPE);
- }
- }
- // if current token is consistent with what could come after set
- // then we know we're missing a token; error recovery is free to
- // "insert" the missing token
-
- //System.out.println("viable tokens="+follow.toString(getTokenNames()));
- //System.out.println("LT(1)="+((TokenStream)input).LT(1));
-
- // BitSet cannot handle negative numbers like -1 (EOF) so I leave EOR
- // in follow set to indicate that the fall of the start symbol is
- // in the set (EOF can follow).
- if ( follow.member(input.LA(1)) || follow.member(Token.EOR_TOKEN_TYPE) ) {
- //System.out.println("LT(1)=="+((TokenStream)input).LT(1)+" is consistent with what follows; inserting...");
- return true;
- }
- return false;
- }
-
- /** Report a recognition problem.
- *
- * This method sets errorRecovery to indicate the parser is recovering
- * not parsing. Once in recovery mode, no errors are generated.
- * To get out of recovery mode, the parser must successfully match
- * a token (after a resync). So it will go:
- *
- * 1. error occurs
- * 2. enter recovery mode, report error
- * 3. consume until token found in resynch set
- * 4. try to resume parsing
- * 5. next match() will reset errorRecovery mode
- *
- * If you override, make sure to update syntaxErrors if you care about that.
- */
- public void reportError(RecognitionException e) {
- // if we've already reported an error and have not matched a token
- // yet successfully, don't report any errors.
- if ( state.errorRecovery ) {
- //System.err.print("[SPURIOUS] ");
- return;
- }
- state.syntaxErrors++; // don't count spurious
- state.errorRecovery = true;
-
- displayRecognitionError(this.getTokenNames(), e);
- }
-
- public void displayRecognitionError(String[] tokenNames,
- RecognitionException e)
- {
- String hdr = getErrorHeader(e);
- String msg = getErrorMessage(e, tokenNames);
- emitErrorMessage(hdr+" "+msg);
- }
-
- /** What error message should be generated for the various
- * exception types?
- *
- * Not very object-oriented code, but I like having all error message
- * generation within one method rather than spread among all of the
- * exception classes. This also makes it much easier for the exception
- * handling because the exception classes do not have to have pointers back
- * to this object to access utility routines and so on. Also, changing
- * the message for an exception type would be difficult because you
- * would have to subclassing exception, but then somehow get ANTLR
- * to make those kinds of exception objects instead of the default.
- * This looks weird, but trust me--it makes the most sense in terms
- * of flexibility.
- *
- * For grammar debugging, you will want to override this to add
- * more information such as the stack frame with
- * getRuleInvocationStack(e, this.getClass().getName()) and,
- * for no viable alts, the decision description and state etc...
- *
- * Override this to change the message generated for one or more
- * exception types.
- */
- public String getErrorMessage(RecognitionException e, String[] tokenNames) {
- String msg = e.getMessage();
- if ( e instanceof UnwantedTokenException ) {
- UnwantedTokenException ute = (UnwantedTokenException)e;
- String tokenName;
- if ( ute.expecting== Token.EOF ) {
- tokenName = "EOF";
- }
- else {
- tokenName = tokenNames[ute.expecting];
- }
- msg = "extraneous input "+getTokenErrorDisplay(ute.getUnexpectedToken())+
- " expecting "+tokenName;
- }
- else if ( e instanceof MissingTokenException ) {
- MissingTokenException mte = (MissingTokenException)e;
- String tokenName;
- if ( mte.expecting== Token.EOF ) {
- tokenName = "EOF";
- }
- else {
- tokenName = tokenNames[mte.expecting];
- }
- msg = "missing "+tokenName+" at "+getTokenErrorDisplay(e.token);
- }
- else if ( e instanceof MismatchedTokenException ) {
- MismatchedTokenException mte = (MismatchedTokenException)e;
- String tokenName;
- if ( mte.expecting== Token.EOF ) {
- tokenName = "EOF";
- }
- else {
- tokenName = tokenNames[mte.expecting];
- }
- msg = "mismatched input "+getTokenErrorDisplay(e.token)+
- " expecting "+tokenName;
- }
- else if ( e instanceof MismatchedTreeNodeException ) {
- MismatchedTreeNodeException mtne = (MismatchedTreeNodeException)e;
- String tokenName;
- if ( mtne.expecting==Token.EOF ) {
- tokenName = "EOF";
- }
- else {
- tokenName = tokenNames[mtne.expecting];
- }
- msg = "mismatched tree node: "+mtne.node+
- " expecting "+tokenName;
- }
- else if ( e instanceof NoViableAltException ) {
- //NoViableAltException nvae = (NoViableAltException)e;
- // for development, can add "decision=<<"+nvae.grammarDecisionDescription+">>"
- // and "(decision="+nvae.decisionNumber+") and
- // "state "+nvae.stateNumber
- msg = "no viable alternative at input "+getTokenErrorDisplay(e.token);
- }
- else if ( e instanceof EarlyExitException ) {
- //EarlyExitException eee = (EarlyExitException)e;
- // for development, can add "(decision="+eee.decisionNumber+")"
- msg = "required (...)+ loop did not match anything at input "+
- getTokenErrorDisplay(e.token);
- }
- else if ( e instanceof MismatchedSetException ) {
- MismatchedSetException mse = (MismatchedSetException)e;
- msg = "mismatched input "+getTokenErrorDisplay(e.token)+
- " expecting set "+mse.expecting;
- }
- else if ( e instanceof MismatchedNotSetException ) {
- MismatchedNotSetException mse = (MismatchedNotSetException)e;
- msg = "mismatched input "+getTokenErrorDisplay(e.token)+
- " expecting set "+mse.expecting;
- }
- else if ( e instanceof FailedPredicateException ) {
- FailedPredicateException fpe = (FailedPredicateException)e;
- msg = "rule "+fpe.ruleName+" failed predicate: {"+
- fpe.predicateText+"}?";
- }
- return msg;
- }
-
- /** Get number of recognition errors (lexer, parser, tree parser). Each
- * recognizer tracks its own number. So parser and lexer each have
- * separate count. Does not count the spurious errors found between
- * an error and next valid token match
- *
- * See also reportError()
- */
- public int getNumberOfSyntaxErrors() {
- return state.syntaxErrors;
- }
-
- /** What is the error header, normally line/character position information? */
- public String getErrorHeader(RecognitionException e) {
- if ( getSourceName()!=null )
- return getSourceName()+" line "+e.line+":"+e.charPositionInLine;
-
- return "line "+e.line+":"+e.charPositionInLine;
- }
-
- /** How should a token be displayed in an error message? The default
- * is to display just the text, but during development you might
- * want to have a lot of information spit out. Override in that case
- * to use t.toString() (which, for CommonToken, dumps everything about
- * the token). This is better than forcing you to override a method in
- * your token objects because you don't have to go modify your lexer
- * so that it creates a new Java type.
- */
- public String getTokenErrorDisplay(Token t) {
- String s = t.getText();
- if ( s==null ) {
- if ( t.getType()==Token.EOF ) {
- s = "";
- }
- else {
- s = "<"+t.getType()+">";
- }
- }
- s = s.replaceAll("\n","\\\\n");
- s = s.replaceAll("\r","\\\\r");
- s = s.replaceAll("\t","\\\\t");
- return "'"+s+"'";
- }
-
- /** Override this method to change where error messages go */
- public void emitErrorMessage(String msg) {
- System.err.println(msg);
- }
-
- /** Recover from an error found on the input stream. This is
- * for NoViableAlt and mismatched symbol exceptions. If you enable
- * single token insertion and deletion, this will usually not
- * handle mismatched symbol exceptions but there could be a mismatched
- * token that the match() routine could not recover from.
- */
- public void recover(IntStream input, RecognitionException re) {
- if ( state.lastErrorIndex==input.index() ) {
- // uh oh, another error at same token index; must be a case
- // where LT(1) is in the recovery token set so nothing is
- // consumed; consume a single token so at least to prevent
- // an infinite loop; this is a failsafe.
- input.consume();
- }
- state.lastErrorIndex = input.index();
- BitSet followSet = computeErrorRecoverySet();
- beginResync();
- consumeUntil(input, followSet);
- endResync();
- }
-
- /** A hook to listen in on the token consumption during error recovery.
- * The DebugParser subclasses this to fire events to the listenter.
- */
- public void beginResync() {
- }
-
- public void endResync() {
- }
-
- /* Compute the error recovery set for the current rule. During
- * rule invocation, the parser pushes the set of tokens that can
- * follow that rule reference on the stack; this amounts to
- * computing FIRST of what follows the rule reference in the
- * enclosing rule. This local follow set only includes tokens
- * from within the rule; i.e., the FIRST computation done by
- * ANTLR stops at the end of a rule.
- *
- * EXAMPLE
- *
- * When you find a "no viable alt exception", the input is not
- * consistent with any of the alternatives for rule r. The best
- * thing to do is to consume tokens until you see something that
- * can legally follow a call to r *or* any rule that called r.
- * You don't want the exact set of viable next tokens because the
- * input might just be missing a token--you might consume the
- * rest of the input looking for one of the missing tokens.
- *
- * Consider grammar:
- *
- * a : '[' b ']'
- * | '(' b ')'
- * ;
- * b : c '^' INT ;
- * c : ID
- * | INT
- * ;
- *
- * At each rule invocation, the set of tokens that could follow
- * that rule is pushed on a stack. Here are the various "local"
- * follow sets:
- *
- * FOLLOW(b1_in_a) = FIRST(']') = ']'
- * FOLLOW(b2_in_a) = FIRST(')') = ')'
- * FOLLOW(c_in_b) = FIRST('^') = '^'
- *
- * Upon erroneous input "[]", the call chain is
- *
- * a -> b -> c
- *
- * and, hence, the follow context stack is:
- *
- * depth local follow set after call to rule
- * 0 a (from main())
- * 1 ']' b
- * 3 '^' c
- *
- * Notice that ')' is not included, because b would have to have
- * been called from a different context in rule a for ')' to be
- * included.
- *
- * For error recovery, we cannot consider FOLLOW(c)
- * (context-sensitive or otherwise). We need the combined set of
- * all context-sensitive FOLLOW sets--the set of all tokens that
- * could follow any reference in the call chain. We need to
- * resync to one of those tokens. Note that FOLLOW(c)='^' and if
- * we resync'd to that token, we'd consume until EOF. We need to
- * sync to context-sensitive FOLLOWs for a, b, and c: {']','^'}.
- * In this case, for input "[]", LA(1) is in this set so we would
- * not consume anything and after printing an error rule c would
- * return normally. It would not find the required '^' though.
- * At this point, it gets a mismatched token error and throws an
- * exception (since LA(1) is not in the viable following token
- * set). The rule exception handler tries to recover, but finds
- * the same recovery set and doesn't consume anything. Rule b
- * exits normally returning to rule a. Now it finds the ']' (and
- * with the successful match exits errorRecovery mode).
- *
- * So, you cna see that the parser walks up call chain looking
- * for the token that was a member of the recovery set.
- *
- * Errors are not generated in errorRecovery mode.
- *
- * ANTLR's error recovery mechanism is based upon original ideas:
- *
- * "Algorithms + Data Structures = Programs" by Niklaus Wirth
- *
- * and
- *
- * "A note on error recovery in recursive descent parsers":
- * http://portal.acm.org/citation.cfm?id=947902.947905
- *
- * Later, Josef Grosch had some good ideas:
- *
- * "Efficient and Comfortable Error Recovery in Recursive Descent
- * Parsers":
- * ftp://www.cocolab.com/products/cocktail/doca4.ps/ell.ps.zip
- *
- * Like Grosch I implemented local FOLLOW sets that are combined
- * at run-time upon error to avoid overhead during parsing.
- */
- protected BitSet computeErrorRecoverySet() {
- return combineFollows(false);
- }
-
- /** Compute the context-sensitive FOLLOW set for current rule.
- * This is set of token types that can follow a specific rule
- * reference given a specific call chain. You get the set of
- * viable tokens that can possibly come next (lookahead depth 1)
- * given the current call chain. Contrast this with the
- * definition of plain FOLLOW for rule r:
- *
- * FOLLOW(r)={x | S=>*alpha r beta in G and x in FIRST(beta)}
- *
- * where x in T* and alpha, beta in V*; T is set of terminals and
- * V is the set of terminals and nonterminals. In other words,
- * FOLLOW(r) is the set of all tokens that can possibly follow
- * references to r in *any* sentential form (context). At
- * runtime, however, we know precisely which context applies as
- * we have the call chain. We may compute the exact (rather
- * than covering superset) set of following tokens.
- *
- * For example, consider grammar:
- *
- * stat : ID '=' expr ';' // FOLLOW(stat)=={EOF}
- * | "return" expr '.'
- * ;
- * expr : atom ('+' atom)* ; // FOLLOW(expr)=={';','.',')'}
- * atom : INT // FOLLOW(atom)=={'+',')',';','.'}
- * | '(' expr ')'
- * ;
- *
- * The FOLLOW sets are all inclusive whereas context-sensitive
- * FOLLOW sets are precisely what could follow a rule reference.
- * For input input "i=(3);", here is the derivation:
- *
- * stat => ID '=' expr ';'
- * => ID '=' atom ('+' atom)* ';'
- * => ID '=' '(' expr ')' ('+' atom)* ';'
- * => ID '=' '(' atom ')' ('+' atom)* ';'
- * => ID '=' '(' INT ')' ('+' atom)* ';'
- * => ID '=' '(' INT ')' ';'
- *
- * At the "3" token, you'd have a call chain of
- *
- * stat → expr → atom → expr → atom
- *
- * What can follow that specific nested ref to atom? Exactly ')'
- * as you can see by looking at the derivation of this specific
- * input. Contrast this with the FOLLOW(atom)={'+',')',';','.'}.
- *
- * You want the exact viable token set when recovering from a
- * token mismatch. Upon token mismatch, if LA(1) is member of
- * the viable next token set, then you know there is most likely
- * a missing token in the input stream. "Insert" one by just not
- * throwing an exception.
- */
- protected BitSet computeContextSensitiveRuleFOLLOW() {
- return combineFollows(true);
- }
-
- // what is exact? it seems to only add sets from above on stack
- // if EOR is in set i. When it sees a set w/o EOR, it stops adding.
- // Why would we ever want them all? Maybe no viable alt instead of
- // mismatched token?
- protected BitSet combineFollows(boolean exact) {
- int top = state._fsp;
- BitSet followSet = new BitSet();
- for (int i=top; i>=0; i--) {
- BitSet localFollowSet = state.following[i];
- /*
- System.out.println("local follow depth "+i+"="+
- localFollowSet.toString(getTokenNames())+")");
- */
- followSet.orInPlace(localFollowSet);
- if ( exact ) {
- // can we see end of rule?
- if ( localFollowSet.member(Token.EOR_TOKEN_TYPE) ) {
- // Only leave EOR in set if at top (start rule); this lets
- // us know if have to include follow(start rule); i.e., EOF
- if ( i>0 ) {
- followSet.remove(Token.EOR_TOKEN_TYPE);
- }
- }
- else { // can't see end of rule, quit
- break;
- }
- }
- }
- return followSet;
- }
-
- /** Attempt to recover from a single missing or extra token.
- *
- * EXTRA TOKEN
- *
- * LA(1) is not what we are looking for. If LA(2) has the right token,
- * however, then assume LA(1) is some extra spurious token. Delete it
- * and LA(2) as if we were doing a normal match(), which advances the
- * input.
- *
- * MISSING TOKEN
- *
- * If current token is consistent with what could come after
- * ttype then it is ok to "insert" the missing token, else throw
- * exception For example, Input "i=(3;" is clearly missing the
- * ')'. When the parser returns from the nested call to expr, it
- * will have call chain:
- *
- * stat → expr → atom
- *
- * and it will be trying to match the ')' at this point in the
- * derivation:
- *
- * => ID '=' '(' INT ')' ('+' atom)* ';'
- * ^
- * match() will see that ';' doesn't match ')' and report a
- * mismatched token error. To recover, it sees that LA(1)==';'
- * is in the set of tokens that can follow the ')' token
- * reference in rule atom. It can assume that you forgot the ')'.
- */
- protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow)
- throws RecognitionException
- {
- RecognitionException e = null;
- // if next token is what we are looking for then "delete" this token
- if ( mismatchIsUnwantedToken(input, ttype) ) {
- e = new UnwantedTokenException(ttype, input);
- /*
- System.err.println("recoverFromMismatchedToken deleting "+
- ((TokenStream)input).LT(1)+
- " since "+((TokenStream)input).LT(2)+" is what we want");
- */
- beginResync();
- input.consume(); // simply delete extra token
- endResync();
- reportError(e); // report after consuming so AW sees the token in the exception
- // we want to return the token we're actually matching
- Object matchedSymbol = getCurrentInputSymbol(input);
- input.consume(); // move past ttype token as if all were ok
- return matchedSymbol;
- }
- // can't recover with single token deletion, try insertion
- if ( mismatchIsMissingToken(input, follow) ) {
- Object inserted = getMissingSymbol(input, e, ttype, follow);
- e = new MissingTokenException(ttype, input, inserted);
- reportError(e); // report after inserting so AW sees the token in the exception
- return inserted;
- }
- // even that didn't work; must throw the exception
- e = new MismatchedTokenException(ttype, input);
- throw e;
- }
-
- /** Not currently used */
- public Object recoverFromMismatchedSet(IntStream input,
- RecognitionException e,
- BitSet follow)
- throws RecognitionException
- {
- if ( mismatchIsMissingToken(input, follow) ) {
- // System.out.println("missing token");
- reportError(e);
- // we don't know how to conjure up a token for sets yet
- return getMissingSymbol(input, e, Token.INVALID_TOKEN_TYPE, follow);
- }
- // TODO do single token deletion like above for Token mismatch
- throw e;
- }
-
- /** Match needs to return the current input symbol, which gets put
- * into the label for the associated token ref; e.g., x=ID. Token
- * and tree parsers need to return different objects. Rather than test
- * for input stream type or change the IntStream interface, I use
- * a simple method to ask the recognizer to tell me what the current
- * input symbol is.
- *
- * This is ignored for lexers.
- */
- protected Object getCurrentInputSymbol(IntStream input) { return null; }
-
- /** Conjure up a missing token during error recovery.
- *
- * The recognizer attempts to recover from single missing
- * symbols. But, actions might refer to that missing symbol.
- * For example, x=ID {f($x);}. The action clearly assumes
- * that there has been an identifier matched previously and that
- * $x points at that token. If that token is missing, but
- * the next token in the stream is what we want we assume that
- * this token is missing and we keep going. Because we
- * have to return some token to replace the missing token,
- * we have to conjure one up. This method gives the user control
- * over the tokens returned for missing tokens. Mostly,
- * you will want to create something special for identifier
- * tokens. For literals such as '{' and ',', the default
- * action in the parser or tree parser works. It simply creates
- * a CommonToken of the appropriate type. The text will be the token.
- * If you change what tokens must be created by the lexer,
- * override this method to create the appropriate tokens.
- */
- protected Object getMissingSymbol(IntStream input,
- RecognitionException e,
- int expectedTokenType,
- BitSet follow)
- {
- return null;
- }
-
- public void consumeUntil(IntStream input, int tokenType) {
- //System.out.println("consumeUntil "+tokenType);
- int ttype = input.LA(1);
- while (ttype != Token.EOF && ttype != tokenType) {
- input.consume();
- ttype = input.LA(1);
- }
- }
-
- /** Consume tokens until one matches the given token set */
- public void consumeUntil(IntStream input, BitSet set) {
- //System.out.println("consumeUntil("+set.toString(getTokenNames())+")");
- int ttype = input.LA(1);
- while (ttype != Token.EOF && !set.member(ttype) ) {
- //System.out.println("consume during recover LA(1)="+getTokenNames()[input.LA(1)]);
- input.consume();
- ttype = input.LA(1);
- }
- }
-
- /** Push a rule's follow set using our own hardcoded stack */
- protected void pushFollow(BitSet fset) {
- if ( (state._fsp +1)>=state.following.length ) {
- BitSet[] f = new BitSet[state.following.length*2];
- System.arraycopy(state.following, 0, f, 0, state.following.length);
- state.following = f;
- }
- state.following[++state._fsp] = fset;
- }
-
- /** Return List<String> of the rules in your parser instance
- * leading up to a call to this method. You could override if
- * you want more details such as the file/line info of where
- * in the parser java code a rule is invoked.
- *
- * This is very useful for error messages and for context-sensitive
- * error recovery.
- */
- public List getRuleInvocationStack() {
- String parserClassName = getClass().getName();
- return getRuleInvocationStack(new Throwable(), parserClassName);
- }
-
- /** A more general version of getRuleInvocationStack where you can
- * pass in, for example, a RecognitionException to get it's rule
- * stack trace. This routine is shared with all recognizers, hence,
- * static.
- *
- * TODO: move to a utility class or something; weird having lexer call this
- */
- public static List getRuleInvocationStack(Throwable e,
- String recognizerClassName)
- {
- List rules = new ArrayList();
- StackTraceElement[] stack = e.getStackTrace();
- int i;
- for (i=stack.length-1; i>=0; i--) {
- StackTraceElement t = stack[i];
- if ( t.getClassName().startsWith("org.eclipse.persistence.internal.libraries.antlr.runtime.") ) {
- continue; // skip support code such as this method
- }
- if ( t.getMethodName().equals(NEXT_TOKEN_RULE_NAME) ) {
- continue;
- }
- if ( !t.getClassName().equals(recognizerClassName) ) {
- continue; // must not be part of this parser
- }
- rules.add(t.getMethodName());
- }
- return rules;
- }
-
- public int getBacktrackingLevel() { return state.backtracking; }
-
- public void setBacktrackingLevel(int n) { state.backtracking = n; }
-
- /** Return whether or not a backtracking attempt failed. */
- public boolean failed() { return state.failed; }
-
- /** Used to print out token names like ID during debugging and
- * error reporting. The generated parsers implement a method
- * that overrides this to point to their String[] tokenNames.
- */
- public String[] getTokenNames() {
- return null;
- }
-
- /** For debugging and other purposes, might want the grammar name.
- * Have ANTLR generate an implementation for this method.
- */
- public String getGrammarFileName() {
- return null;
- }
-
- public abstract String getSourceName();
-
- /** A convenience method for use most often with template rewrites.
- * Convert a List<Token> to List<String>
- */
- public List toStrings(List extends Token> tokens) {
- if ( tokens==null ) return null;
- List strings = new ArrayList(tokens.size());
- for (int i=0; i();
- }
- Integer stopIndexI =
- state.ruleMemo[ruleIndex].get(ruleStartIndex);
- if ( stopIndexI==null ) {
- return MEMO_RULE_UNKNOWN;
- }
- return stopIndexI;
- }
-
- /** Has this rule already parsed input at the current index in the
- * input stream? Return the stop token index or MEMO_RULE_UNKNOWN.
- * If we attempted but failed to parse properly before, return
- * MEMO_RULE_FAILED.
- *
- * This method has a side-effect: if we have seen this input for
- * this rule and successfully parsed before, then seek ahead to
- * 1 past the stop token matched for this rule last time.
- */
- public boolean alreadyParsedRule(IntStream input, int ruleIndex) {
- int stopIndex = getRuleMemoization(ruleIndex, input.index());
- if ( stopIndex==MEMO_RULE_UNKNOWN ) {
- return false;
- }
- if ( stopIndex==MEMO_RULE_FAILED ) {
- //System.out.println("rule "+ruleIndex+" will never succeed");
- state.failed=true;
- }
- else {
- //System.out.println("seen rule "+ruleIndex+" before; skipping ahead to @"+(stopIndex+1)+" failed="+state.failed);
- input.seek(stopIndex+1); // jump to one past stop token
- }
- return true;
- }
-
- /** Record whether or not this rule parsed the input at this position
- * successfully. Use a standard java hashtable for now.
- */
- public void memoize(IntStream input,
- int ruleIndex,
- int ruleStartIndex)
- {
- int stopTokenIndex = state.failed?MEMO_RULE_FAILED:input.index()-1;
- if ( state.ruleMemo==null ) {
- System.err.println("!!!!!!!!! memo array is null for "+ getGrammarFileName());
- }
- if ( ruleIndex >= state.ruleMemo.length ) {
- System.err.println("!!!!!!!!! memo size is "+state.ruleMemo.length+", but rule index is "+ruleIndex);
- }
- if ( state.ruleMemo[ruleIndex]!=null ) {
- state.ruleMemo[ruleIndex].put(ruleStartIndex, stopTokenIndex);
- }
- }
-
- /** return how many rule/input-index pairs there are in total.
- * TODO: this includes synpreds. :(
- */
- public int getRuleMemoizationCacheSize() {
- int n = 0;
- for (int i = 0; state.ruleMemo!=null && i < state.ruleMemo.length; i++) {
- Map ruleMap = state.ruleMemo[i];
- if ( ruleMap!=null ) {
- n += ruleMap.size(); // how many input indexes are recorded?
- }
- }
- return n;
- }
-
- public void traceIn(String ruleName, int ruleIndex, Object inputSymbol) {
- System.out.print("enter "+ruleName+" "+inputSymbol);
- if ( state.backtracking>0 ) {
- System.out.print(" backtracking="+state.backtracking);
- }
- System.out.println();
- }
-
- public void traceOut(String ruleName,
- int ruleIndex,
- Object inputSymbol)
- {
- System.out.print("exit "+ruleName+" "+inputSymbol);
- if ( state.backtracking>0 ) {
- System.out.print(" backtracking="+state.backtracking);
- if ( state.failed ) System.out.print(" failed");
- else System.out.print(" succeeded");
- }
- System.out.println();
- }
-
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/BitSet.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/BitSet.java
deleted file mode 100644
index 14257cf7d60..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/BitSet.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-import java.util.List;
-
-/**A stripped-down version of org.eclipse.persistence.internal.libraries.antlr.misc.BitSet that is just
- * good enough to handle runtime requirements such as FOLLOW sets
- * for automatic error recovery.
- */
-public class BitSet implements Cloneable {
- protected final static int BITS = 64; // number of bits / long
- protected final static int LOG_BITS = 6; // 2^6 == 64
-
- /* We will often need to do a mod operator (i mod nbits). Its
- * turns out that, for powers of two, this mod operation is
- * same as (i & (nbits-1)). Since mod is slow, we use a
- * precomputed mod mask to do the mod instead.
- */
- protected final static int MOD_MASK = BITS - 1;
-
- /** The actual data bits */
- protected long bits[];
-
- /** Construct a bitset of size one word (64 bits) */
- public BitSet() {
- this(BITS);
- }
-
- /** Construction from a static array of longs */
- public BitSet(long[] bits_) {
- bits = bits_;
- }
-
- /** Construction from a list of integers */
- public BitSet(List items) {
- this();
- for (int i = 0; i < items.size(); i++) {
- Integer v = items.get(i);
- add(v);
- }
- }
-
- /** Construct a bitset given the size
- * @param nbits The size of the bitset in bits
- */
- public BitSet(int nbits) {
- bits = new long[((nbits - 1) >> LOG_BITS) + 1];
- }
-
- public static BitSet of(int el) {
- BitSet s = new BitSet(el + 1);
- s.add(el);
- return s;
- }
-
- public static BitSet of(int a, int b) {
- BitSet s = new BitSet(Math.max(a,b)+1);
- s.add(a);
- s.add(b);
- return s;
- }
-
- public static BitSet of(int a, int b, int c) {
- BitSet s = new BitSet();
- s.add(a);
- s.add(b);
- s.add(c);
- return s;
- }
-
- public static BitSet of(int a, int b, int c, int d) {
- BitSet s = new BitSet();
- s.add(a);
- s.add(b);
- s.add(c);
- s.add(d);
- return s;
- }
-
- /** return this | a in a new set */
- public BitSet or(BitSet a) {
- if ( a==null ) {
- return this;
- }
- BitSet s = (BitSet)this.clone();
- s.orInPlace(a);
- return s;
- }
-
- /** or this element into this set (grow as necessary to accommodate) */
- public void add(int el) {
- int n = wordNumber(el);
- if (n >= bits.length) {
- growToInclude(el);
- }
- bits[n] |= bitMask(el);
- }
-
- /**
- * Grows the set to a larger number of bits.
- * @param bit element that must fit in set
- */
- public void growToInclude(int bit) {
- int newSize = Math.max(bits.length << 1, numWordsToHold(bit));
- long newbits[] = new long[newSize];
- System.arraycopy(bits, 0, newbits, 0, bits.length);
- bits = newbits;
- }
-
- public void orInPlace(BitSet a) {
- if ( a==null ) {
- return;
- }
- // If this is smaller than a, grow this first
- if (a.bits.length > bits.length) {
- setSize(a.bits.length);
- }
- int min = Math.min(bits.length, a.bits.length);
- for (int i = min - 1; i >= 0; i--) {
- bits[i] |= a.bits[i];
- }
- }
-
- /**
- * Sets the size of a set.
- * @param nwords how many words the new set should be
- */
- private void setSize(int nwords) {
- long newbits[] = new long[nwords];
- int n = Math.min(nwords, bits.length);
- System.arraycopy(bits, 0, newbits, 0, n);
- bits = newbits;
- }
-
- private final static long bitMask(int bitNumber) {
- int bitPosition = bitNumber & MOD_MASK; // bitNumber mod BITS
- return 1L << bitPosition;
- }
-
- @Override
- public Object clone() {
- BitSet s;
- try {
- s = (BitSet)super.clone();
- s.bits = new long[bits.length];
- System.arraycopy(bits, 0, s.bits, 0, bits.length);
- }
- catch (CloneNotSupportedException e) {
- throw new InternalError();
- }
- return s;
- }
-
- public int size() {
- int deg = 0;
- for (int i = bits.length - 1; i >= 0; i--) {
- long word = bits[i];
- if (word != 0L) {
- for (int bit = BITS - 1; bit >= 0; bit--) {
- if ((word & (1L << bit)) != 0) {
- deg++;
- }
- }
- }
- }
- return deg;
- }
-
- @Override
- public boolean equals(Object other) {
- if ( other == null || !(other instanceof BitSet) ) {
- return false;
- }
-
- BitSet otherSet = (BitSet)other;
-
- int n = Math.min(this.bits.length, otherSet.bits.length);
-
- // for any bits in common, compare
- for (int i=0; i n) {
- for (int i = n+1; i n) {
- for (int i = n+1; i= bits.length) return false;
- return (bits[n] & bitMask(el)) != 0;
- }
-
- // remove this element from this set
- public void remove(int el) {
- int n = wordNumber(el);
- if (n < bits.length) {
- bits[n] &= ~bitMask(el);
- }
- }
-
- public boolean isNil() {
- for (int i = bits.length - 1; i >= 0; i--) {
- if (bits[i] != 0) return false;
- }
- return true;
- }
-
- private final int numWordsToHold(int el) {
- return (el >> LOG_BITS) + 1;
- }
-
- public int numBits() {
- return bits.length << LOG_BITS; // num words * bits per word
- }
-
- /** return how much space is being used by the bits array not
- * how many actually have member bits on.
- */
- public int lengthInLongWords() {
- return bits.length;
- }
-
- /**Is this contained within a? */
- /*
- public boolean subset(BitSet a) {
- if (a == null || !(a instanceof BitSet)) return false;
- return this.and(a).equals(this);
- }
- */
-
- public int[] toArray() {
- int[] elems = new int[size()];
- int en = 0;
- for (int i = 0; i < (bits.length << LOG_BITS); i++) {
- if (member(i)) {
- elems[en++] = i;
- }
- }
- return elems;
- }
-
- public long[] toPackedArray() {
- return bits;
- }
-
- private final static int wordNumber(int bit) {
- return bit >> LOG_BITS; // bit / BITS
- }
-
- @Override
- public String toString() {
- return toString(null);
- }
-
- public String toString(String[] tokenNames) {
- StringBuilder buf = new StringBuilder();
- String separator = ",";
- boolean havePrintedAnElement = false;
- buf.append('{');
-
- for (int i = 0; i < (bits.length << LOG_BITS); i++) {
- if (member(i)) {
- if (i > 0 && havePrintedAnElement ) {
- buf.append(separator);
- }
- if ( tokenNames!=null ) {
- buf.append(tokenNames[i]);
- }
- else {
- buf.append(i);
- }
- havePrintedAnElement = true;
- }
- }
- buf.append('}');
- return buf.toString();
- }
-
-
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/BufferedTokenStream.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/BufferedTokenStream.java
deleted file mode 100644
index 06520699915..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/BufferedTokenStream.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.NoSuchElementException;
-
-/** Buffer all input tokens but do on-demand fetching of new tokens from
- * lexer. Useful when the parser or lexer has to set context/mode info before
- * proper lexing of future tokens. The ST template parser needs this,
- * for example, because it has to constantly flip back and forth between
- * inside/output templates. E.g., {@code }>} has to parse names
- * as part of an expression but {@code "hi, "} as a nested template.
- *
- * You can't use this stream if you pass whitespace or other off-channel
- * tokens to the parser. The stream can't ignore off-channel tokens.
- * (UnbufferedTokenStream is the same way.)
- *
- * This is not a subclass of UnbufferedTokenStream because I don't want
- * to confuse small moving window of tokens it uses for the full buffer.
- */
-public class BufferedTokenStream implements TokenStream {
- protected TokenSource tokenSource;
-
- /** Record every single token pulled from the source so we can reproduce
- * chunks of it later. The buffer in LookaheadStream overlaps sometimes
- * as its moving window moves through the input. This list captures
- * everything so we can access complete input text.
- */
- protected List tokens = new ArrayList(100);
-
- /** Track the last mark() call result value for use in rewind(). */
- protected int lastMarker;
-
- /** The index into the tokens list of the current token (next token
- * to consume). tokens[p] should be LT(1). p=-1 indicates need
- * to initialize with first token. The ctor doesn't get a token.
- * First call to LT(1) or whatever gets the first token and sets p=0;
- */
- protected int p = -1;
-
- protected int range = -1; // how deep have we gone?
-
- public BufferedTokenStream() {}
-
- public BufferedTokenStream(TokenSource tokenSource) {
- this.tokenSource = tokenSource;
- }
-
- @Override
- public TokenSource getTokenSource() { return tokenSource; }
-
- @Override
- public int index() { return p; }
-
- @Override
- public int range() { return range; }
-
- @Override
- public int mark() {
- if ( p == -1 ) setup();
- lastMarker = index();
- return lastMarker;
- }
-
- @Override
- public void release(int marker) {
- // no resources to release
- }
-
- @Override
- public void rewind(int marker) {
- seek(marker);
- }
-
- @Override
- public void rewind() {
- seek(lastMarker);
- }
-
- public void reset() {
- p = 0;
- lastMarker = 0;
- }
-
- @Override
- public void seek(int index) { p = index; }
-
- @Override
- public int size() { return tokens.size(); }
-
- /** Move the input pointer to the next incoming token. The stream
- * must become active with LT(1) available. consume() simply
- * moves the input pointer so that LT(1) points at the next
- * input symbol. Consume at least one token.
- *
- * Walk past any token not on the channel the parser is listening to.
- */
- @Override
- public void consume() {
- if ( p == -1 ) setup();
- p++;
- sync(p);
- }
-
- /** Make sure index i in tokens has a token. */
- protected void sync(int i) {
- int n = i - tokens.size() + 1; // how many more elements we need?
- //System.out.println("sync("+i+") needs "+n);
- if ( n > 0 ) fetch(n);
- }
-
- /** add n elements to buffer */
- protected void fetch(int n) {
- for (int i=1; i<=n; i++) {
- Token t = tokenSource.nextToken();
- t.setTokenIndex(tokens.size());
- //System.out.println("adding "+t+" at index "+tokens.size());
- tokens.add(t);
- if ( t.getType()==Token.EOF ) break;
- }
- }
-
- @Override
- public Token get(int i) {
- if ( i < 0 || i >= tokens.size() ) {
- throw new NoSuchElementException("token index "+i+" out of range 0.."+(tokens.size()-1));
- }
- return tokens.get(i);
- }
-
- /** Get all tokens from start..stop inclusively */
- public List extends Token> get(int start, int stop) {
- if ( start<0 || stop<0 ) return null;
- if ( p == -1 ) setup();
- List subset = new ArrayList();
- if ( stop>=tokens.size() ) stop = tokens.size()-1;
- for (int i = start; i <= stop; i++) {
- Token t = tokens.get(i);
- if ( t.getType()==Token.EOF ) break;
- subset.add(t);
- }
- return subset;
- }
-
- @Override
- public int LA(int i) { return LT(i).getType(); }
-
- protected Token LB(int k) {
- if ( (p-k)<0 ) return null;
- return tokens.get(p-k);
- }
-
- @Override
- public Token LT(int k) {
- if ( p == -1 ) setup();
- if ( k==0 ) return null;
- if ( k < 0 ) return LB(-k);
-
- int i = p + k - 1;
- sync(i);
- if ( i >= tokens.size() ) { // return EOF token
- // EOF must be last token
- return tokens.get(tokens.size()-1);
- }
- if ( i>range ) range = i;
- return tokens.get(i);
- }
-
- protected void setup() { sync(0); p = 0; }
-
- /** Reset this token stream by setting its token source. */
- public void setTokenSource(TokenSource tokenSource) {
- this.tokenSource = tokenSource;
- tokens.clear();
- p = -1;
- }
-
- public List extends Token> getTokens() { return tokens; }
-
- public List extends Token> getTokens(int start, int stop) {
- return getTokens(start, stop, (BitSet)null);
- }
-
- /** Given a start and stop index, return a List of all tokens in
- * the token type BitSet. Return null if no tokens were found. This
- * method looks at both on and off channel tokens.
- */
- public List extends Token> getTokens(int start, int stop, BitSet types) {
- if ( p == -1 ) setup();
- if ( stop>=tokens.size() ) stop=tokens.size()-1;
- if ( start<0 ) start=0;
- if ( start>stop ) return null;
-
- // list = tokens[start:stop]:{Token t, t.getType() in types}
- List filteredTokens = new ArrayList();
- for (int i=start; i<=stop; i++) {
- Token t = tokens.get(i);
- if ( types==null || types.member(t.getType()) ) {
- filteredTokens.add(t);
- }
- }
- if ( filteredTokens.isEmpty() ) {
- filteredTokens = null;
- }
- return filteredTokens;
- }
-
- public List extends Token> getTokens(int start, int stop, List types) {
- return getTokens(start,stop,new BitSet(types));
- }
-
- public List extends Token> getTokens(int start, int stop, int ttype) {
- return getTokens(start,stop,BitSet.of(ttype));
- }
-
- @Override
- public String getSourceName() { return tokenSource.getSourceName(); }
-
- /** Grab *all* tokens from stream and return string */
- @Override
- public String toString() {
- if ( p == -1 ) setup();
- fill();
- return toString(0, tokens.size()-1);
- }
-
- @Override
- public String toString(int start, int stop) {
- if ( start<0 || stop<0 ) return null;
- if ( p == -1 ) setup();
- if ( stop>=tokens.size() ) stop = tokens.size()-1;
- StringBuilder buf = new StringBuilder();
- for (int i = start; i <= stop; i++) {
- Token t = tokens.get(i);
- if ( t.getType()==Token.EOF ) break;
- buf.append(t.getText());
- }
- return buf.toString();
- }
-
- @Override
- public String toString(Token start, Token stop) {
- if ( start!=null && stop!=null ) {
- return toString(start.getTokenIndex(), stop.getTokenIndex());
- }
- return null;
- }
-
- /** Get all tokens from lexer until EOF */
- public void fill() {
- if ( p == -1 ) setup();
- if ( tokens.get(p).getType()==Token.EOF ) return;
-
- int i = p+1;
- sync(i);
- while ( tokens.get(i).getType()!=Token.EOF ) {
- i++;
- sync(i);
- }
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/CharStream.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/CharStream.java
deleted file mode 100644
index 5ac0990e4c4..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/CharStream.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-/** A source of characters for an ANTLR lexer */
-public interface CharStream extends IntStream {
- public static final int EOF = -1;
-
- /** For infinite streams, you don't need this; primarily I'm providing
- * a useful interface for action code. Just make sure actions don't
- * use this on streams that don't support it.
- */
- public String substring(int start, int stop);
-
- /** Get the ith character of lookahead. This is the same usually as
- * LA(i). This will be used for labels in the generated
- * lexer code. I'd prefer to return a char here type-wise, but it's
- * probably better to be 32-bit clean and be consistent with LA.
- */
- public int LT(int i);
-
- /** ANTLR tracks the line information automatically */
- int getLine();
-
- /** Because this stream can rewind, we need to be able to reset the line */
- void setLine(int line);
-
- void setCharPositionInLine(int pos);
-
- /** The index of the character relative to the beginning of the line 0..n-1 */
- int getCharPositionInLine();
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/CharStreamState.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/CharStreamState.java
deleted file mode 100644
index 91bf8f4c2b0..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/CharStreamState.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-/** When walking ahead with cyclic DFA or for syntactic predicates,
- * we need to record the state of the input stream (char index,
- * line, etc...) so that we can rewind the state after scanning ahead.
- *
- * This is the complete state of a stream.
- */
-public class CharStreamState {
- /** Index into the char stream of next lookahead char */
- int p;
-
- /** What line number is the scanner at before processing buffer[p]? */
- int line;
-
- /** What char position 0..n-1 in line is scanner before processing buffer[p]? */
- int charPositionInLine;
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ClassicToken.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ClassicToken.java
deleted file mode 100644
index bd92e3c7b12..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ClassicToken.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-/** A Token object like we'd use in ANTLR 2.x; has an actual string created
- * and associated with this object. These objects are needed for imaginary
- * tree nodes that have payload objects. We need to create a Token object
- * that has a string; the tree node will point at this token. CommonToken
- * has indexes into a char stream and hence cannot be used to introduce
- * new strings.
- */
-public class ClassicToken implements Token {
- protected String text;
- protected int type;
- protected int line;
- protected int charPositionInLine;
- protected int channel=DEFAULT_CHANNEL;
-
- /** What token number is this from 0..n-1 tokens */
- protected int index;
-
- public ClassicToken(int type) {
- this.type = type;
- }
-
- public ClassicToken(Token oldToken) {
- text = oldToken.getText();
- type = oldToken.getType();
- line = oldToken.getLine();
- charPositionInLine = oldToken.getCharPositionInLine();
- channel = oldToken.getChannel();
- }
-
- public ClassicToken(int type, String text) {
- this.type = type;
- this.text = text;
- }
-
- public ClassicToken(int type, String text, int channel) {
- this.type = type;
- this.text = text;
- this.channel = channel;
- }
-
- @Override
- public int getType() {
- return type;
- }
-
- @Override
- public void setLine(int line) {
- this.line = line;
- }
-
- @Override
- public String getText() {
- return text;
- }
-
- @Override
- public void setText(String text) {
- this.text = text;
- }
-
- @Override
- public int getLine() {
- return line;
- }
-
- @Override
- public int getCharPositionInLine() {
- return charPositionInLine;
- }
-
- @Override
- public void setCharPositionInLine(int charPositionInLine) {
- this.charPositionInLine = charPositionInLine;
- }
-
- @Override
- public int getChannel() {
- return channel;
- }
-
- @Override
- public void setChannel(int channel) {
- this.channel = channel;
- }
-
- @Override
- public void setType(int type) {
- this.type = type;
- }
-
- @Override
- public int getTokenIndex() {
- return index;
- }
-
- @Override
- public void setTokenIndex(int index) {
- this.index = index;
- }
-
- @Override
- public CharStream getInputStream() {
- return null;
- }
-
- @Override
- public void setInputStream(CharStream input) {
- }
-
- @Override
- public String toString() {
- String channelStr = "";
- if ( channel>0 ) {
- channelStr=",channel="+channel;
- }
- String txt = getText();
- if ( txt!=null ) {
- txt = txt.replaceAll("\n","\\\\n");
- txt = txt.replaceAll("\r","\\\\r");
- txt = txt.replaceAll("\t","\\\\t");
- }
- else {
- txt = "";
- }
- return "[@"+getTokenIndex()+",'"+txt+"',<"+type+">"+channelStr+","+line+":"+getCharPositionInLine()+"]";
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/CommonToken.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/CommonToken.java
deleted file mode 100644
index 9496de68b8a..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/CommonToken.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-import java.io.Serializable;
-
-public class CommonToken implements Token, Serializable {
- protected int type;
- protected int line;
- protected int charPositionInLine = -1; // set to invalid position
- protected int channel=DEFAULT_CHANNEL;
- protected transient CharStream input;
-
- /** We need to be able to change the text once in a while. If
- * this is non-null, then getText should return this. Note that
- * start/stop are not affected by changing this.
- */
- protected String text;
-
- /** What token number is this from 0..n-1 tokens; < 0 implies invalid index */
- protected int index = -1;
-
- /** The char position into the input buffer where this token starts */
- protected int start;
-
- /** The char position into the input buffer where this token stops */
- protected int stop;
-
- public CommonToken(int type) {
- this.type = type;
- }
-
- public CommonToken(CharStream input, int type, int channel, int start, int stop) {
- this.input = input;
- this.type = type;
- this.channel = channel;
- this.start = start;
- this.stop = stop;
- }
-
- public CommonToken(int type, String text) {
- this.type = type;
- this.channel = DEFAULT_CHANNEL;
- this.text = text;
- }
-
- public CommonToken(Token oldToken) {
- text = oldToken.getText();
- type = oldToken.getType();
- line = oldToken.getLine();
- index = oldToken.getTokenIndex();
- charPositionInLine = oldToken.getCharPositionInLine();
- channel = oldToken.getChannel();
- input = oldToken.getInputStream();
- if ( oldToken instanceof CommonToken ) {
- start = ((CommonToken)oldToken).start;
- stop = ((CommonToken)oldToken).stop;
- }
- }
-
- @Override
- public int getType() {
- return type;
- }
-
- @Override
- public void setLine(int line) {
- this.line = line;
- }
-
- @Override
- public String getText() {
- if ( text!=null ) {
- return text;
- }
- if ( input==null ) {
- return null;
- }
- int n = input.size();
- if ( start";
- }
- }
-
- /** Override the text for this token. getText() will return this text
- * rather than pulling from the buffer. Note that this does not mean
- * that start/stop indexes are not valid. It means that that input
- * was converted to a new string in the token object.
- */
- @Override
- public void setText(String text) {
- this.text = text;
- }
-
- @Override
- public int getLine() {
- return line;
- }
-
- @Override
- public int getCharPositionInLine() {
- return charPositionInLine;
- }
-
- @Override
- public void setCharPositionInLine(int charPositionInLine) {
- this.charPositionInLine = charPositionInLine;
- }
-
- @Override
- public int getChannel() {
- return channel;
- }
-
- @Override
- public void setChannel(int channel) {
- this.channel = channel;
- }
-
- @Override
- public void setType(int type) {
- this.type = type;
- }
-
- public int getStartIndex() {
- return start;
- }
-
- public void setStartIndex(int start) {
- this.start = start;
- }
-
- public int getStopIndex() {
- return stop;
- }
-
- public void setStopIndex(int stop) {
- this.stop = stop;
- }
-
- @Override
- public int getTokenIndex() {
- return index;
- }
-
- @Override
- public void setTokenIndex(int index) {
- this.index = index;
- }
-
- @Override
- public CharStream getInputStream() {
- return input;
- }
-
- @Override
- public void setInputStream(CharStream input) {
- this.input = input;
- }
-
- @Override
- public String toString() {
- String channelStr = "";
- if ( channel>0 ) {
- channelStr=",channel="+channel;
- }
- String txt = getText();
- if ( txt!=null ) {
- txt = txt.replaceAll("\n","\\\\n");
- txt = txt.replaceAll("\r","\\\\r");
- txt = txt.replaceAll("\t","\\\\t");
- }
- else {
- txt = "";
- }
- return "[@"+getTokenIndex()+","+start+":"+stop+"='"+txt+"',<"+type+">"+channelStr+","+line+":"+getCharPositionInLine()+"]";
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/CommonTokenStream.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/CommonTokenStream.java
deleted file mode 100644
index 09ed2cd42b0..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/CommonTokenStream.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-/** The most common stream of tokens where every token is buffered up
- * and tokens are filtered for a certain channel (the parser will only
- * see these tokens).
- *
- * Even though it buffers all of the tokens, this token stream pulls tokens
- * from the tokens source on demand. In other words, until you ask for a
- * token using consume(), LT(), etc. the stream does not pull from the lexer.
- *
- * The only difference between this stream and BufferedTokenStream superclass
- * is that this stream knows how to ignore off channel tokens. There may be
- * a performance advantage to using the superclass if you don't pass
- * whitespace and comments etc. to the parser on a hidden channel (i.e.,
- * you set $channel instead of calling skip() in lexer rules.)
- *
- * @see org.eclipse.persistence.internal.libraries.antlr.runtime.UnbufferedTokenStream
- * @see org.eclipse.persistence.internal.libraries.antlr.runtime.BufferedTokenStream
- */
-public class CommonTokenStream extends BufferedTokenStream {
- /** Skip tokens on any channel but this one; this is how we skip whitespace... */
- protected int channel = Token.DEFAULT_CHANNEL;
-
- public CommonTokenStream() { }
-
- public CommonTokenStream(TokenSource tokenSource) {
- super(tokenSource);
- }
-
- public CommonTokenStream(TokenSource tokenSource, int channel) {
- this(tokenSource);
- this.channel = channel;
- }
-
- /** Always leave p on an on-channel token. */
- @Override
- public void consume() {
- if ( p == -1 ) setup();
- p++;
- sync(p);
- while ( tokens.get(p).getChannel()!=channel ) {
- p++;
- sync(p);
- }
- }
-
- @Override
- protected Token LB(int k) {
- if ( k==0 || (p-k)<0 ) return null;
-
- int i = p;
- int n = 1;
- // find k good tokens looking backwards
- while ( n<=k ) {
- // skip off-channel tokens
- i = skipOffTokenChannelsReverse(i-1);
- n++;
- }
- if ( i<0 ) return null;
- return tokens.get(i);
- }
-
- @Override
- public Token LT(int k) {
- //System.out.println("enter LT("+k+")");
- if ( p == -1 ) setup();
- if ( k == 0 ) return null;
- if ( k < 0 ) return LB(-k);
- int i = p;
- int n = 1; // we know tokens[p] is a good one
- // find k good tokens
- while ( nrange ) range = i;
- return tokens.get(i);
- }
-
- /** Given a starting index, return the index of the first on-channel
- * token.
- */
- protected int skipOffTokenChannels(int i) {
- sync(i);
- while ( tokens.get(i).getChannel()!=channel ) { // also stops at EOF (it's onchannel)
- i++;
- sync(i);
- }
- return i;
- }
-
- protected int skipOffTokenChannelsReverse(int i) {
- while ( i>=0 && tokens.get(i).getChannel()!=channel ) {
- i--;
- }
- return i;
- }
-
- @Override
- public void reset() {
- super.reset();
- p = skipOffTokenChannels(0);
- }
-
- @Override
- protected void setup() {
- p = 0;
- sync(0);
- int i = 0;
- while ( tokens.get(i).getChannel()!=channel ) {
- i++;
- sync(i);
- }
- p = i;
- }
-
- /** Count EOF just once. */
- public int getNumberOfOnChannelTokens() {
- int n = 0;
- fill();
- for (int i = 0; i < tokens.size(); i++) {
- Token t = tokens.get(i);
- if ( t.getChannel()==channel ) n++;
- if ( t.getType()==Token.EOF ) break;
- }
- return n;
- }
-
- /** Reset this token stream by setting its token source. */
- @Override
- public void setTokenSource(TokenSource tokenSource) {
- super.setTokenSource(tokenSource);
- channel = Token.DEFAULT_CHANNEL;
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/DFA.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/DFA.java
deleted file mode 100644
index 490b6bd90ad..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/DFA.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-/** A DFA implemented as a set of transition tables.
- *
- * Any state that has a semantic predicate edge is special; those states
- * are generated with if-then-else structures in a specialStateTransition()
- * which is generated by cyclicDFA template.
- *
- * There are at most 32767 states (16-bit signed short).
- * Could get away with byte sometimes but would have to generate different
- * types and the simulation code too. For a point of reference, the Java
- * lexer's Tokens rule DFA has 326 states roughly.
- */
-public class DFA {
- protected short[] eot;
- protected short[] eof;
- protected char[] min;
- protected char[] max;
- protected short[] accept;
- protected short[] special;
- protected short[][] transition;
-
- protected int decisionNumber;
-
- /** Which recognizer encloses this DFA? Needed to check backtracking */
- protected BaseRecognizer recognizer;
-
- public static final boolean debug = false;
-
- /** From the input stream, predict what alternative will succeed
- * using this DFA (representing the covering regular approximation
- * to the underlying CFL). Return an alternative number 1..n. Throw
- * an exception upon error.
- */
- public int predict(IntStream input)
- throws RecognitionException
- {
- if ( debug ) {
- System.err.println("Enter DFA.predict for decision "+decisionNumber);
- }
- int mark = input.mark(); // remember where decision started in input
- int s = 0; // we always start at s0
- try {
- while ( true ) {
- if ( debug ) System.err.println("DFA "+decisionNumber+" state "+s+" LA(1)="+(char)input.LA(1)+"("+input.LA(1)+
- "), index="+input.index());
- int specialState = special[s];
- if ( specialState>=0 ) {
- if ( debug ) {
- System.err.println("DFA "+decisionNumber+
- " state "+s+" is special state "+specialState);
- }
- s = specialStateTransition(specialState,input);
- if ( debug ) {
- System.err.println("DFA "+decisionNumber+
- " returns from special state "+specialState+" to "+s);
- }
- if ( s==-1 ) {
- noViableAlt(s,input);
- return 0;
- }
- input.consume();
- continue;
- }
- if ( accept[s] >= 1 ) {
- if ( debug ) System.err.println("accept; predict "+accept[s]+" from state "+s);
- return accept[s];
- }
- // look for a normal char transition
- char c = (char)input.LA(1); // -1 == \uFFFF, all tokens fit in 65000 space
- if (c>=min[s] && c<=max[s]) {
- int snext = transition[s][c-min[s]]; // move to next state
- if ( snext < 0 ) {
- // was in range but not a normal transition
- // must check EOT, which is like the else clause.
- // eot[s]>=0 indicates that an EOT edge goes to another
- // state.
- if ( eot[s]>=0 ) { // EOT Transition to accept state?
- if ( debug ) System.err.println("EOT transition");
- s = eot[s];
- input.consume();
- // TODO: I had this as return accept[eot[s]]
- // which assumed here that the EOT edge always
- // went to an accept...faster to do this, but
- // what about predicated edges coming from EOT
- // target?
- continue;
- }
- noViableAlt(s,input);
- return 0;
- }
- s = snext;
- input.consume();
- continue;
- }
- if ( eot[s]>=0 ) { // EOT Transition?
- if ( debug ) System.err.println("EOT transition");
- s = eot[s];
- input.consume();
- continue;
- }
- if ( c==(char)Token.EOF && eof[s]>=0 ) { // EOF Transition to accept state?
- if ( debug ) System.err.println("accept via EOF; predict "+accept[eof[s]]+" from "+eof[s]);
- return accept[eof[s]];
- }
- // not in range and not EOF/EOT, must be invalid symbol
- if ( debug ) {
- System.err.println("min["+s+"]="+min[s]);
- System.err.println("max["+s+"]="+max[s]);
- System.err.println("eot["+s+"]="+eot[s]);
- System.err.println("eof["+s+"]="+eof[s]);
- for (int p=0; p0) {
- recognizer.state.failed=true;
- return;
- }
- NoViableAltException nvae =
- new NoViableAltException(getDescription(),
- decisionNumber,
- s,
- input);
- error(nvae);
- throw nvae;
- }
-
- /** A hook for debugging interface */
- protected void error(NoViableAltException nvae) { ; }
-
- public int specialStateTransition(int s, IntStream input)
- throws NoViableAltException
- {
- return -1;
- }
-
- public String getDescription() {
- return "n/a";
- }
-
- /** Given a String that has a run-length-encoding of some unsigned shorts
- * like "\1\2\3\9", convert to short[] {2,9,9,9}. We do this to avoid
- * static short[] which generates so much init code that the class won't
- * compile. :(
- */
- public static short[] unpackEncodedString(String encodedString) {
- // walk first to find how big it is.
- int size = 0;
- for (int i=0; i tokens;
-
- /** Map<tokentype, channel> to override some Tokens' channel numbers */
- protected Map channelOverrideMap;
-
- /** Set<tokentype>; discard any tokens with this type */
- protected Set discardSet;
-
- /** Skip tokens on any channel but this one; this is how we skip whitespace... */
- protected int channel = Token.DEFAULT_CHANNEL;
-
- /** By default, track all incoming tokens */
- protected boolean discardOffChannelTokens = false;
-
- /** Track the last mark() call result value for use in rewind(). */
- protected int lastMarker;
-
- protected int range = -1; // how deep have we gone?
-
- /** The index into the tokens list of the current token (next token
- * to consume). p==-1 indicates that the tokens list is empty
- */
- protected int p = -1;
-
- public LegacyCommonTokenStream() {
- tokens = new ArrayList(500);
- }
-
- public LegacyCommonTokenStream(TokenSource tokenSource) {
- this();
- this.tokenSource = tokenSource;
- }
-
- public LegacyCommonTokenStream(TokenSource tokenSource, int channel) {
- this(tokenSource);
- this.channel = channel;
- }
-
- /** Reset this token stream by setting its token source. */
- public void setTokenSource(TokenSource tokenSource) {
- this.tokenSource = tokenSource;
- tokens.clear();
- p = -1;
- channel = Token.DEFAULT_CHANNEL;
- }
-
- /** Load all tokens from the token source and put in tokens.
- * This is done upon first LT request because you might want to
- * set some token type / channel overrides before filling buffer.
- */
- protected void fillBuffer() {
- int index = 0;
- Token t = tokenSource.nextToken();
- while ( t!=null && t.getType()!=CharStream.EOF ) {
- boolean discard = false;
- // is there a channel override for token type?
- if ( channelOverrideMap!=null ) {
- Integer channelI = channelOverrideMap.get(t.getType());
- if ( channelI!=null ) {
- t.setChannel(channelI);
- }
- }
- if ( discardSet!=null &&
- discardSet.contains(new Integer(t.getType())) )
- {
- discard = true;
- }
- else if ( discardOffChannelTokens && t.getChannel()!=this.channel ) {
- discard = true;
- }
- if ( !discard ) {
- t.setTokenIndex(index);
- tokens.add(t);
- index++;
- }
- t = tokenSource.nextToken();
- }
- // leave p pointing at first token on channel
- p = 0;
- p = skipOffTokenChannels(p);
- }
-
- /** Move the input pointer to the next incoming token. The stream
- * must become active with LT(1) available. consume() simply
- * moves the input pointer so that LT(1) points at the next
- * input symbol. Consume at least one token.
- *
- * Walk past any token not on the channel the parser is listening to.
- */
- @Override
- public void consume() {
- if ( p=0 && tokens.get(i).getChannel()!=channel ) {
- i--;
- }
- return i;
- }
-
- /** A simple filter mechanism whereby you can tell this token stream
- * to force all tokens of type ttype to be on channel. For example,
- * when interpreting, we cannot exec actions so we need to tell
- * the stream to force all WS and NEWLINE to be a different, ignored
- * channel.
- */
- public void setTokenTypeChannel(int ttype, int channel) {
- if ( channelOverrideMap==null ) {
- channelOverrideMap = new HashMap();
- }
- channelOverrideMap.put(ttype, channel);
- }
-
- public void discardTokenType(int ttype) {
- if ( discardSet==null ) {
- discardSet = new HashSet();
- }
- discardSet.add(ttype);
- }
-
- public void discardOffChannelTokens(boolean discardOffChannelTokens) {
- this.discardOffChannelTokens = discardOffChannelTokens;
- }
-
- public List extends Token> getTokens() {
- if ( p == -1 ) {
- fillBuffer();
- }
- return tokens;
- }
-
- public List extends Token> getTokens(int start, int stop) {
- return getTokens(start, stop, (BitSet)null);
- }
-
- /** Given a start and stop index, return a List of all tokens in
- * the token type BitSet. Return null if no tokens were found. This
- * method looks at both on and off channel tokens.
- */
- public List extends Token> getTokens(int start, int stop, BitSet types) {
- if ( p == -1 ) {
- fillBuffer();
- }
- if ( stop>=tokens.size() ) {
- stop=tokens.size()-1;
- }
- if ( start<0 ) {
- start=0;
- }
- if ( start>stop ) {
- return null;
- }
-
- // list = tokens[start:stop]:{Token t, t.getType() in types}
- List filteredTokens = new ArrayList();
- for (int i=start; i<=stop; i++) {
- Token t = tokens.get(i);
- if ( types==null || types.member(t.getType()) ) {
- filteredTokens.add(t);
- }
- }
- if ( filteredTokens.isEmpty() ) {
- filteredTokens = null;
- }
- return filteredTokens;
- }
-
- public List extends Token> getTokens(int start, int stop, List types) {
- return getTokens(start,stop,new BitSet(types));
- }
-
- public List extends Token> getTokens(int start, int stop, int ttype) {
- return getTokens(start,stop,BitSet.of(ttype));
- }
-
- /** Get the ith token from the current position 1..n where k=1 is the
- * first symbol of lookahead.
- */
- @Override
- public Token LT(int k) {
- if ( p == -1 ) {
- fillBuffer();
- }
- if ( k==0 ) {
- return null;
- }
- if ( k<0 ) {
- return LB(-k);
- }
- //System.out.print("LT(p="+p+","+k+")=");
- if ( (p+k-1) >= tokens.size() ) {
- return tokens.get(tokens.size()-1);
- }
- //System.out.println(tokens.get(p+k-1));
- int i = p;
- int n = 1;
- // find k good tokens
- while ( n=tokens.size() ) {
- return tokens.get(tokens.size()-1); // must be EOF
- }
-
- if ( i>range ) range = i;
- return tokens.get(i);
- }
-
- /** Look backwards k tokens on-channel tokens */
- protected Token LB(int k) {
- //System.out.print("LB(p="+p+","+k+") ");
- if ( p == -1 ) {
- fillBuffer();
- }
- if ( k==0 ) {
- return null;
- }
- if ( (p-k)<0 ) {
- return null;
- }
-
- int i = p;
- int n = 1;
- // find k good tokens looking backwards
- while ( n<=k ) {
- // skip off-channel tokens
- i = skipOffTokenChannelsReverse(i-1); // leave p on valid token
- n++;
- }
- if ( i<0 ) {
- return null;
- }
- return tokens.get(i);
- }
-
- /** Return absolute token i; ignore which channel the tokens are on;
- * that is, count all tokens not just on-channel tokens.
- */
- @Override
- public Token get(int i) {
- return tokens.get(i);
- }
-
- /** Get all tokens from start..stop inclusively */
- public List extends Token> get(int start, int stop) {
- if ( p == -1 ) fillBuffer();
- if ( start<0 || stop<0 ) return null;
- return tokens.subList(start, stop);
- }
-
- @Override
- public int LA(int i) {
- return LT(i).getType();
- }
-
- @Override
- public int mark() {
- if ( p == -1 ) {
- fillBuffer();
- }
- lastMarker = index();
- return lastMarker;
- }
-
- @Override
- public void release(int marker) {
- // no resources to release
- }
-
- @Override
- public int size() {
- return tokens.size();
- }
-
- @Override
- public int index() {
- return p;
- }
-
- @Override
- public int range() {
- return range;
- }
-
- @Override
- public void rewind(int marker) {
- seek(marker);
- }
-
- @Override
- public void rewind() {
- seek(lastMarker);
- }
-
- public void reset() {
- p = 0;
- lastMarker = 0;
- }
-
- @Override
- public void seek(int index) {
- p = index;
- }
-
- @Override
- public TokenSource getTokenSource() {
- return tokenSource;
- }
-
- @Override
- public String getSourceName() {
- return getTokenSource().getSourceName();
- }
-
- @Override
- public String toString() {
- if ( p == -1 ) {
- fillBuffer();
- }
- return toString(0, tokens.size()-1);
- }
-
- @Override
- public String toString(int start, int stop) {
- if ( start<0 || stop<0 ) {
- return null;
- }
- if ( p == -1 ) {
- fillBuffer();
- }
- if ( stop>=tokens.size() ) {
- stop = tokens.size()-1;
- }
- StringBuilder buf = new StringBuilder();
- for (int i = start; i <= stop; i++) {
- Token t = tokens.get(i);
- buf.append(t.getText());
- }
- return buf.toString();
- }
-
- @Override
- public String toString(Token start, Token stop) {
- if ( start!=null && stop!=null ) {
- return toString(start.getTokenIndex(), stop.getTokenIndex());
- }
- return null;
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/Lexer.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/Lexer.java
deleted file mode 100644
index 65bb293001a..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/Lexer.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-/** A lexer is recognizer that draws input symbols from a character stream.
- * lexer grammars result in a subclass of this object. A Lexer object
- * uses simplified match() and error recovery mechanisms in the interest
- * of speed.
- */
-public abstract class Lexer extends BaseRecognizer implements TokenSource {
- /** Where is the lexer drawing characters from? */
- protected CharStream input;
-
- public Lexer() {
- }
-
- public Lexer(CharStream input) {
- this.input = input;
- }
-
- public Lexer(CharStream input, RecognizerSharedState state) {
- super(state);
- this.input = input;
- }
-
- @Override
- public void reset() {
- super.reset(); // reset all recognizer state variables
- // wack Lexer state variables
- if ( input!=null ) {
- input.seek(0); // rewind the input
- }
- if ( state==null ) {
- return; // no shared state work to do
- }
- state.token = null;
- state.type = Token.INVALID_TOKEN_TYPE;
- state.channel = Token.DEFAULT_CHANNEL;
- state.tokenStartCharIndex = -1;
- state.tokenStartCharPositionInLine = -1;
- state.tokenStartLine = -1;
- state.text = null;
- }
-
- /** Return a token from this source; i.e., match a token on the char
- * stream.
- */
- public Token nextToken() {
- while (true) {
- state.token = null;
- state.channel = Token.DEFAULT_CHANNEL;
- state.tokenStartCharIndex = input.index();
- state.tokenStartCharPositionInLine = input.getCharPositionInLine();
- state.tokenStartLine = input.getLine();
- state.text = null;
- if ( input.LA(1)==CharStream.EOF ) {
- return getEOFToken();
- }
- try {
- mTokens();
- if ( state.token==null ) {
- emit();
- }
- else if ( state.token==Token.SKIP_TOKEN ) {
- continue;
- }
- return state.token;
- }
- catch (MismatchedRangeException re) {
- reportError(re);
- // matchRange() routine has already called recover()
- }
- catch (MismatchedTokenException re) {
- reportError(re);
- // match() routine has already called recover()
- }
- catch (RecognitionException re) {
- reportError(re);
- recover(re); // throw out current char and try again
- }
- }
- }
-
- /** Returns the EOF token (default), if you need
- * to return a custom token instead override this method.
- */
- public Token getEOFToken() {
- Token eof = new CommonToken(input,Token.EOF,
- Token.DEFAULT_CHANNEL,
- input.index(),input.index());
- eof.setLine(getLine());
- eof.setCharPositionInLine(getCharPositionInLine());
- return eof;
- }
-
- /** Instruct the lexer to skip creating a token for current lexer rule
- * and look for another token. nextToken() knows to keep looking when
- * a lexer rule finishes with token set to SKIP_TOKEN. Recall that
- * if token==null at end of any token rule, it creates one for you
- * and emits it.
- */
- public void skip() {
- state.token = Token.SKIP_TOKEN;
- }
-
- /** This is the lexer entry point that sets instance var 'token' */
- public abstract void mTokens() throws RecognitionException;
-
- /** Set the char stream and reset the lexer */
- public void setCharStream(CharStream input) {
- this.input = null;
- reset();
- this.input = input;
- }
-
- public CharStream getCharStream() {
- return this.input;
- }
-
- @Override
- public String getSourceName() {
- return input.getSourceName();
- }
-
- /** Currently does not support multiple emits per nextToken invocation
- * for efficiency reasons. Subclass and override this method and
- * nextToken (to push tokens into a list and pull from that list rather
- * than a single variable as this implementation does).
- */
- public void emit(Token token) {
- state.token = token;
- }
-
- /** The standard method called to automatically emit a token at the
- * outermost lexical rule. The token object should point into the
- * char buffer start..stop. If there is a text override in 'text',
- * use that to set the token's text. Override this method to emit
- * custom Token objects.
- *
- * If you are building trees, then you should also override
- * Parser or TreeParser.getMissingSymbol().
- */
- public Token emit() {
- Token t = new CommonToken(input, state.type, state.channel, state.tokenStartCharIndex, getCharIndex()-1);
- t.setLine(state.tokenStartLine);
- t.setText(state.text);
- t.setCharPositionInLine(state.tokenStartCharPositionInLine);
- emit(t);
- return t;
- }
-
- public void match(String s) throws MismatchedTokenException {
- int i = 0;
- while ( i0 ) {
- state.failed = true;
- return;
- }
- MismatchedTokenException mte =
- new MismatchedTokenException(s.charAt(i), input);
- recover(mte);
- throw mte;
- }
- i++;
- input.consume();
- state.failed = false;
- }
- }
-
- public void matchAny() {
- input.consume();
- }
-
- public void match(int c) throws MismatchedTokenException {
- if ( input.LA(1)!=c ) {
- if ( state.backtracking>0 ) {
- state.failed = true;
- return;
- }
- MismatchedTokenException mte =
- new MismatchedTokenException(c, input);
- recover(mte); // don't really recover; just consume in lexer
- throw mte;
- }
- input.consume();
- state.failed = false;
- }
-
- public void matchRange(int a, int b)
- throws MismatchedRangeException
- {
- if ( input.LA(1)b ) {
- if ( state.backtracking>0 ) {
- state.failed = true;
- return;
- }
- MismatchedRangeException mre =
- new MismatchedRangeException(a,b,input);
- recover(mre);
- throw mre;
- }
- input.consume();
- state.failed = false;
- }
-
- public int getLine() {
- return input.getLine();
- }
-
- public int getCharPositionInLine() {
- return input.getCharPositionInLine();
- }
-
- /** What is the index of the current character of lookahead? */
- public int getCharIndex() {
- return input.index();
- }
-
- /** Return the text matched so far for the current token or any
- * text override.
- */
- public String getText() {
- if ( state.text!=null ) {
- return state.text;
- }
- return input.substring(state.tokenStartCharIndex,getCharIndex()-1);
- }
-
- /** Set the complete text of this token; it wipes any previous
- * changes to the text.
- */
- public void setText(String text) {
- state.text = text;
- }
-
- @Override
- public void reportError(RecognitionException e) {
- /** TODO: not thought about recovery in lexer yet.
- *
- // if we've already reported an error and have not matched a token
- // yet successfully, don't report any errors.
- if ( errorRecovery ) {
- //System.err.print("[SPURIOUS] ");
- return;
- }
- errorRecovery = true;
- */
-
- displayRecognitionError(this.getTokenNames(), e);
- }
-
- @Override
- public String getErrorMessage(RecognitionException e, String[] tokenNames) {
- String msg;
- if ( e instanceof MismatchedTokenException ) {
- MismatchedTokenException mte = (MismatchedTokenException)e;
- msg = "mismatched character "+getCharErrorDisplay(e.c)+" expecting "+getCharErrorDisplay(mte.expecting);
- }
- else if ( e instanceof NoViableAltException ) {
- NoViableAltException nvae = (NoViableAltException)e;
- // for development, can add "decision=<<"+nvae.grammarDecisionDescription+">>"
- // and "(decision="+nvae.decisionNumber+") and
- // "state "+nvae.stateNumber
- msg = "no viable alternative at character "+getCharErrorDisplay(e.c);
- }
- else if ( e instanceof EarlyExitException ) {
- EarlyExitException eee = (EarlyExitException)e;
- // for development, can add "(decision="+eee.decisionNumber+")"
- msg = "required (...)+ loop did not match anything at character "+getCharErrorDisplay(e.c);
- }
- else if ( e instanceof MismatchedNotSetException ) {
- MismatchedNotSetException mse = (MismatchedNotSetException)e;
- msg = "mismatched character "+getCharErrorDisplay(e.c)+" expecting set "+mse.expecting;
- }
- else if ( e instanceof MismatchedSetException ) {
- MismatchedSetException mse = (MismatchedSetException)e;
- msg = "mismatched character "+getCharErrorDisplay(e.c)+" expecting set "+mse.expecting;
- }
- else if ( e instanceof MismatchedRangeException ) {
- MismatchedRangeException mre = (MismatchedRangeException)e;
- msg = "mismatched character "+getCharErrorDisplay(e.c)+" expecting set "+
- getCharErrorDisplay(mre.a)+".."+getCharErrorDisplay(mre.b);
- }
- else {
- msg = super.getErrorMessage(e, tokenNames);
- }
- return msg;
- }
-
- public String getCharErrorDisplay(int c) {
- String s = String.valueOf((char)c);
- switch ( c ) {
- case Token.EOF :
- s = "";
- break;
- case '\n' :
- s = "\\n";
- break;
- case '\t' :
- s = "\\t";
- break;
- case '\r' :
- s = "\\r";
- break;
- }
- return "'"+s+"'";
- }
-
- /** Lexers can normally match any char in it's vocabulary after matching
- * a token, so do the easy thing and just kill a character and hope
- * it all works out. You can instead use the rule invocation stack
- * to do sophisticated error recovery if you are in a fragment rule.
- */
- public void recover(RecognitionException re) {
- //System.out.println("consuming char "+(char)input.LA(1)+" during recovery");
- //re.printStackTrace();
- input.consume();
- }
-
- public void traceIn(String ruleName, int ruleIndex) {
- String inputSymbol = ((char)input.LT(1))+" line="+getLine()+":"+getCharPositionInLine();
- super.traceIn(ruleName, ruleIndex, inputSymbol);
- }
-
- public void traceOut(String ruleName, int ruleIndex) {
- String inputSymbol = ((char)input.LT(1))+" line="+getLine()+":"+getCharPositionInLine();
- super.traceOut(ruleName, ruleIndex, inputSymbol);
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedNotSetException.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedNotSetException.java
deleted file mode 100644
index d95d3b568c7..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedNotSetException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-public class MismatchedNotSetException extends MismatchedSetException {
- /** Used for remote debugger deserialization */
- public MismatchedNotSetException() {;}
-
- public MismatchedNotSetException(BitSet expecting, IntStream input) {
- super(expecting, input);
- }
-
- @Override
- public String toString() {
- return "MismatchedNotSetException("+getUnexpectedType()+"!="+expecting+")";
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedRangeException.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedRangeException.java
deleted file mode 100644
index 2cd18ee9d83..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedRangeException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-public class MismatchedRangeException extends RecognitionException {
- public int a,b;
-
- /** Used for remote debugger deserialization */
- public MismatchedRangeException() {;}
-
- public MismatchedRangeException(int a, int b, IntStream input) {
- super(input);
- this.a = a;
- this.b = b;
- }
-
- @Override
- public String toString() {
- return "MismatchedNotSetException("+getUnexpectedType()+" not in ["+a+","+b+"])";
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedSetException.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedSetException.java
deleted file mode 100644
index 3230833c3d6..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedSetException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-public class MismatchedSetException extends RecognitionException {
- public BitSet expecting;
-
- /** Used for remote debugger deserialization */
- public MismatchedSetException() {;}
-
- public MismatchedSetException(BitSet expecting, IntStream input) {
- super(input);
- this.expecting = expecting;
- }
-
- @Override
- public String toString() {
- return "MismatchedSetException("+getUnexpectedType()+"!="+expecting+")";
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedTokenException.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedTokenException.java
deleted file mode 100644
index e9f19b48051..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedTokenException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-/** A mismatched char or Token or tree node */
-public class MismatchedTokenException extends RecognitionException {
- public int expecting = Token.INVALID_TOKEN_TYPE;
-
- /** Used for remote debugger deserialization */
- public MismatchedTokenException() {;}
-
- public MismatchedTokenException(int expecting, IntStream input) {
- super(input);
- this.expecting = expecting;
- }
-
- @Override
- public String toString() {
- return "MismatchedTokenException("+getUnexpectedType()+"!="+expecting+")";
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedTreeNodeException.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedTreeNodeException.java
deleted file mode 100644
index 3f2387fc9c5..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MismatchedTreeNodeException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-import org.eclipse.persistence.internal.libraries.antlr.runtime.tree.TreeNodeStream;
-
-/**
- */
-public class MismatchedTreeNodeException extends RecognitionException {
- public int expecting;
-
- public MismatchedTreeNodeException() {
- }
-
- public MismatchedTreeNodeException(int expecting, TreeNodeStream input) {
- super(input);
- this.expecting = expecting;
- }
-
- @Override
- public String toString() {
- return "MismatchedTreeNodeException("+getUnexpectedType()+"!="+expecting+")";
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MissingTokenException.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MissingTokenException.java
deleted file mode 100644
index 5c684e332ec..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/MissingTokenException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-/** We were expecting a token but it's not found. The current token
- * is actually what we wanted next. Used for tree node errors too.
- */
-public class MissingTokenException extends MismatchedTokenException {
- public Object inserted;
- /** Used for remote debugger deserialization */
- public MissingTokenException() {;}
-
- public MissingTokenException(int expecting, IntStream input, Object inserted) {
- super(expecting, input);
- this.inserted = inserted;
- }
-
- public int getMissingType() {
- return expecting;
- }
-
- @Override
- public String toString() {
- if ( inserted!=null && token!=null ) {
- return "MissingTokenException(inserted "+inserted+" at "+token.getText()+")";
- }
- if ( token!=null ) {
- return "MissingTokenException(at "+token.getText()+")";
- }
- return "MissingTokenException";
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/NoViableAltException.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/NoViableAltException.java
deleted file mode 100644
index bb5c3c0dbea..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/NoViableAltException.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-public class NoViableAltException extends RecognitionException {
- public String grammarDecisionDescription;
- public int decisionNumber;
- public int stateNumber;
-
- /** Used for remote debugger deserialization */
- public NoViableAltException() {;}
-
- public NoViableAltException(String grammarDecisionDescription,
- int decisionNumber,
- int stateNumber,
- IntStream input)
- {
- super(input);
- this.grammarDecisionDescription = grammarDecisionDescription;
- this.decisionNumber = decisionNumber;
- this.stateNumber = stateNumber;
- }
-
- @Override
- public String toString() {
- if ( input instanceof CharStream ) {
- return "NoViableAltException('"+(char)getUnexpectedType()+"'@["+grammarDecisionDescription+"])";
- }
- else {
- return "NoViableAltException("+getUnexpectedType()+"@["+grammarDecisionDescription+"])";
- }
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/Parser.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/Parser.java
deleted file mode 100644
index 1ef4d017b52..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/Parser.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-/** A parser for TokenStreams. "parser grammars" result in a subclass
- * of this.
- */
-public class Parser extends BaseRecognizer {
- public TokenStream input;
-
- public Parser(TokenStream input) {
- super(); // highlight that we go to super to set state object
- setTokenStream(input);
- }
-
- public Parser(TokenStream input, RecognizerSharedState state) {
- super(state); // share the state object with another parser
- this.input = input;
- }
-
- @Override
- public void reset() {
- super.reset(); // reset all recognizer state variables
- if ( input!=null ) {
- input.seek(0); // rewind the input
- }
- }
-
- @Override
- protected Object getCurrentInputSymbol(IntStream input) {
- return ((TokenStream)input).LT(1);
- }
-
- @Override
- protected Object getMissingSymbol(IntStream input,
- RecognitionException e,
- int expectedTokenType,
- BitSet follow)
- {
- String tokenText;
- if ( expectedTokenType==Token.EOF ) tokenText = "";
- else tokenText = "";
- CommonToken t = new CommonToken(expectedTokenType, tokenText);
- Token current = ((TokenStream)input).LT(1);
- if ( current.getType() == Token.EOF ) {
- current = ((TokenStream)input).LT(-1);
- }
- t.line = current.getLine();
- t.charPositionInLine = current.getCharPositionInLine();
- t.channel = DEFAULT_TOKEN_CHANNEL;
- t.input = current.getInputStream();
- return t;
- }
-
- /** Set the token stream and reset the parser */
- public void setTokenStream(TokenStream input) {
- this.input = null;
- reset();
- this.input = input;
- }
-
- public TokenStream getTokenStream() {
- return input;
- }
-
- @Override
- public String getSourceName() {
- return input.getSourceName();
- }
-
- public void traceIn(String ruleName, int ruleIndex) {
- super.traceIn(ruleName, ruleIndex, input.LT(1));
- }
-
- public void traceOut(String ruleName, int ruleIndex) {
- super.traceOut(ruleName, ruleIndex, input.LT(1));
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ParserRuleReturnScope.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ParserRuleReturnScope.java
deleted file mode 100644
index f07806ed3c3..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/ParserRuleReturnScope.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-/** Rules that return more than a single value must return an object
- * containing all the values. Besides the properties defined in
- * RuleLabelScope.predefinedRulePropertiesScope there may be user-defined
- * return values. This class simply defines the minimum properties that
- * are always defined and methods to access the others that might be
- * available depending on output option such as template and tree.
- *
- * Note text is not an actual property of the return value, it is computed
- * from start and stop using the input stream's toString() method. I
- * could add a ctor to this so that we can pass in and store the input
- * stream, but I'm not sure we want to do that. It would seem to be undefined
- * to get the .text property anyway if the rule matches tokens from multiple
- * input streams.
- *
- * I do not use getters for fields of objects that are used simply to
- * group values such as this aggregate. The getters/setters are there to
- * satisfy the superclass interface.
- */
-public class ParserRuleReturnScope extends RuleReturnScope {
- public Token start, stop;
- @Override
- public Object getStart() { return start; }
- @Override
- public Object getStop() { return stop; }
-
- @Override
- public Object getTree() { return null; }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/RecognitionException.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/RecognitionException.java
deleted file mode 100644
index 75c2d984a41..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/RecognitionException.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-import org.eclipse.persistence.internal.libraries.antlr.runtime.tree.*;
-
-/** The root of the ANTLR exception hierarchy.
- *
- * To avoid English-only error messages and to generally make things
- * as flexible as possible, these exceptions are not created with strings,
- * but rather the information necessary to generate an error. Then
- * the various reporting methods in Parser and Lexer can be overridden
- * to generate a localized error message. For example, MismatchedToken
- * exceptions are built with the expected token type.
- * So, don't expect getMessage() to return anything.
- *
- * Note that as of Java 1.4, you can access the stack trace, which means
- * that you can compute the complete trace of rules from the start symbol.
- * This gives you considerable context information with which to generate
- * useful error messages.
- *
- * ANTLR generates code that throws exceptions upon recognition error and
- * also generates code to catch these exceptions in each rule. If you
- * want to quit upon first error, you can turn off the automatic error
- * handling mechanism using rulecatch action, but you still need to
- * override methods mismatch and recoverFromMismatchSet.
- *
- * In general, the recognition exceptions can track where in a grammar a
- * problem occurred and/or what was the expected input. While the parser
- * knows its state (such as current input symbol and line info) that
- * state can change before the exception is reported so current token index
- * is computed and stored at exception time. From this info, you can
- * perhaps print an entire line of input not just a single token, for example.
- * Better to just say the recognizer had a problem and then let the parser
- * figure out a fancy report.
- */
-public class RecognitionException extends Exception {
- /** What input stream did the error occur in? */
- public transient IntStream input;
-
- /** What is index of token/char were we looking at when the error occurred? */
- public int index;
-
- /** The current Token when an error occurred. Since not all streams
- * can retrieve the ith Token, we have to track the Token object.
- * For parsers. Even when it's a tree parser, token might be set.
- */
- public Token token;
-
- /** If this is a tree parser exception, node is set to the node with
- * the problem.
- */
- public Object node;
-
- /** The current char when an error occurred. For lexers. */
- public int c;
-
- /** Track the line at which the error occurred in case this is
- * generated from a lexer. We need to track this since the
- * unexpected char doesn't carry the line info.
- */
- public int line;
-
- public int charPositionInLine;
-
- /** If you are parsing a tree node stream, you will encounter som
- * imaginary nodes w/o line/col info. We now search backwards looking
- * for most recent token with line/col info, but notify getErrorHeader()
- * that info is approximate.
- */
- public boolean approximateLineInfo;
-
- /** Used for remote debugger deserialization */
- public RecognitionException() {
- }
-
- public RecognitionException(IntStream input) {
- this.input = input;
- this.index = input.index();
- if ( input instanceof TokenStream ) {
- this.token = ((TokenStream)input).LT(1);
- this.line = token.getLine();
- this.charPositionInLine = token.getCharPositionInLine();
- }
- if ( input instanceof TreeNodeStream ) {
- extractInformationFromTreeNodeStream(input);
- }
- else if ( input instanceof CharStream ) {
- this.c = input.LA(1);
- this.line = ((CharStream)input).getLine();
- this.charPositionInLine = ((CharStream)input).getCharPositionInLine();
- }
- else {
- this.c = input.LA(1);
- }
- }
-
- protected void extractInformationFromTreeNodeStream(IntStream input) {
- TreeNodeStream nodes = (TreeNodeStream)input;
-
- this.node = nodes.LT(1);
-
- Object positionNode = null;
- if (nodes instanceof PositionTrackingStream) {
- positionNode = ((PositionTrackingStream>)nodes).getKnownPositionElement(false);
- if (positionNode == null) {
- positionNode = ((PositionTrackingStream>)nodes).getKnownPositionElement(true);
- this.approximateLineInfo = positionNode != null;
- }
- }
-
- TreeAdaptor adaptor = nodes.getTreeAdaptor();
- Token payload = adaptor.getToken(positionNode != null ? positionNode : this.node);
- if ( payload!=null ) {
- this.token = payload;
- if ( payload.getLine()<= 0 ) {
- // imaginary node; no line/pos info; scan backwards
- int i = -1;
- Object priorNode = nodes.LT(i);
- while ( priorNode!=null ) {
- Token priorPayload = adaptor.getToken(priorNode);
- if ( priorPayload!=null && priorPayload.getLine()>0 ) {
- // we found the most recent real line / pos info
- this.line = priorPayload.getLine();
- this.charPositionInLine = priorPayload.getCharPositionInLine();
- this.approximateLineInfo = true;
- break;
- }
-
- --i;
- try {
- priorNode = nodes.LT(i);
- } catch (UnsupportedOperationException ex) {
- priorNode = null;
- }
- }
- }
- else { // node created from real token
- this.line = payload.getLine();
- this.charPositionInLine = payload.getCharPositionInLine();
- }
- }
- else if ( this.node instanceof Tree) {
- this.line = ((Tree)this.node).getLine();
- this.charPositionInLine = ((Tree)this.node).getCharPositionInLine();
- if ( this.node instanceof CommonTree) {
- this.token = ((CommonTree)this.node).token;
- }
- }
- else {
- int type = adaptor.getType(this.node);
- String text = adaptor.getText(this.node);
- this.token = new CommonToken(type, text);
- }
- }
-
- /** Return the token type or char of the unexpected input element */
- public int getUnexpectedType() {
- if ( input instanceof TokenStream ) {
- return token.getType();
- }
- else if ( input instanceof TreeNodeStream ) {
- TreeNodeStream nodes = (TreeNodeStream)input;
- TreeAdaptor adaptor = nodes.getTreeAdaptor();
- return adaptor.getType(node);
- }
- else {
- return c;
- }
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/RecognizerSharedState.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/RecognizerSharedState.java
deleted file mode 100644
index 43d6910eff7..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/RecognizerSharedState.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-import java.util.Map;
-
-/** The set of fields needed by an abstract recognizer to recognize input
- * and recover from errors etc... As a separate state object, it can be
- * shared among multiple grammars; e.g., when one grammar imports another.
- *
- * These fields are publically visible but the actual state pointer per
- * parser is protected.
- */
-public class RecognizerSharedState {
- /** Track the set of token types that can follow any rule invocation.
- * Stack grows upwards. When it hits the max, it grows 2x in size
- * and keeps going.
- */
- public BitSet[] following = new BitSet[BaseRecognizer.INITIAL_FOLLOW_STACK_SIZE];
- public int _fsp = -1;
-
- /** This is true when we see an error and before having successfully
- * matched a token. Prevents generation of more than one error message
- * per error.
- */
- public boolean errorRecovery = false;
-
- /** The index into the input stream where the last error occurred.
- * This is used to prevent infinite loops where an error is found
- * but no token is consumed during recovery...another error is found,
- * ad naseum. This is a failsafe mechanism to guarantee that at least
- * one token/tree node is consumed for two errors.
- */
- public int lastErrorIndex = -1;
-
- /** In lieu of a return value, this indicates that a rule or token
- * has failed to match. Reset to false upon valid token match.
- */
- public boolean failed = false;
-
- /** Did the recognizer encounter a syntax error? Track how many. */
- public int syntaxErrors = 0;
-
- /** If 0, no backtracking is going on. Safe to exec actions etc...
- * If >0 then it's the level of backtracking.
- */
- public int backtracking = 0;
-
- /** An array[size num rules] of Map<Integer,Integer> that tracks
- * the stop token index for each rule. ruleMemo[ruleIndex] is
- * the memoization table for ruleIndex. For key ruleStartIndex, you
- * get back the stop token for associated rule or MEMO_RULE_FAILED.
- *
- * This is only used if rule memoization is on (which it is by default).
- */
- public Map[] ruleMemo;
-
-
- // LEXER FIELDS (must be in same state object to avoid casting
- // constantly in generated code and Lexer object) :(
-
-
- /** The goal of all lexer rules/methods is to create a token object.
- * This is an instance variable as multiple rules may collaborate to
- * create a single token. nextToken will return this object after
- * matching lexer rule(s). If you subclass to allow multiple token
- * emissions, then set this to the last token to be matched or
- * something nonnull so that the auto token emit mechanism will not
- * emit another token.
- */
- public Token token;
-
- /** What character index in the stream did the current token start at?
- * Needed, for example, to get the text for current token. Set at
- * the start of nextToken.
- */
- public int tokenStartCharIndex = -1;
-
- /** The line on which the first character of the token resides */
- public int tokenStartLine;
-
- /** The character position of first character within the line */
- public int tokenStartCharPositionInLine;
-
- /** The channel number for the current token */
- public int channel;
-
- /** The token type for the current token */
- public int type;
-
- /** You can set the text for the current token to override what is in
- * the input char buffer. Use setText() or can set this instance var.
- */
- public String text;
-
- public RecognizerSharedState() {}
-
- @SuppressWarnings("unchecked")
- public RecognizerSharedState(RecognizerSharedState state) {
- if ( this.following.length < state.following.length ) {
- this.following = new BitSet[state.following.length];
- }
- System.arraycopy(state.following, 0, this.following, 0, state.following.length);
- this._fsp = state._fsp;
- this.errorRecovery = state.errorRecovery;
- this.lastErrorIndex = state.lastErrorIndex;
- this.failed = state.failed;
- this.syntaxErrors = state.syntaxErrors;
- this.backtracking = state.backtracking;
- if ( state.ruleMemo!=null ) {
- this.ruleMemo = (Map[])new Map, ?>[state.ruleMemo.length];
- System.arraycopy(state.ruleMemo, 0, this.ruleMemo, 0, state.ruleMemo.length);
- }
- this.token = state.token;
- this.tokenStartCharIndex = state.tokenStartCharIndex;
- this.tokenStartCharPositionInLine = state.tokenStartCharPositionInLine;
- this.channel = state.channel;
- this.type = state.type;
- this.text = state.text;
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/RuleReturnScope.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/RuleReturnScope.java
deleted file mode 100644
index d869c60efb8..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/RuleReturnScope.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-/** Rules can return start/stop info as well as possible trees and templates */
-public class RuleReturnScope {
- /** Return the start token or tree */
- public Object getStart() { return null; }
- /** Return the stop token or tree */
- public Object getStop() { return null; }
- /** Has a value potentially if output=AST; */
- public Object getTree() { return null; }
- /** Has a value potentially if output=template; Don't use StringTemplate
- * type as it then causes a dependency with ST lib.
- */
- public Object getTemplate() { return null; }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/SerializedGrammar.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/SerializedGrammar.java
deleted file mode 100644
index 9a5e4bd129a..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/SerializedGrammar.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-import java.io.IOException;
-import java.io.FileInputStream;
-import java.io.BufferedInputStream;
-import java.io.DataInputStream;
-import java.util.List;
-import java.util.ArrayList;
-
-public class SerializedGrammar {
- public static final String COOKIE = "$ANTLR";
- public static final int FORMAT_VERSION = 1;
- //public static org.eclipse.persistence.internal.libraries.antlr.tool.Grammar gr; // TESTING ONLY; remove later
-
- public String name;
- public char type; // in {l, p, t, c}
- public List extends Rule> rules;
-
- protected class Rule {
- String name;
- Block block;
- public Rule(String name, Block block) {
- this.name = name;
- this.block = block;
- }
- @Override
- public String toString() {
- return name+":"+block;
- }
- }
-
- protected abstract class Node {
- @Override
- public abstract String toString();
- }
-
- protected class Block extends Node {
- List[] alts;
- public Block(List[] alts) {
- this.alts = alts;
- }
- @Override
- public String toString() {
- StringBuilder buf = new StringBuilder();
- buf.append("(");
- for (int i = 0; i < alts.length; i++) {
- List> alt = alts[i];
- if ( i>0 ) buf.append("|");
- buf.append(alt.toString());
- }
- buf.append(")");
- return buf.toString();
- }
- }
-
- protected class TokenRef extends Node {
- int ttype;
- public TokenRef(int ttype) { this.ttype = ttype; }
- @Override
- public String toString() { return String.valueOf(ttype); }
- }
-
- protected class RuleRef extends Node {
- int ruleIndex;
- public RuleRef(int ruleIndex) { this.ruleIndex = ruleIndex; }
- @Override
- public String toString() { return String.valueOf(ruleIndex); }
- }
-
- public SerializedGrammar(String filename) throws IOException {
- System.out.println("loading "+filename);
- FileInputStream fis = new FileInputStream(filename);
- BufferedInputStream bos = new BufferedInputStream(fis);
- DataInputStream in = new DataInputStream(bos);
- readFile(in);
- in.close();
- }
-
- protected void readFile(DataInputStream in) throws IOException {
- String cookie = readString(in); // get $ANTLR
- if ( !cookie.equals(COOKIE) ) throw new IOException("not a serialized grammar file");
- int version = in.readByte();
- char grammarType = (char)in.readByte();
- this.type = grammarType;
- String grammarName = readString(in);
- this.name = grammarName;
- System.out.println(grammarType+" grammar "+grammarName);
- int numRules = in.readShort();
- System.out.println("num rules = "+numRules);
- rules = readRules(in, numRules);
- }
-
- protected List extends Rule> readRules(DataInputStream in, int numRules) throws IOException {
- List rules = new ArrayList();
- for (int i=0; i[] alts = (List[])new List>[nalts];
- //System.out.println("enter block n="+nalts);
- for (int i=0; i alt = readAlt(in);
- alts[i] = alt;
- }
- //System.out.println("exit block");
- return new Block(alts);
- }
-
- protected List readAlt(DataInputStream in) throws IOException {
- List alt = new ArrayList();
- byte A = in.readByte();
- if ( A!='A' ) throw new IOException("missing A on start of alt");
- byte cmd = in.readByte();
- while ( cmd!=';' ) {
- switch (cmd) {
- case 't' :
- int ttype = in.readShort();
- alt.add(new TokenRef(ttype));
- //System.out.println("read token "+gr.getTokenDisplayName(ttype));
- break;
- case 'r' :
- int ruleIndex = in.readShort();
- alt.add(new RuleRef(ruleIndex));
- //System.out.println("read rule "+gr.getRuleName(ruleIndex));
- break;
- case '.' : // wildcard
- break;
- case '-' : // range
- int from = in.readChar();
- int to = in.readChar();
- break;
- case '~' : // not
- int notThisTokenType = in.readShort();
- break;
- case 'B' : // nested block
- Block b = readBlock(in);
- alt.add(b);
- break;
- }
- cmd = in.readByte();
- }
- //System.out.println("exit alt");
- return alt;
- }
-
- protected String readString(DataInputStream in) throws IOException {
- byte c = in.readByte();
- StringBuilder buf = new StringBuilder();
- while ( c!=';' ) {
- buf.append((char)c);
- c = in.readByte();
- }
- return buf.toString();
- }
-
- @Override
- public String toString() {
- StringBuilder buf = new StringBuilder();
- buf.append(type).append(" grammar ").append(name);
- buf.append(rules);
- return buf.toString();
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/Token.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/Token.java
deleted file mode 100644
index 6dd2baf3191..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/Token.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-public interface Token {
- public static final int EOR_TOKEN_TYPE = 1;
-
- /** imaginary tree navigation type; traverse "get child" link */
- public static final int DOWN = 2;
- /** imaginary tree navigation type; finish with a child list */
- public static final int UP = 3;
-
- public static final int MIN_TOKEN_TYPE = UP+1;
-
- public static final int EOF = CharStream.EOF;
-
- public static final int INVALID_TOKEN_TYPE = 0;
- public static final Token INVALID_TOKEN = new CommonToken(INVALID_TOKEN_TYPE);
-
- /** In an action, a lexer rule can set token to this SKIP_TOKEN and ANTLR
- * will avoid creating a token for this symbol and try to fetch another.
- */
- public static final Token SKIP_TOKEN = new CommonToken(INVALID_TOKEN_TYPE);
-
- /** All tokens go to the parser (unless skip() is called in that rule)
- * on a particular "channel". The parser tunes to a particular channel
- * so that whitespace etc... can go to the parser on a "hidden" channel.
- */
- public static final int DEFAULT_CHANNEL = 0;
-
- /** Anything on different channel than DEFAULT_CHANNEL is not parsed
- * by parser.
- */
- public static final int HIDDEN_CHANNEL = 99;
-
- /** Get the text of the token */
- public String getText();
- public void setText(String text);
-
- public int getType();
- public void setType(int ttype);
- /** The line number on which this token was matched; line=1..n */
- public int getLine();
- public void setLine(int line);
-
- /** The index of the first character relative to the beginning of the line 0..n-1 */
- public int getCharPositionInLine();
- public void setCharPositionInLine(int pos);
-
- public int getChannel();
- public void setChannel(int channel);
-
- /** An index from 0..n-1 of the token object in the input stream.
- * This must be valid in order to use the ANTLRWorks debugger.
- */
- public int getTokenIndex();
- public void setTokenIndex(int index);
-
- /** From what character stream was this token created? You don't have to
- * implement but it's nice to know where a Token comes from if you have
- * include files etc... on the input.
- */
- public CharStream getInputStream();
- public void setInputStream(CharStream input);
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/TokenRewriteStream.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/TokenRewriteStream.java
deleted file mode 100644
index 38d3a536e83..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/TokenRewriteStream.java
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-import java.util.*;
-
-/** Useful for dumping out the input stream after doing some
- * augmentation or other manipulations.
- *
- * You can insert stuff, replace, and delete chunks. Note that the
- * operations are done lazily--only if you convert the buffer to a
- * String. This is very efficient because you are not moving data around
- * all the time. As the buffer of tokens is converted to strings, the
- * toString() method(s) check to see if there is an operation at the
- * current index. If so, the operation is done and then normal String
- * rendering continues on the buffer. This is like having multiple Turing
- * machine instruction streams (programs) operating on a single input tape. :)
- *
- * Since the operations are done lazily at toString-time, operations do not
- * screw up the token index values. That is, an insert operation at token
- * index i does not change the index values for tokens i+1..n-1.
- *
- * Because operations never actually alter the buffer, you may always get
- * the original token stream back without undoing anything. Since
- * the instructions are queued up, you can easily simulate transactions and
- * roll back any changes if there is an error just by removing instructions.
- * For example,
- *
- * CharStream input = new ANTLRFileStream("input");
- * TLexer lex = new TLexer(input);
- * TokenRewriteStream tokens = new TokenRewriteStream(lex);
- * T parser = new T(tokens);
- * parser.startRule();
- *
- * Then in the rules, you can execute
- * Token t,u;
- * ...
- * input.insertAfter(t, "text to put after t");}
- * input.insertAfter(u, "text after u");}
- * System.out.println(tokens.toString());
- *
- * Actually, you have to cast the 'input' to a TokenRewriteStream. :(
- *
- * You can also have multiple "instruction streams" and get multiple
- * rewrites from a single pass over the input. Just name the instruction
- * streams and use that name again when printing the buffer. This could be
- * useful for generating a C file and also its header file--all from the
- * same buffer:
- *
- * tokens.insertAfter("pass1", t, "text to put after t");}
- * tokens.insertAfter("pass2", u, "text after u");}
- * System.out.println(tokens.toString("pass1"));
- * System.out.println(tokens.toString("pass2"));
- *
- * If you don't use named rewrite streams, a "default" stream is used as
- * the first example shows.
- */
-public class TokenRewriteStream extends CommonTokenStream {
- public static final String DEFAULT_PROGRAM_NAME = "default";
- public static final int PROGRAM_INIT_SIZE = 100;
- public static final int MIN_TOKEN_INDEX = 0;
-
- // Define the rewrite operation hierarchy
-
- public class RewriteOperation {
- /** What index into rewrites List are we? */
- protected int instructionIndex;
- /** Token buffer index. */
- protected int index;
- protected Object text;
-
- protected RewriteOperation(int index) {
- this.index = index;
- }
-
- protected RewriteOperation(int index, Object text) {
- this.index = index;
- this.text = text;
- }
- /** Execute the rewrite operation by possibly adding to the buffer.
- * Return the index of the next token to operate on.
- */
- public int execute(StringBuffer buf) {
- return index;
- }
- @Override
- public String toString() {
- String opName = getClass().getName();
- int $index = opName.indexOf('$');
- opName = opName.substring($index+1, opName.length());
- return "<"+opName+"@"+tokens.get(index)+
- ":\""+text+"\">";
- }
- }
-
- class InsertBeforeOp extends RewriteOperation {
- public InsertBeforeOp(int index, Object text) {
- super(index,text);
- }
- @Override
- public int execute(StringBuffer buf) {
- buf.append(text);
- if ( tokens.get(index).getType()!=Token.EOF ) {
- buf.append(tokens.get(index).getText());
- }
- return index+1;
- }
- }
-
- /** I'm going to try replacing range from x..y with (y-x)+1 ReplaceOp
- * instructions.
- */
- class ReplaceOp extends RewriteOperation {
- protected int lastIndex;
- public ReplaceOp(int from, int to, Object text) {
- super(from,text);
- lastIndex = to;
- }
- @Override
- public int execute(StringBuffer buf) {
- if ( text!=null ) {
- buf.append(text);
- }
- return lastIndex+1;
- }
- @Override
- public String toString() {
- if ( text==null ) {
- return "";
- }
- return "";
- }
- }
-
- /** You may have multiple, named streams of rewrite operations.
- * I'm calling these things "programs."
- * Maps String (name) → rewrite (List)
- */
- protected Map> programs = null;
-
- /** Map String (program name) → Integer index */
- protected Map lastRewriteTokenIndexes = null;
-
- public TokenRewriteStream() {
- init();
- }
-
- protected void init() {
- programs = new HashMap>();
- programs.put(DEFAULT_PROGRAM_NAME, new ArrayList(PROGRAM_INIT_SIZE));
- lastRewriteTokenIndexes = new HashMap();
- }
-
- public TokenRewriteStream(TokenSource tokenSource) {
- super(tokenSource);
- init();
- }
-
- public TokenRewriteStream(TokenSource tokenSource, int channel) {
- super(tokenSource, channel);
- init();
- }
-
- public void rollback(int instructionIndex) {
- rollback(DEFAULT_PROGRAM_NAME, instructionIndex);
- }
-
- /** Rollback the instruction stream for a program so that
- * the indicated instruction (via instructionIndex) is no
- * longer in the stream. UNTESTED!
- */
- public void rollback(String programName, int instructionIndex) {
- List is = programs.get(programName);
- if ( is!=null ) {
- programs.put(programName, is.subList(MIN_TOKEN_INDEX,instructionIndex));
- }
- }
-
- public void deleteProgram() {
- deleteProgram(DEFAULT_PROGRAM_NAME);
- }
-
- /** Reset the program so that no instructions exist */
- public void deleteProgram(String programName) {
- rollback(programName, MIN_TOKEN_INDEX);
- }
-
- public void insertAfter(Token t, Object text) {
- insertAfter(DEFAULT_PROGRAM_NAME, t, text);
- }
-
- public void insertAfter(int index, Object text) {
- insertAfter(DEFAULT_PROGRAM_NAME, index, text);
- }
-
- public void insertAfter(String programName, Token t, Object text) {
- insertAfter(programName,t.getTokenIndex(), text);
- }
-
- public void insertAfter(String programName, int index, Object text) {
- // to insert after, just insert before next index (even if past end)
- insertBefore(programName,index+1, text);
- }
-
- public void insertBefore(Token t, Object text) {
- insertBefore(DEFAULT_PROGRAM_NAME, t, text);
- }
-
- public void insertBefore(int index, Object text) {
- insertBefore(DEFAULT_PROGRAM_NAME, index, text);
- }
-
- public void insertBefore(String programName, Token t, Object text) {
- insertBefore(programName, t.getTokenIndex(), text);
- }
-
- public void insertBefore(String programName, int index, Object text) {
- RewriteOperation op = new InsertBeforeOp(index,text);
- List super RewriteOperation> rewrites = getProgram(programName);
- op.instructionIndex = rewrites.size();
- rewrites.add(op);
- }
-
- public void replace(int index, Object text) {
- replace(DEFAULT_PROGRAM_NAME, index, index, text);
- }
-
- public void replace(int from, int to, Object text) {
- replace(DEFAULT_PROGRAM_NAME, from, to, text);
- }
-
- public void replace(Token indexT, Object text) {
- replace(DEFAULT_PROGRAM_NAME, indexT, indexT, text);
- }
-
- public void replace(Token from, Token to, Object text) {
- replace(DEFAULT_PROGRAM_NAME, from, to, text);
- }
-
- public void replace(String programName, int from, int to, Object text) {
- if ( from > to || from<0 || to<0 || to >= tokens.size() ) {
- throw new IllegalArgumentException("replace: range invalid: "+from+".."+to+"(size="+tokens.size()+")");
- }
- RewriteOperation op = new ReplaceOp(from, to, text);
- List super RewriteOperation> rewrites = getProgram(programName);
- op.instructionIndex = rewrites.size();
- rewrites.add(op);
- }
-
- public void replace(String programName, Token from, Token to, Object text) {
- replace(programName,
- from.getTokenIndex(),
- to.getTokenIndex(),
- text);
- }
-
- public void delete(int index) {
- delete(DEFAULT_PROGRAM_NAME, index, index);
- }
-
- public void delete(int from, int to) {
- delete(DEFAULT_PROGRAM_NAME, from, to);
- }
-
- public void delete(Token indexT) {
- delete(DEFAULT_PROGRAM_NAME, indexT, indexT);
- }
-
- public void delete(Token from, Token to) {
- delete(DEFAULT_PROGRAM_NAME, from, to);
- }
-
- public void delete(String programName, int from, int to) {
- replace(programName,from,to,null);
- }
-
- public void delete(String programName, Token from, Token to) {
- replace(programName,from,to,null);
- }
-
- public int getLastRewriteTokenIndex() {
- return getLastRewriteTokenIndex(DEFAULT_PROGRAM_NAME);
- }
-
- protected int getLastRewriteTokenIndex(String programName) {
- Integer I = lastRewriteTokenIndexes.get(programName);
- if ( I==null ) {
- return -1;
- }
- return I;
- }
-
- protected void setLastRewriteTokenIndex(String programName, int i) {
- lastRewriteTokenIndexes.put(programName, i);
- }
-
- protected List getProgram(String name) {
- List is = programs.get(name);
- if ( is==null ) {
- is = initializeProgram(name);
- }
- return is;
- }
-
- private List initializeProgram(String name) {
- List is = new ArrayList(PROGRAM_INIT_SIZE);
- programs.put(name, is);
- return is;
- }
-
- public String toOriginalString() {
- fill();
- return toOriginalString(MIN_TOKEN_INDEX, size()-1);
- }
-
- public String toOriginalString(int start, int end) {
- StringBuilder buf = new StringBuilder();
- for (int i=start; i>=MIN_TOKEN_INDEX && i<=end && i rewrites = programs.get(programName);
-
- // ensure start/end are in range
- if ( end>tokens.size()-1 ) end = tokens.size()-1;
- if ( start<0 ) start = 0;
-
- if ( rewrites==null || rewrites.isEmpty() ) {
- return toOriginalString(start,end); // no instructions to execute
- }
- StringBuffer buf = new StringBuffer();
-
- // First, optimize instruction stream
- Map indexToOp = reduceToSingleOperationPerIndex(rewrites);
-
- // Walk buffer, executing instructions and emitting tokens
- int i = start;
- while ( i <= end && i < tokens.size() ) {
- RewriteOperation op = indexToOp.get(i);
- indexToOp.remove(i); // remove so any left have index size-1
- Token t = tokens.get(i);
- if ( op==null ) {
- // no operation at that index, just dump token
- if ( t.getType()!=Token.EOF ) buf.append(t.getText());
- i++; // move to next token
- }
- else {
- i = op.execute(buf); // execute operation and skip
- }
- }
-
- // include stuff after end if it's last index in buffer
- // So, if they did an insertAfter(lastValidIndex, "foo"), include
- // foo if end==lastValidIndex.
- if ( end==tokens.size()-1 ) {
- // Scan any remaining operations after last token
- // should be included (they will be inserts).
- for (RewriteOperation op : indexToOp.values()) {
- if ( op.index >= tokens.size()-1 ) buf.append(op.text);
- }
- }
- return buf.toString();
- }
-
- /** We need to combine operations and report invalid operations (like
- * overlapping replaces that are not completed nested). Inserts to
- * same index need to be combined etc... Here are the cases:
- *
- * I.i.u I.j.v leave alone, nonoverlapping
- * I.i.u I.i.v combine: Iivu
- *
- * R.i-j.u R.x-y.v | i-j in x-y delete first R
- * R.i-j.u R.i-j.v delete first R
- * R.i-j.u R.x-y.v | x-y in i-j ERROR
- * R.i-j.u R.x-y.v | boundaries overlap ERROR
- *
- * Delete special case of replace (text==null):
- * D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right)
- *
- * I.i.u R.x-y.v | i in (x+1)-y delete I (since insert before
- * we're not deleting i)
- * I.i.u R.x-y.v | i not in (x+1)-y leave alone, nonoverlapping
- * R.x-y.v I.i.u | i in x-y ERROR
- * R.x-y.v I.x.u R.x-y.uv (combine, delete I)
- * R.x-y.v I.i.u | i not in x-y leave alone, nonoverlapping
- *
- * I.i.u = insert u before op @ index i
- * R.x-y.u = replace x-y indexed tokens with u
- *
- * First we need to examine replaces. For any replace op:
- *
- * 1. wipe out any insertions before op within that range.
- * 2. Drop any replace op before that is contained completely within
- * that range.
- * 3. Throw exception upon boundary overlap with any previous replace.
- *
- * Then we can deal with inserts:
- *
- * 1. for any inserts to same index, combine even if not adjacent.
- * 2. for any prior replace with same left boundary, combine this
- * insert with replace and delete this replace.
- * 3. throw exception if index in same range as previous replace
- *
- * Don't actually delete; make op null in list. Easier to walk list.
- * Later we can throw as we add to index → op map.
- *
- * Note that I.2 R.2-2 will wipe out I.2 even though, technically, the
- * inserted stuff would be before the replace range. But, if you
- * add tokens in front of a method body '{' and then delete the method
- * body, I think the stuff before the '{' you added should disappear too.
- *
- * Return a map from token index to operation.
- */
- protected Map reduceToSingleOperationPerIndex(List extends RewriteOperation> rewrites) {
-// System.out.println("rewrites="+rewrites);
-
- // WALK REPLACES
- for (int i = 0; i < rewrites.size(); i++) {
- RewriteOperation op = rewrites.get(i);
- if ( op==null ) continue;
- if ( !(op instanceof ReplaceOp) ) continue;
- ReplaceOp rop = (ReplaceOp)rewrites.get(i);
- // Wipe prior inserts within range
- List extends InsertBeforeOp> inserts = getKindOfOps(rewrites, InsertBeforeOp.class, i);
- for (int j = 0; j < inserts.size(); j++) {
- InsertBeforeOp iop = inserts.get(j);
- if ( iop.index == rop.index ) {
- // E.g., insert before 2, delete 2..2; update replace
- // text to include insert before, kill insert
- rewrites.set(iop.instructionIndex, null);
- rop.text = iop.text.toString() + (rop.text!=null?rop.text.toString():"");
- }
- else if ( iop.index > rop.index && iop.index <= rop.lastIndex ) {
- // delete insert as it's a no-op.
- rewrites.set(iop.instructionIndex, null);
- }
- }
- // Drop any prior replaces contained within
- List extends ReplaceOp> prevReplaces = getKindOfOps(rewrites, ReplaceOp.class, i);
- for (int j = 0; j < prevReplaces.size(); j++) {
- ReplaceOp prevRop = prevReplaces.get(j);
- if ( prevRop.index>=rop.index && prevRop.lastIndex <= rop.lastIndex ) {
- // delete replace as it's a no-op.
- rewrites.set(prevRop.instructionIndex, null);
- continue;
- }
- // throw exception unless disjoint or identical
- boolean disjoint =
- prevRop.lastIndex rop.lastIndex;
- boolean same =
- prevRop.index==rop.index && prevRop.lastIndex==rop.lastIndex;
- // Delete special case of replace (text==null):
- // D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right)
- if ( prevRop.text==null && rop.text==null && !disjoint ) {
- //System.out.println("overlapping deletes: "+prevRop+", "+rop);
- rewrites.set(prevRop.instructionIndex, null); // kill first delete
- rop.index = Math.min(prevRop.index, rop.index);
- rop.lastIndex = Math.max(prevRop.lastIndex, rop.lastIndex);
- System.out.println("new rop "+rop);
- }
- else if ( !disjoint && !same ) {
- throw new IllegalArgumentException("replace op boundaries of "+rop+
- " overlap with previous "+prevRop);
- }
- }
- }
-
- // WALK INSERTS
- for (int i = 0; i < rewrites.size(); i++) {
- RewriteOperation op = rewrites.get(i);
- if ( op==null ) continue;
- if ( !(op instanceof InsertBeforeOp) ) continue;
- InsertBeforeOp iop = (InsertBeforeOp)rewrites.get(i);
- // combine current insert with prior if any at same index
- List extends InsertBeforeOp> prevInserts = getKindOfOps(rewrites, InsertBeforeOp.class, i);
- for (int j = 0; j < prevInserts.size(); j++) {
- InsertBeforeOp prevIop = prevInserts.get(j);
- if ( prevIop.index == iop.index ) { // combine objects
- // convert to strings...we're in process of toString'ing
- // whole token buffer so no lazy eval issue with any templates
- iop.text = catOpText(iop.text,prevIop.text);
- // delete redundant prior insert
- rewrites.set(prevIop.instructionIndex, null);
- }
- }
- // look for replaces where iop.index is in range; error
- List extends ReplaceOp> prevReplaces = getKindOfOps(rewrites, ReplaceOp.class, i);
- for (int j = 0; j < prevReplaces.size(); j++) {
- ReplaceOp rop = prevReplaces.get(j);
- if ( iop.index == rop.index ) {
- rop.text = catOpText(iop.text,rop.text);
- rewrites.set(i, null); // delete current insert
- continue;
- }
- if ( iop.index >= rop.index && iop.index <= rop.lastIndex ) {
- throw new IllegalArgumentException("insert op "+iop+
- " within boundaries of previous "+rop);
- }
- }
- }
- // System.out.println("rewrites after="+rewrites);
- Map m = new HashMap();
- for (int i = 0; i < rewrites.size(); i++) {
- RewriteOperation op = rewrites.get(i);
- if ( op==null ) continue; // ignore deleted ops
- if ( m.get(op.index)!=null ) {
- throw new Error("should only be one op per index");
- }
- m.put(op.index, op);
- }
- //System.out.println("index to op: "+m);
- return m;
- }
-
- protected String catOpText(Object a, Object b) {
- String x = "";
- String y = "";
- if ( a!=null ) x = a.toString();
- if ( b!=null ) y = b.toString();
- return x+y;
- }
- protected List extends T> getKindOfOps(List extends RewriteOperation> rewrites, Class kind) {
- return getKindOfOps(rewrites, kind, rewrites.size());
- }
-
- /** Get all operations before an index of a particular kind */
- protected List extends T> getKindOfOps(List extends RewriteOperation> rewrites, Class kind, int before) {
- List ops = new ArrayList();
- for (int i=0; i=MIN_TOKEN_INDEX && i<=end && i implements TokenStream {
- protected TokenSource tokenSource;
- protected int tokenIndex = 0; // simple counter to set token index in tokens
-
- /** Skip tokens on any channel but this one; this is how we skip whitespace... */
- protected int channel = Token.DEFAULT_CHANNEL;
-
- public UnbufferedTokenStream(TokenSource tokenSource) {
- this.tokenSource = tokenSource;
- }
-
- @Override
- public Token nextElement() {
- Token t = tokenSource.nextToken();
- t.setTokenIndex(tokenIndex++);
- return t;
- }
-
- @Override
- public boolean isEOF(Token o) { return o.getType() == Token.EOF; }
-
- @Override
- public TokenSource getTokenSource() { return tokenSource; }
-
- @Override
- public String toString(int start, int stop) { return "n/a"; }
-
- @Override
- public String toString(Token start, Token stop) { return "n/a"; }
-
- @Override
- public int LA(int i) { return LT(i).getType(); }
-
- @Override
- public Token get(int i) {
- throw new UnsupportedOperationException("Absolute token indexes are meaningless in an unbuffered stream");
- }
-
- @Override
- public String getSourceName() { return tokenSource.getSourceName(); }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/UnwantedTokenException.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/UnwantedTokenException.java
deleted file mode 100644
index b512282443b..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/UnwantedTokenException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime;
-
-/** An extra token while parsing a TokenStream */
-public class UnwantedTokenException extends MismatchedTokenException {
- /** Used for remote debugger deserialization */
- public UnwantedTokenException() {;}
-
- public UnwantedTokenException(int expecting, IntStream input) {
- super(expecting, input);
- }
-
- public Token getUnexpectedToken() {
- return token;
- }
-
- @Override
- public String toString() {
- String exp = ", expected "+expecting;
- if ( expecting==Token.INVALID_TOKEN_TYPE ) {
- exp = "";
- }
- if ( token==null ) {
- return "UnwantedTokenException(found="+null+exp+")";
- }
- return "UnwantedTokenException(found="+token.getText()+exp+")";
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/BlankDebugEventListener.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/BlankDebugEventListener.java
deleted file mode 100644
index 01f3ccf9e2a..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/BlankDebugEventListener.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime.debug;
-
-import org.eclipse.persistence.internal.libraries.antlr.runtime.RecognitionException;
-import org.eclipse.persistence.internal.libraries.antlr.runtime.Token;
-
-/** A blank listener that does nothing; useful for real classes so
- * they don't have to have lots of blank methods and are less
- * sensitive to updates to debug interface.
- */
-public class BlankDebugEventListener implements DebugEventListener {
- @Override public void enterRule(String grammarFileName, String ruleName) {}
- @Override public void exitRule(String grammarFileName, String ruleName) {}
- @Override public void enterAlt(int alt) {}
- @Override public void enterSubRule(int decisionNumber) {}
- @Override public void exitSubRule(int decisionNumber) {}
- @Override public void enterDecision(int decisionNumber, boolean couldBacktrack) {}
- @Override public void exitDecision(int decisionNumber) {}
- @Override public void location(int line, int pos) {}
- @Override public void consumeToken(Token token) {}
- @Override public void consumeHiddenToken(Token token) {}
- @Override public void LT(int i, Token t) {}
- @Override public void mark(int i) {}
- @Override public void rewind(int i) {}
- @Override public void rewind() {}
- @Override public void beginBacktrack(int level) {}
- @Override public void endBacktrack(int level, boolean successful) {}
- @Override public void recognitionException(RecognitionException e) {}
- @Override public void beginResync() {}
- @Override public void endResync() {}
- @Override public void semanticPredicate(boolean result, String predicate) {}
- @Override public void commence() {}
- @Override public void terminate() {}
-
- // Tree parsing stuff
-
- @Override public void consumeNode(Object t) {}
- @Override public void LT(int i, Object t) {}
-
- // AST Stuff
-
- @Override public void nilNode(Object t) {}
- @Override public void errorNode(Object t) {}
- @Override public void createNode(Object t) {}
- @Override public void createNode(Object node, Token token) {}
- @Override public void becomeRoot(Object newRoot, Object oldRoot) {}
- @Override public void addChild(Object root, Object child) {}
- @Override public void setTokenBoundaries(Object t, int tokenStartIndex, int tokenStopIndex) {}
-}
-
-
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugEventHub.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugEventHub.java
deleted file mode 100644
index 319fea12171..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugEventHub.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime.debug;
-
-import org.eclipse.persistence.internal.libraries.antlr.runtime.Token;
-import org.eclipse.persistence.internal.libraries.antlr.runtime.RecognitionException;
-
-import java.util.List;
-import java.util.ArrayList;
-
-/** Broadcast debug events to multiple listeners. Lets you debug and still
- * use the event mechanism to build parse trees etc... Not thread-safe.
- * Don't add events in one thread while parser fires events in another.
- *
- * @see DebugEventRepeater
- */
-public class DebugEventHub implements DebugEventListener {
- protected List listeners = new ArrayList();
-
- public DebugEventHub(DebugEventListener listener) {
- listeners.add(listener);
- }
-
- public DebugEventHub(DebugEventListener a, DebugEventListener b) {
- listeners.add(a);
- listeners.add(b);
- }
-
- /** Add another listener to broadcast events too. Not thread-safe.
- * Don't add events in one thread while parser fires events in another.
- */
- public void addListener(DebugEventListener listener) {
- listeners.add(listener);
- }
-
- /* To avoid a mess like this:
- public void enterRule(final String ruleName) {
- broadcast(new Code(){
- public void exec(DebugEventListener listener) {listener.enterRule(ruleName);}}
- );
- }
- I am dup'ing the for-loop in each. Where are Java closures!? blech!
- */
-
- @Override
- public void enterRule(String grammarFileName, String ruleName) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.enterRule(grammarFileName,ruleName);
- }
- }
-
- @Override
- public void exitRule(String grammarFileName, String ruleName) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.exitRule(grammarFileName, ruleName);
- }
- }
-
- @Override
- public void enterAlt(int alt) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.enterAlt(alt);
- }
- }
-
- @Override
- public void enterSubRule(int decisionNumber) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.enterSubRule(decisionNumber);
- }
- }
-
- @Override
- public void exitSubRule(int decisionNumber) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.exitSubRule(decisionNumber);
- }
- }
-
- @Override
- public void enterDecision(int decisionNumber, boolean couldBacktrack) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.enterDecision(decisionNumber, couldBacktrack);
- }
- }
-
- @Override
- public void exitDecision(int decisionNumber) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.exitDecision(decisionNumber);
- }
- }
-
- @Override
- public void location(int line, int pos) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.location(line, pos);
- }
- }
-
- @Override
- public void consumeToken(Token token) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.consumeToken(token);
- }
- }
-
- @Override
- public void consumeHiddenToken(Token token) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.consumeHiddenToken(token);
- }
- }
-
- @Override
- public void LT(int index, Token t) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.LT(index, t);
- }
- }
-
- @Override
- public void mark(int index) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.mark(index);
- }
- }
-
- @Override
- public void rewind(int index) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.rewind(index);
- }
- }
-
- @Override
- public void rewind() {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.rewind();
- }
- }
-
- @Override
- public void beginBacktrack(int level) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.beginBacktrack(level);
- }
- }
-
- @Override
- public void endBacktrack(int level, boolean successful) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.endBacktrack(level, successful);
- }
- }
-
- @Override
- public void recognitionException(RecognitionException e) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.recognitionException(e);
- }
- }
-
- @Override
- public void beginResync() {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.beginResync();
- }
- }
-
- @Override
- public void endResync() {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.endResync();
- }
- }
-
- @Override
- public void semanticPredicate(boolean result, String predicate) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.semanticPredicate(result, predicate);
- }
- }
-
- @Override
- public void commence() {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.commence();
- }
- }
-
- @Override
- public void terminate() {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.terminate();
- }
- }
-
-
- // Tree parsing stuff
-
- @Override
- public void consumeNode(Object t) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.consumeNode(t);
- }
- }
-
- @Override
- public void LT(int index, Object t) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.LT(index, t);
- }
- }
-
-
- // AST Stuff
-
- @Override
- public void nilNode(Object t) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.nilNode(t);
- }
- }
-
- @Override
- public void errorNode(Object t) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.errorNode(t);
- }
- }
-
- @Override
- public void createNode(Object t) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.createNode(t);
- }
- }
-
- @Override
- public void createNode(Object node, Token token) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.createNode(node, token);
- }
- }
-
- @Override
- public void becomeRoot(Object newRoot, Object oldRoot) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.becomeRoot(newRoot, oldRoot);
- }
- }
-
- @Override
- public void addChild(Object root, Object child) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.addChild(root, child);
- }
- }
-
- @Override
- public void setTokenBoundaries(Object t, int tokenStartIndex, int tokenStopIndex) {
- for (int i = 0; i < listeners.size(); i++) {
- DebugEventListener listener = listeners.get(i);
- listener.setTokenBoundaries(t, tokenStartIndex, tokenStopIndex);
- }
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugEventListener.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugEventListener.java
deleted file mode 100644
index e82b3106980..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugEventListener.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime.debug;
-
-import org.eclipse.persistence.internal.libraries.antlr.runtime.RecognitionException;
-import org.eclipse.persistence.internal.libraries.antlr.runtime.Token;
-
-/** All debugging events that a recognizer can trigger.
- *
- * I did not create a separate AST debugging interface as it would create
- * lots of extra classes and DebugParser has a dbg var defined, which makes
- * it hard to change to ASTDebugEventListener. I looked hard at this issue
- * and it is easier to understand as one monolithic event interface for all
- * possible events. Hopefully, adding ST debugging stuff won't be bad. Leave
- * for future. 4/26/2006.
- */
-public interface DebugEventListener {
- /** Moved to version 2 for v3.1: added grammar name to enter/exit Rule */
- public static final String PROTOCOL_VERSION = "2";
-
- /** serialized version of true */
- public static final int TRUE = 1;
- public static final int FALSE = 0;
-
- /** The parser has just entered a rule. No decision has been made about
- * which alt is predicted. This is fired AFTER init actions have been
- * executed. Attributes are defined and available etc...
- * The grammarFileName allows composite grammars to jump around among
- * multiple grammar files.
- */
- public void enterRule(String grammarFileName, String ruleName);
-
- /** Because rules can have lots of alternatives, it is very useful to
- * know which alt you are entering. This is 1..n for n alts.
- */
- public void enterAlt(int alt);
-
- /** This is the last thing executed before leaving a rule. It is
- * executed even if an exception is thrown. This is triggered after
- * error reporting and recovery have occurred (unless the exception is
- * not caught in this rule). This implies an "exitAlt" event.
- * The grammarFileName allows composite grammars to jump around among
- * multiple grammar files.
- */
- public void exitRule(String grammarFileName, String ruleName);
-
- /** Track entry into any (...) subrule other EBNF construct */
- public void enterSubRule(int decisionNumber);
-
- public void exitSubRule(int decisionNumber);
-
- /** Every decision, fixed k or arbitrary, has an enter/exit event
- * so that a GUI can easily track what LT/consume events are
- * associated with prediction. You will see a single enter/exit
- * subrule but multiple enter/exit decision events, one for each
- * loop iteration.
- */
- public void enterDecision(int decisionNumber, boolean couldBacktrack);
-
- public void exitDecision(int decisionNumber);
-
- /** An input token was consumed; matched by any kind of element.
- * Trigger after the token was matched by things like match(), matchAny().
- */
- public void consumeToken(Token t);
-
- /** An off-channel input token was consumed.
- * Trigger after the token was matched by things like match(), matchAny().
- * (unless of course the hidden token is first stuff in the input stream).
- */
- public void consumeHiddenToken(Token t);
-
- /** Somebody (anybody) looked ahead. Note that this actually gets
- * triggered by both LA and LT calls. The debugger will want to know
- * which Token object was examined. Like consumeToken, this indicates
- * what token was seen at that depth. A remote debugger cannot look
- * ahead into a file it doesn't have so LT events must pass the token
- * even if the info is redundant.
- */
- public void LT(int i, Token t);
-
- /** The parser is going to look arbitrarily ahead; mark this location,
- * the token stream's marker is sent in case you need it.
- */
- public void mark(int marker);
-
- /** After an arbitrairly long lookahead as with a cyclic DFA (or with
- * any backtrack), this informs the debugger that stream should be
- * rewound to the position associated with marker.
- */
- public void rewind(int marker);
-
- /** Rewind to the input position of the last marker.
- * Used currently only after a cyclic DFA and just
- * before starting a sem/syn predicate to get the
- * input position back to the start of the decision.
- * Do not "pop" the marker off the state. mark(i)
- * and rewind(i) should balance still.
- */
- public void rewind();
-
- public void beginBacktrack(int level);
-
- public void endBacktrack(int level, boolean successful);
-
- /** To watch a parser move through the grammar, the parser needs to
- * inform the debugger what line/charPos it is passing in the grammar.
- * For now, this does not know how to switch from one grammar to the
- * other and back for island grammars etc...
- *
- * This should also allow breakpoints because the debugger can stop
- * the parser whenever it hits this line/pos.
- */
- public void location(int line, int pos);
-
- /** A recognition exception occurred such as NoViableAltException. I made
- * this a generic event so that I can alter the exception hierachy later
- * without having to alter all the debug objects.
- *
- * Upon error, the stack of enter rule/subrule must be properly unwound.
- * If no viable alt occurs it is within an enter/exit decision, which
- * also must be rewound. Even the rewind for each mark must be unwount.
- * In the Java target this is pretty easy using try/finally, if a bit
- * ugly in the generated code. The rewind is generated in DFA.predict()
- * actually so no code needs to be generated for that. For languages
- * w/o this "finally" feature (C++?), the target implementor will have
- * to build an event stack or something.
- *
- * Across a socket for remote debugging, only the RecognitionException
- * data fields are transmitted. The token object or whatever that
- * caused the problem was the last object referenced by LT. The
- * immediately preceding LT event should hold the unexpected Token or
- * char.
- *
- * Here is a sample event trace for grammar:
- *
- * b : C ({;}A|B) // {;} is there to prevent A|B becoming a set
- * | D
- * ;
- *
- * The sequence for this rule (with no viable alt in the subrule) for
- * input 'c c' (there are 3 tokens) is:
- *
- * commence
- * LT(1)
- * enterRule b
- * location 7 1
- * enter decision 3
- * LT(1)
- * exit decision 3
- * enterAlt1
- * location 7 5
- * LT(1)
- * consumeToken [c/<4>,1:0]
- * location 7 7
- * enterSubRule 2
- * enter decision 2
- * LT(1)
- * LT(1)
- * recognitionException NoViableAltException 2 1 2
- * exit decision 2
- * exitSubRule 2
- * beginResync
- * LT(1)
- * consumeToken [c/<4>,1:1]
- * LT(1)
- * endResync
- * LT(-1)
- * exitRule b
- * terminate
- */
- public void recognitionException(RecognitionException e);
-
- /** Indicates the recognizer is about to consume tokens to resynchronize
- * the parser. Any consume events from here until the recovered event
- * are not part of the parse--they are dead tokens.
- */
- public void beginResync();
-
- /** Indicates that the recognizer has finished consuming tokens in order
- * to resychronize. There may be multiple beginResync/endResync pairs
- * before the recognizer comes out of errorRecovery mode (in which
- * multiple errors are suppressed). This will be useful
- * in a gui where you want to probably grey out tokens that are consumed
- * but not matched to anything in grammar. Anything between
- * a beginResync/endResync pair was tossed out by the parser.
- */
- public void endResync();
-
- /** A semantic predicate was evaluate with this result and action text */
- public void semanticPredicate(boolean result, String predicate);
-
- /** Announce that parsing has begun. Not technically useful except for
- * sending events over a socket. A GUI for example will launch a thread
- * to connect and communicate with a remote parser. The thread will want
- * to notify the GUI when a connection is made. ANTLR parsers
- * trigger this upon entry to the first rule (the ruleLevel is used to
- * figure this out).
- */
- public void commence();
-
- /** Parsing is over; successfully or not. Mostly useful for telling
- * remote debugging listeners that it's time to quit. When the rule
- * invocation level goes to zero at the end of a rule, we are done
- * parsing.
- */
- public void terminate();
-
-
- // T r e e P a r s i n g
-
- /** Input for a tree parser is an AST, but we know nothing for sure
- * about a node except its type and text (obtained from the adaptor).
- * This is the analog of the consumeToken method. Again, the ID is
- * the hashCode usually of the node so it only works if hashCode is
- * not implemented. If the type is UP or DOWN, then
- * the ID is not really meaningful as it's fixed--there is
- * just one UP node and one DOWN navigation node.
- * @param t
- */
- public void consumeNode(Object t);
-
- /** The tree parser lookedahead. If the type is UP or DOWN,
- * then the ID is not really meaningful as it's fixed--there is
- * just one UP node and one DOWN navigation node.
- */
- public void LT(int i, Object t);
-
-
- // A S T E v e n t s
-
- /** A nil was created (even nil nodes have a unique ID...
- * they are not "null" per se). As of 4/28/2006, this
- * seems to be uniquely triggered when starting a new subtree
- * such as when entering a subrule in automatic mode and when
- * building a tree in rewrite mode.
- *
- * If you are receiving this event over a socket via
- * RemoteDebugEventSocketListener then only t.ID is set.
- */
- public void nilNode(Object t);
-
- /** Upon syntax error, recognizers bracket the error with an error node
- * if they are building ASTs.
- * @param t
- */
- public void errorNode(Object t);
-
- /** Announce a new node built from token elements such as type etc...
- *
- * If you are receiving this event over a socket via
- * RemoteDebugEventSocketListener then only t.ID, type, text are
- * set.
- */
- public void createNode(Object t);
-
- /** Announce a new node built from an existing token.
- *
- * If you are receiving this event over a socket via
- * RemoteDebugEventSocketListener then only node.ID and token.tokenIndex
- * are set.
- */
- public void createNode(Object node, Token token);
-
- /** Make a node the new root of an existing root. See
- *
- * Note: the newRootID parameter is possibly different
- * than the TreeAdaptor.becomeRoot() newRoot parameter.
- * In our case, it will always be the result of calling
- * TreeAdaptor.becomeRoot() and not root_n or whatever.
- *
- * The listener should assume that this event occurs
- * only when the current subrule (or rule) subtree is
- * being reset to newRootID.
- *
- * If you are receiving this event over a socket via
- * RemoteDebugEventSocketListener then only IDs are set.
- *
- * @see org.eclipse.persistence.internal.libraries.antlr.runtime.tree.TreeAdaptor#becomeRoot
- */
- public void becomeRoot(Object newRoot, Object oldRoot);
-
- /** Make childID a child of rootID.
- *
- * If you are receiving this event over a socket via
- * RemoteDebugEventSocketListener then only IDs are set.
- *
- * @see org.eclipse.persistence.internal.libraries.antlr.runtime.tree.TreeAdaptor#addChild
- */
- public void addChild(Object root, Object child);
-
- /** Set the token start/stop token index for a subtree root or node.
- *
- * If you are receiving this event over a socket via
- * RemoteDebugEventSocketListener then only t.ID is set.
- */
- public void setTokenBoundaries(Object t, int tokenStartIndex, int tokenStopIndex);
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugEventRepeater.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugEventRepeater.java
deleted file mode 100644
index cdbad757261..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugEventRepeater.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime.debug;
-
-import org.eclipse.persistence.internal.libraries.antlr.runtime.Token;
-import org.eclipse.persistence.internal.libraries.antlr.runtime.RecognitionException;
-
-/** A simple event repeater (proxy) that delegates all functionality to the
- * listener sent into the ctor. Useful if you want to listen in on a few
- * debug events w/o interrupting the debugger. Just subclass the repeater
- * and override the methods you want to listen in on. Remember to call
- * the method in this class so the event will continue on to the original
- * recipient.
- *
- * @see DebugEventHub
- */
-public class DebugEventRepeater implements DebugEventListener {
- protected DebugEventListener listener;
-
- public DebugEventRepeater(DebugEventListener listener) {
- this.listener = listener;
- }
-
- @Override public void enterRule(String grammarFileName, String ruleName) { listener.enterRule(grammarFileName, ruleName); }
- @Override public void exitRule(String grammarFileName, String ruleName) { listener.exitRule(grammarFileName, ruleName); }
- @Override public void enterAlt(int alt) { listener.enterAlt(alt); }
- @Override public void enterSubRule(int decisionNumber) { listener.enterSubRule(decisionNumber); }
- @Override public void exitSubRule(int decisionNumber) { listener.exitSubRule(decisionNumber); }
- @Override public void enterDecision(int decisionNumber, boolean couldBacktrack) { listener.enterDecision(decisionNumber, couldBacktrack); }
- @Override public void exitDecision(int decisionNumber) { listener.exitDecision(decisionNumber); }
- @Override public void location(int line, int pos) { listener.location(line, pos); }
- @Override public void consumeToken(Token token) { listener.consumeToken(token); }
- @Override public void consumeHiddenToken(Token token) { listener.consumeHiddenToken(token); }
- @Override public void LT(int i, Token t) { listener.LT(i, t); }
- @Override public void mark(int i) { listener.mark(i); }
- @Override public void rewind(int i) { listener.rewind(i); }
- @Override public void rewind() { listener.rewind(); }
- @Override public void beginBacktrack(int level) { listener.beginBacktrack(level); }
- @Override public void endBacktrack(int level, boolean successful) { listener.endBacktrack(level, successful); }
- @Override public void recognitionException(RecognitionException e) { listener.recognitionException(e); }
- @Override public void beginResync() { listener.beginResync(); }
- @Override public void endResync() { listener.endResync(); }
- @Override public void semanticPredicate(boolean result, String predicate) { listener.semanticPredicate(result, predicate); }
- @Override public void commence() { listener.commence(); }
- @Override public void terminate() { listener.terminate(); }
-
- // Tree parsing stuff
-
- @Override public void consumeNode(Object t) { listener.consumeNode(t); }
- @Override public void LT(int i, Object t) { listener.LT(i, t); }
-
- // AST Stuff
-
- @Override public void nilNode(Object t) { listener.nilNode(t); }
- @Override public void errorNode(Object t) { listener.errorNode(t); }
- @Override public void createNode(Object t) { listener.createNode(t); }
- @Override public void createNode(Object node, Token token) { listener.createNode(node, token); }
- @Override public void becomeRoot(Object newRoot, Object oldRoot) { listener.becomeRoot(newRoot, oldRoot); }
- @Override public void addChild(Object root, Object child) { listener.addChild(root, child); }
- @Override public void setTokenBoundaries(Object t, int tokenStartIndex, int tokenStopIndex) {
- listener.setTokenBoundaries(t, tokenStartIndex, tokenStopIndex);
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugEventSocketProxy.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugEventSocketProxy.java
deleted file mode 100644
index 299104e8bff..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugEventSocketProxy.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime.debug;
-
-import org.eclipse.persistence.internal.libraries.antlr.runtime.RecognitionException;
-import org.eclipse.persistence.internal.libraries.antlr.runtime.Token;
-import org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer;
-import org.eclipse.persistence.internal.libraries.antlr.runtime.tree.TreeAdaptor;
-
-import java.io.*;
-import java.net.ServerSocket;
-import java.net.Socket;
-
-/** A proxy debug event listener that forwards events over a socket to
- * a debugger (or any other listener) using a simple text-based protocol;
- * one event per line. ANTLRWorks listens on server socket with a
- * RemoteDebugEventSocketListener instance. These two objects must therefore
- * be kept in sync. New events must be handled on both sides of socket.
- */
-public class DebugEventSocketProxy extends BlankDebugEventListener {
- public static final int DEFAULT_DEBUGGER_PORT = 49100; // was 49153
- protected int port = DEFAULT_DEBUGGER_PORT;
- protected ServerSocket serverSocket;
- protected Socket socket;
- protected String grammarFileName;
- protected PrintWriter out;
- protected BufferedReader in;
-
- /** Who am i debugging? */
- protected BaseRecognizer recognizer;
-
- /** Almost certainly the recognizer will have adaptor set, but
- * we don't know how to cast it (Parser or TreeParser) to get
- * the adaptor field. Must be set with a constructor. :(
- */
- protected TreeAdaptor adaptor;
-
- public DebugEventSocketProxy(BaseRecognizer recognizer, TreeAdaptor adaptor) {
- this(recognizer, DEFAULT_DEBUGGER_PORT, adaptor);
- }
-
- public DebugEventSocketProxy(BaseRecognizer recognizer, int port, TreeAdaptor adaptor) {
- this.grammarFileName = recognizer.getGrammarFileName();
- this.adaptor = adaptor;
- this.port = port;
- }
-
- public void handshake() throws IOException {
- if ( serverSocket==null ) {
- serverSocket = new ServerSocket(port);
- socket = serverSocket.accept();
- socket.setTcpNoDelay(true);
- OutputStream os = socket.getOutputStream();
- OutputStreamWriter osw = new OutputStreamWriter(os, "UTF8");
- out = new PrintWriter(new BufferedWriter(osw));
- InputStream is = socket.getInputStream();
- InputStreamReader isr = new InputStreamReader(is, "UTF8");
- in = new BufferedReader(isr);
- out.println("ANTLR "+ DebugEventListener.PROTOCOL_VERSION);
- out.println("grammar \""+ grammarFileName);
- out.flush();
- ack();
- }
- }
-
- @Override
- public void commence() {
- // don't bother sending event; listener will trigger upon connection
- }
-
- @Override
- public void terminate() {
- transmit("terminate");
- out.close();
- try {
- socket.close();
- }
- catch (IOException ioe) {
- ioe.printStackTrace(System.err);
- }
- }
-
- protected void ack() {
- try {
- in.readLine();
- }
- catch (IOException ioe) {
- ioe.printStackTrace(System.err);
- }
- }
-
- protected void transmit(String event) {
- out.println(event);
- out.flush();
- ack();
- }
-
- @Override
- public void enterRule(String grammarFileName, String ruleName) {
- transmit("enterRule\t"+grammarFileName+"\t"+ruleName);
- }
-
- @Override
- public void enterAlt(int alt) {
- transmit("enterAlt\t"+alt);
- }
-
- @Override
- public void exitRule(String grammarFileName, String ruleName) {
- transmit("exitRule\t"+grammarFileName+"\t"+ruleName);
- }
-
- @Override
- public void enterSubRule(int decisionNumber) {
- transmit("enterSubRule\t"+decisionNumber);
- }
-
- @Override
- public void exitSubRule(int decisionNumber) {
- transmit("exitSubRule\t"+decisionNumber);
- }
-
- @Override
- public void enterDecision(int decisionNumber, boolean couldBacktrack) {
- transmit("enterDecision\t"+decisionNumber+"\t"+couldBacktrack);
- }
-
- @Override
- public void exitDecision(int decisionNumber) {
- transmit("exitDecision\t"+decisionNumber);
- }
-
- @Override
- public void consumeToken(Token t) {
- String buf = serializeToken(t);
- transmit("consumeToken\t"+buf);
- }
-
- @Override
- public void consumeHiddenToken(Token t) {
- String buf = serializeToken(t);
- transmit("consumeHiddenToken\t"+buf);
- }
-
- @Override
- public void LT(int i, Token t) {
- if(t != null)
- transmit("LT\t"+i+"\t"+serializeToken(t));
- }
-
- @Override
- public void mark(int i) {
- transmit("mark\t"+i);
- }
-
- @Override
- public void rewind(int i) {
- transmit("rewind\t"+i);
- }
-
- @Override
- public void rewind() {
- transmit("rewind");
- }
-
- @Override
- public void beginBacktrack(int level) {
- transmit("beginBacktrack\t"+level);
- }
-
- @Override
- public void endBacktrack(int level, boolean successful) {
- transmit("endBacktrack\t"+level+"\t"+(successful?TRUE:FALSE));
- }
-
- @Override
- public void location(int line, int pos) {
- transmit("location\t"+line+"\t"+pos);
- }
-
- @Override
- public void recognitionException(RecognitionException e) {
- StringBuilder buf = new StringBuilder(50);
- buf.append("exception\t");
- buf.append(e.getClass().getName());
- // dump only the data common to all exceptions for now
- buf.append("\t");
- buf.append(e.index);
- buf.append("\t");
- buf.append(e.line);
- buf.append("\t");
- buf.append(e.charPositionInLine);
- transmit(buf.toString());
- }
-
- @Override
- public void beginResync() {
- transmit("beginResync");
- }
-
- @Override
- public void endResync() {
- transmit("endResync");
- }
-
- @Override
- public void semanticPredicate(boolean result, String predicate) {
- StringBuffer buf = new StringBuffer(50);
- buf.append("semanticPredicate\t");
- buf.append(result);
- serializeText(buf, predicate);
- transmit(buf.toString());
- }
-
- // A S T P a r s i n g E v e n t s
-
- @Override
- public void consumeNode(Object t) {
- StringBuffer buf = new StringBuffer(50);
- buf.append("consumeNode");
- serializeNode(buf, t);
- transmit(buf.toString());
- }
-
- @Override
- public void LT(int i, Object t) {
- int ID = adaptor.getUniqueID(t);
- String text = adaptor.getText(t);
- int type = adaptor.getType(t);
- StringBuffer buf = new StringBuffer(50);
- buf.append("LN\t"); // lookahead node; distinguish from LT in protocol
- buf.append(i);
- serializeNode(buf, t);
- transmit(buf.toString());
- }
-
- protected void serializeNode(StringBuffer buf, Object t) {
- int ID = adaptor.getUniqueID(t);
- String text = adaptor.getText(t);
- int type = adaptor.getType(t);
- buf.append("\t");
- buf.append(ID);
- buf.append("\t");
- buf.append(type);
- Token token = adaptor.getToken(t);
- int line = -1;
- int pos = -1;
- if ( token!=null ) {
- line = token.getLine();
- pos = token.getCharPositionInLine();
- }
- buf.append("\t");
- buf.append(line);
- buf.append("\t");
- buf.append(pos);
- int tokenIndex = adaptor.getTokenStartIndex(t);
- buf.append("\t");
- buf.append(tokenIndex);
- serializeText(buf, text);
- }
-
-
- // A S T E v e n t s
-
- @Override
- public void nilNode(Object t) {
- int ID = adaptor.getUniqueID(t);
- transmit("nilNode\t"+ID);
- }
-
- @Override
- public void errorNode(Object t) {
- int ID = adaptor.getUniqueID(t);
- String text = t.toString();
- StringBuffer buf = new StringBuffer(50);
- buf.append("errorNode\t");
- buf.append(ID);
- buf.append("\t");
- buf.append(Token.INVALID_TOKEN_TYPE);
- serializeText(buf, text);
- transmit(buf.toString());
- }
-
- @Override
- public void createNode(Object t) {
- int ID = adaptor.getUniqueID(t);
- String text = adaptor.getText(t);
- int type = adaptor.getType(t);
- StringBuffer buf = new StringBuffer(50);
- buf.append("createNodeFromTokenElements\t");
- buf.append(ID);
- buf.append("\t");
- buf.append(type);
- serializeText(buf, text);
- transmit(buf.toString());
- }
-
- @Override
- public void createNode(Object node, Token token) {
- int ID = adaptor.getUniqueID(node);
- int tokenIndex = token.getTokenIndex();
- transmit("createNode\t"+ID+"\t"+tokenIndex);
- }
-
- @Override
- public void becomeRoot(Object newRoot, Object oldRoot) {
- int newRootID = adaptor.getUniqueID(newRoot);
- int oldRootID = adaptor.getUniqueID(oldRoot);
- transmit("becomeRoot\t"+newRootID+"\t"+oldRootID);
- }
-
- @Override
- public void addChild(Object root, Object child) {
- int rootID = adaptor.getUniqueID(root);
- int childID = adaptor.getUniqueID(child);
- transmit("addChild\t"+rootID+"\t"+childID);
- }
-
- @Override
- public void setTokenBoundaries(Object t, int tokenStartIndex, int tokenStopIndex) {
- int ID = adaptor.getUniqueID(t);
- transmit("setTokenBoundaries\t"+ID+"\t"+tokenStartIndex+"\t"+tokenStopIndex);
- }
-
-
- // support
-
- public void setTreeAdaptor(TreeAdaptor adaptor) { this.adaptor = adaptor; }
- public TreeAdaptor getTreeAdaptor() { return adaptor; }
-
- protected String serializeToken(Token t) {
- StringBuffer buf = new StringBuffer(50);
- buf.append(t.getTokenIndex()); buf.append('\t');
- buf.append(t.getType()); buf.append('\t');
- buf.append(t.getChannel()); buf.append('\t');
- buf.append(t.getLine()); buf.append('\t');
- buf.append(t.getCharPositionInLine());
- serializeText(buf, t.getText());
- return buf.toString();
- }
-
- protected void serializeText(StringBuffer buf, String text) {
- buf.append("\t\"");
- if ( text==null ) {
- text = "";
- }
- // escape \n and \r all text for token appears to exist on one line
- // this escape is slow but easy to understand
- text = escapeNewlines(text);
- buf.append(text);
- }
-
- protected String escapeNewlines(String txt) {
- txt = txt.replaceAll("%","%25"); // escape all escape char ;)
- txt = txt.replaceAll("\n","%0A"); // escape \n
- txt = txt.replaceAll("\r","%0D"); // escape \r
- return txt;
- }
-}
-
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugParser.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugParser.java
deleted file mode 100644
index c1af3a7bc79..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugParser.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime.debug;
-
-import org.eclipse.persistence.internal.libraries.antlr.runtime.*;
-
-import java.io.IOException;
-
-public class DebugParser extends Parser {
- /** Who to notify when events in the parser occur. */
- protected DebugEventListener dbg = null;
-
- /** Used to differentiate between fixed lookahead and cyclic DFA decisions
- * while profiling.
- */
- public boolean isCyclicDecision = false;
-
- /** Create a normal parser except wrap the token stream in a debug
- * proxy that fires consume events.
- */
- public DebugParser(TokenStream input, DebugEventListener dbg, RecognizerSharedState state) {
- super(input instanceof DebugTokenStream?input:new DebugTokenStream(input,dbg), state);
- setDebugListener(dbg);
- }
-
- public DebugParser(TokenStream input, RecognizerSharedState state) {
- super(input instanceof DebugTokenStream?input:new DebugTokenStream(input,null), state);
- }
-
- public DebugParser(TokenStream input, DebugEventListener dbg) {
- this(input instanceof DebugTokenStream?input:new DebugTokenStream(input,dbg), dbg, null);
- }
-
- /** Provide a new debug event listener for this parser. Notify the
- * input stream too that it should send events to this listener.
- */
- public void setDebugListener(DebugEventListener dbg) {
- if ( input instanceof DebugTokenStream ) {
- ((DebugTokenStream)input).setDebugListener(dbg);
- }
- this.dbg = dbg;
- }
-
- public DebugEventListener getDebugListener() {
- return dbg;
- }
-
- public void reportError(IOException e) {
- System.err.println(e);
- e.printStackTrace(System.err);
- }
-
- @Override
- public void beginResync() {
- dbg.beginResync();
- }
-
- @Override
- public void endResync() {
- dbg.endResync();
- }
-
- public void beginBacktrack(int level) {
- dbg.beginBacktrack(level);
- }
-
- public void endBacktrack(int level, boolean successful) {
- dbg.endBacktrack(level,successful);
- }
-
- @Override
- public void reportError(RecognitionException e) {
- super.reportError(e);
- dbg.recognitionException(e);
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugTokenStream.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugTokenStream.java
deleted file mode 100644
index 11537f1b15d..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/DebugTokenStream.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime.debug;
-
-import org.eclipse.persistence.internal.libraries.antlr.runtime.*;
-
-public class DebugTokenStream implements TokenStream {
- protected DebugEventListener dbg;
- public TokenStream input;
- protected boolean initialStreamState = true;
-
- /** Track the last mark() call result value for use in rewind(). */
- protected int lastMarker;
-
- public DebugTokenStream(TokenStream input, DebugEventListener dbg) {
- this.input = input;
- setDebugListener(dbg);
- // force TokenStream to get at least first valid token
- // so we know if there are any hidden tokens first in the stream
- input.LT(1);
- }
-
- public void setDebugListener(DebugEventListener dbg) {
- this.dbg = dbg;
- }
-
- @Override
- public void consume() {
- if ( initialStreamState ) {
- consumeInitialHiddenTokens();
- }
- int a = input.index();
- Token t = input.LT(1);
- input.consume();
- int b = input.index();
- dbg.consumeToken(t);
- if ( b>a+1 ) {
- // then we consumed more than one token; must be off channel tokens
- for (int i=a+1; i callStack = new Stack();
- List hiddenTokens = new ArrayList();
- int backtracking = 0;
-
- public ParseTreeBuilder(String grammarName) {
- ParseTree root = create("");
- callStack.push(root);
- }
-
- public ParseTree getTree() {
- return callStack.elementAt(0);
- }
-
- /** What kind of node to create. You might want to override
- * so I factored out creation here.
- */
- public ParseTree create(Object payload) {
- return new ParseTree(payload);
- }
-
- public ParseTree epsilonNode() {
- return create(EPSILON_PAYLOAD);
- }
-
- /** Backtracking or cyclic DFA, don't want to add nodes to tree */
- @Override
- public void enterDecision(int d, boolean couldBacktrack) { backtracking++; }
- @Override
- public void exitDecision(int i) { backtracking--; }
-
- @Override
- public void enterRule(String filename, String ruleName) {
- if ( backtracking>0 ) return;
- ParseTree parentRuleNode = callStack.peek();
- ParseTree ruleNode = create(ruleName);
- parentRuleNode.addChild(ruleNode);
- callStack.push(ruleNode);
- }
-
- @Override
- public void exitRule(String filename, String ruleName) {
- if ( backtracking>0 ) return;
- ParseTree ruleNode = callStack.peek();
- if ( ruleNode.getChildCount()==0 ) {
- ruleNode.addChild(epsilonNode());
- }
- callStack.pop();
- }
-
- @Override
- public void consumeToken(Token token) {
- if ( backtracking>0 ) return;
- ParseTree ruleNode = callStack.peek();
- ParseTree elementNode = create(token);
- elementNode.hiddenTokens = this.hiddenTokens;
- this.hiddenTokens = new ArrayList();
- ruleNode.addChild(elementNode);
- }
-
- @Override
- public void consumeHiddenToken(Token token) {
- if ( backtracking>0 ) return;
- hiddenTokens.add(token);
- }
-
- @Override
- public void recognitionException(RecognitionException e) {
- if ( backtracking>0 ) return;
- ParseTree ruleNode = callStack.peek();
- ParseTree errorNode = create(e);
- ruleNode.addChild(errorNode);
- }
-}
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/Profiler.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/Profiler.java
deleted file mode 100644
index 5b622a08a65..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/Profiler.java
+++ /dev/null
@@ -1,747 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime.debug;
-
-import org.eclipse.persistence.internal.libraries.antlr.runtime.*;
-import org.eclipse.persistence.internal.libraries.antlr.runtime.misc.DoubleKeyMap;
-
-import java.util.*;
-
-/** Using the debug event interface, track what is happening in the parser
- * and record statistics about the runtime.
- */
-public class Profiler extends BlankDebugEventListener {
- public static final String DATA_SEP = "\t";
- public static final String newline = System.getProperty("line.separator");
-
- static boolean dump = false;
-
- public static class ProfileStats {
- public String Version;
- public String name;
- public int numRuleInvocations;
- public int numUniqueRulesInvoked;
- public int numDecisionEvents;
- public int numDecisionsCovered;
- public int numDecisionsThatPotentiallyBacktrack;
- public int numDecisionsThatDoBacktrack;
- public int maxRuleInvocationDepth;
- public float avgkPerDecisionEvent;
- public float avgkPerBacktrackingDecisionEvent;
- public float averageDecisionPercentBacktracks;
- public int numBacktrackOccurrences; // doesn't count gated DFA edges
-
- public int numFixedDecisions;
- public int minDecisionMaxFixedLookaheads;
- public int maxDecisionMaxFixedLookaheads;
- public int avgDecisionMaxFixedLookaheads;
- public int stddevDecisionMaxFixedLookaheads;
- public int numCyclicDecisions;
- public int minDecisionMaxCyclicLookaheads;
- public int maxDecisionMaxCyclicLookaheads;
- public int avgDecisionMaxCyclicLookaheads;
- public int stddevDecisionMaxCyclicLookaheads;
-// int Stats.min(toArray(decisionMaxSynPredLookaheads);
-// int Stats.max(toArray(decisionMaxSynPredLookaheads);
-// int Stats.avg(toArray(decisionMaxSynPredLookaheads);
-// int Stats.stddev(toArray(decisionMaxSynPredLookaheads);
- public int numSemanticPredicates;
- public int numTokens;
- public int numHiddenTokens;
- public int numCharsMatched;
- public int numHiddenCharsMatched;
- public int numReportedErrors;
- public int numMemoizationCacheHits;
- public int numMemoizationCacheMisses;
- public int numGuessingRuleInvocations;
- public int numMemoizationCacheEntries;
- }
-
- public static class DecisionDescriptor {
- public int decision;
- public String fileName;
- public String ruleName;
- public int line;
- public int pos;
- public boolean couldBacktrack;
-
- public int n;
- public float avgk; // avg across all decision events
- public int maxk;
- public int numBacktrackOccurrences;
- public int numSemPredEvals;
- }
-
- // all about a specific exec of a single decision
- public static class DecisionEvent {
- public DecisionDescriptor decision;
- public int startIndex;
- public int k;
- public boolean backtracks; // doesn't count gated DFA edges
- public boolean evalSemPred;
- public long startTime;
- public long stopTime;
- public int numMemoizationCacheHits;
- public int numMemoizationCacheMisses;
- }
-
- /** Because I may change the stats, I need to track that for later
- * computations to be consistent.
- */
- public static final String Version = "3";
- public static final String RUNTIME_STATS_FILENAME = "runtime.stats";
-
- /** Ack, should not store parser; can't do remote stuff. Well, we pass
- * input stream around too so I guess it's ok.
- */
- public DebugParser parser = null;
-
- // working variables
-
- protected int ruleLevel = 0;
- //protected int decisionLevel = 0;
- protected Token lastRealTokenTouchedInDecision;
- protected Set uniqueRules = new HashSet();
- protected Stack currentGrammarFileName = new Stack();
- protected Stack currentRuleName = new Stack();
- protected Stack currentLine = new Stack();
- protected Stack currentPos = new Stack();
-
- // Vector
- //protected Vector decisions = new Vector(200); // need setSize
- protected DoubleKeyMap decisions =
- new DoubleKeyMap();
-
- // Record a DecisionData for each decision we hit while parsing
- protected List decisionEvents = new ArrayList();
- protected Stack decisionStack = new Stack();
-
- protected int backtrackDepth;
-
- ProfileStats stats = new ProfileStats();
-
- public Profiler() {
- }
-
- public Profiler(DebugParser parser) {
- this.parser = parser;
- }
-
- @Override
- public void enterRule(String grammarFileName, String ruleName) {
-// System.out.println("enterRule "+grammarFileName+":"+ruleName);
- ruleLevel++;
- stats.numRuleInvocations++;
- uniqueRules.add(grammarFileName+":"+ruleName);
- stats.maxRuleInvocationDepth = Math.max(stats.maxRuleInvocationDepth, ruleLevel);
- currentGrammarFileName.push( grammarFileName );
- currentRuleName.push( ruleName );
- }
-
- @Override
- public void exitRule(String grammarFileName, String ruleName) {
- ruleLevel--;
- currentGrammarFileName.pop();
- currentRuleName.pop();
- }
-
- /** Track memoization; this is not part of standard debug interface
- * but is triggered by profiling. Code gen inserts an override
- * for this method in the recognizer, which triggers this method.
- * Called from alreadyParsedRule().
- */
- public void examineRuleMemoization(IntStream input,
- int ruleIndex,
- int stopIndex, // index or MEMO_RULE_UNKNOWN...
- String ruleName)
- {
- if (dump) System.out.println("examine memo "+ruleName+" at "+input.index()+": "+stopIndex);
- if ( stopIndex==BaseRecognizer.MEMO_RULE_UNKNOWN ) {
- //System.out.println("rule "+ruleIndex+" missed @ "+input.index());
- stats.numMemoizationCacheMisses++;
- stats.numGuessingRuleInvocations++; // we'll have to enter
- currentDecision().numMemoizationCacheMisses++;
- }
- else {
- // regardless of rule success/failure, if in cache, we have a cache hit
- //System.out.println("rule "+ruleIndex+" hit @ "+input.index());
- stats.numMemoizationCacheHits++;
- currentDecision().numMemoizationCacheHits++;
- }
- }
-
- /** Warning: doesn't track success/failure, just unique recording event */
- public void memoize(IntStream input,
- int ruleIndex,
- int ruleStartIndex,
- String ruleName)
- {
- // count how many entries go into table
- if (dump) System.out.println("memoize "+ruleName);
- stats.numMemoizationCacheEntries++;
- }
-
- @Override
- public void location(int line, int pos) {
- currentLine.push(line);
- currentPos.push(pos);
- }
-
- @Override
- public void enterDecision(int decisionNumber, boolean couldBacktrack) {
- lastRealTokenTouchedInDecision = null;
- stats.numDecisionEvents++;
- int startingLookaheadIndex = parser.getTokenStream().index();
- TokenStream input = parser.getTokenStream();
- if ( dump ) System.out.println("enterDecision canBacktrack="+couldBacktrack+" "+ decisionNumber +
- " backtrack depth " + backtrackDepth +
- " @ " + input.get(input.index()) +
- " rule " +locationDescription());
- String g = currentGrammarFileName.peek();
- DecisionDescriptor descriptor = decisions.get(g, decisionNumber);
- if ( descriptor == null ) {
- descriptor = new DecisionDescriptor();
- decisions.put(g, decisionNumber, descriptor);
- descriptor.decision = decisionNumber;
- descriptor.fileName = currentGrammarFileName.peek();
- descriptor.ruleName = currentRuleName.peek();
- descriptor.line = currentLine.peek();
- descriptor.pos = currentPos.peek();
- descriptor.couldBacktrack = couldBacktrack;
- }
- descriptor.n++;
-
- DecisionEvent d = new DecisionEvent();
- decisionStack.push(d);
- d.decision = descriptor;
- d.startTime = System.currentTimeMillis();
- d.startIndex = startingLookaheadIndex;
- }
-
- @Override
- public void exitDecision(int decisionNumber) {
- DecisionEvent d = decisionStack.pop();
- d.stopTime = System.currentTimeMillis();
-
- int lastTokenIndex = lastRealTokenTouchedInDecision.getTokenIndex();
- int numHidden = getNumberOfHiddenTokens(d.startIndex, lastTokenIndex);
- int depth = lastTokenIndex - d.startIndex - numHidden + 1; // +1 counts consuming start token as 1
- d.k = depth;
- d.decision.maxk = Math.max(d.decision.maxk, depth);
-
- if (dump) System.out.println("exitDecision "+decisionNumber+" in "+d.decision.ruleName+
- " lookahead "+d.k +" max token "+lastRealTokenTouchedInDecision);
- decisionEvents.add(d); // done with decision; track all
- }
-
- @Override
- public void consumeToken(Token token) {
- if (dump) System.out.println("consume token "+token);
- if ( !inDecision() ) {
- stats.numTokens++;
- return;
- }
- if ( lastRealTokenTouchedInDecision==null ||
- lastRealTokenTouchedInDecision.getTokenIndex() < token.getTokenIndex() )
- {
- lastRealTokenTouchedInDecision = token;
- }
- DecisionEvent d = currentDecision();
- // compute lookahead depth
- int thisRefIndex = token.getTokenIndex();
- int numHidden = getNumberOfHiddenTokens(d.startIndex, thisRefIndex);
- int depth = thisRefIndex - d.startIndex - numHidden + 1; // +1 counts consuming start token as 1
- //d.maxk = Math.max(d.maxk, depth);
- if (dump) System.out.println("consume "+thisRefIndex+" "+depth+" tokens ahead in "+
- d.decision.ruleName+"-"+d.decision.decision+" start index "+d.startIndex);
- }
-
- /** The parser is in a decision if the decision depth > 0. This
- * works for backtracking also, which can have nested decisions.
- */
- public boolean inDecision() {
- return decisionStack.size()>0;
- }
-
- @Override
- public void consumeHiddenToken(Token token) {
- //System.out.println("consume hidden token "+token);
- if ( !inDecision() ) stats.numHiddenTokens++;
- }
-
- /** Track refs to lookahead if in a fixed/nonfixed decision.
- */
- @Override
- public void LT(int i, Token t) {
- if ( inDecision() && i>0 ) {
- DecisionEvent d = currentDecision();
- if (dump) System.out.println("LT("+i+")="+t+" index "+t.getTokenIndex()+" relative to "+d.decision.ruleName+"-"+
- d.decision.decision+" start index "+d.startIndex);
- if ( lastRealTokenTouchedInDecision==null ||
- lastRealTokenTouchedInDecision.getTokenIndex() < t.getTokenIndex() )
- {
- lastRealTokenTouchedInDecision = t;
- if (dump) System.out.println("set last token "+lastRealTokenTouchedInDecision);
- }
- // get starting index off stack
-// int stackTop = lookaheadStack.size()-1;
-// Integer startingIndex = (Integer)lookaheadStack.get(stackTop);
-// // compute lookahead depth
-// int thisRefIndex = parser.getTokenStream().index();
-// int numHidden =
-// getNumberOfHiddenTokens(startingIndex.intValue(), thisRefIndex);
-// int depth = i + thisRefIndex - startingIndex.intValue() - numHidden;
-// /*
-// System.out.println("LT("+i+") @ index "+thisRefIndex+" is depth "+depth+
-// " max is "+maxLookaheadInCurrentDecision);
-// */
-// if ( depth>maxLookaheadInCurrentDecision ) {
-// maxLookaheadInCurrentDecision = depth;
-// }
-// d.maxk = currentDecision()/
- }
- }
-
- /** Track backtracking decisions. You'll see a fixed or cyclic decision
- * and then a backtrack.
- *
- * enter rule
- * ...
- * enter decision
- * LA and possibly consumes (for cyclic DFAs)
- * begin backtrack level
- * mark m
- * rewind m
- * end backtrack level, success
- * exit decision
- * ...
- * exit rule
- */
- @Override
- public void beginBacktrack(int level) {
- if (dump) System.out.println("enter backtrack "+level);
- backtrackDepth++;
- DecisionEvent e = currentDecision();
- if ( e.decision.couldBacktrack ) {
- stats.numBacktrackOccurrences++;
- e.decision.numBacktrackOccurrences++;
- e.backtracks = true;
- }
- }
-
- /** Successful or not, track how much lookahead synpreds use */
- @Override
- public void endBacktrack(int level, boolean successful) {
- if (dump) System.out.println("exit backtrack "+level+": "+successful);
- backtrackDepth--;
- }
-
- @Override
- public void mark(int i) {
- if (dump) System.out.println("mark "+i);
- }
-
- @Override
- public void rewind(int i) {
- if (dump) System.out.println("rewind "+i);
- }
-
- @Override
- public void rewind() {
- if (dump) System.out.println("rewind");
- }
-
-
-
- protected DecisionEvent currentDecision() {
- return decisionStack.peek();
- }
-
- @Override
- public void recognitionException(RecognitionException e) {
- stats.numReportedErrors++;
- }
-
- @Override
- public void semanticPredicate(boolean result, String predicate) {
- stats.numSemanticPredicates++;
- if ( inDecision() ) {
- DecisionEvent d = currentDecision();
- d.evalSemPred = true;
- d.decision.numSemPredEvals++;
- if (dump) System.out.println("eval "+predicate+" in "+d.decision.ruleName+"-"+
- d.decision.decision);
- }
- }
-
- @Override
- public void terminate() {
- for (DecisionEvent e : decisionEvents) {
- //System.out.println("decision "+e.decision.decision+": k="+e.k);
- e.decision.avgk += e.k;
- stats.avgkPerDecisionEvent += e.k;
- if ( e.backtracks ) { // doesn't count gated syn preds on DFA edges
- stats.avgkPerBacktrackingDecisionEvent += e.k;
- }
- }
- stats.averageDecisionPercentBacktracks = 0.0f;
- for (DecisionDescriptor d : decisions.values()) {
- stats.numDecisionsCovered++;
- d.avgk /= (double)d.n;
- if ( d.couldBacktrack ) {
- stats.numDecisionsThatPotentiallyBacktrack++;
- float percentBacktracks = d.numBacktrackOccurrences / (float)d.n;
- //System.out.println("dec "+d.decision+" backtracks "+percentBacktracks*100+"%");
- stats.averageDecisionPercentBacktracks += percentBacktracks;
- }
- // ignore rules that backtrack along gated DFA edges
- if ( d.numBacktrackOccurrences > 0 ) {
- stats.numDecisionsThatDoBacktrack++;
- }
- }
- stats.averageDecisionPercentBacktracks /= stats.numDecisionsThatPotentiallyBacktrack;
- stats.averageDecisionPercentBacktracks *= 100; // it's a percentage
- stats.avgkPerDecisionEvent /= stats.numDecisionEvents;
- stats.avgkPerBacktrackingDecisionEvent /= (double)stats.numBacktrackOccurrences;
-
- System.err.println(toString());
- System.err.println(getDecisionStatsDump());
-
-// String stats = toNotifyString();
-// try {
-// Stats.writeReport(RUNTIME_STATS_FILENAME,stats);
-// }
-// catch (IOException ioe) {
-// System.err.println(ioe);
-// ioe.printStackTrace(System.err);
-// }
- }
-
- public void setParser(DebugParser parser) {
- this.parser = parser;
- }
-
- // R E P O R T I N G
-
- public String toNotifyString() {
- StringBuilder buf = new StringBuilder();
- buf.append(Version);
- buf.append('\t');
- buf.append(parser.getClass().getName());
-// buf.append('\t');
-// buf.append(numRuleInvocations);
-// buf.append('\t');
-// buf.append(maxRuleInvocationDepth);
-// buf.append('\t');
-// buf.append(numFixedDecisions);
-// buf.append('\t');
-// buf.append(Stats.min(decisionMaxFixedLookaheads));
-// buf.append('\t');
-// buf.append(Stats.max(decisionMaxFixedLookaheads));
-// buf.append('\t');
-// buf.append(Stats.avg(decisionMaxFixedLookaheads));
-// buf.append('\t');
-// buf.append(Stats.stddev(decisionMaxFixedLookaheads));
-// buf.append('\t');
-// buf.append(numCyclicDecisions);
-// buf.append('\t');
-// buf.append(Stats.min(decisionMaxCyclicLookaheads));
-// buf.append('\t');
-// buf.append(Stats.max(decisionMaxCyclicLookaheads));
-// buf.append('\t');
-// buf.append(Stats.avg(decisionMaxCyclicLookaheads));
-// buf.append('\t');
-// buf.append(Stats.stddev(decisionMaxCyclicLookaheads));
-// buf.append('\t');
-// buf.append(numBacktrackDecisions);
-// buf.append('\t');
-// buf.append(Stats.min(toArray(decisionMaxSynPredLookaheads)));
-// buf.append('\t');
-// buf.append(Stats.max(toArray(decisionMaxSynPredLookaheads)));
-// buf.append('\t');
-// buf.append(Stats.avg(toArray(decisionMaxSynPredLookaheads)));
-// buf.append('\t');
-// buf.append(Stats.stddev(toArray(decisionMaxSynPredLookaheads)));
-// buf.append('\t');
-// buf.append(numSemanticPredicates);
-// buf.append('\t');
-// buf.append(parser.getTokenStream().size());
-// buf.append('\t');
-// buf.append(numHiddenTokens);
-// buf.append('\t');
-// buf.append(numCharsMatched);
-// buf.append('\t');
-// buf.append(numHiddenCharsMatched);
-// buf.append('\t');
-// buf.append(numberReportedErrors);
-// buf.append('\t');
-// buf.append(numMemoizationCacheHits);
-// buf.append('\t');
-// buf.append(numMemoizationCacheMisses);
-// buf.append('\t');
-// buf.append(numGuessingRuleInvocations);
-// buf.append('\t');
-// buf.append(numMemoizationCacheEntries);
- return buf.toString();
- }
-
- @Override
- public String toString() {
- return toString(getReport());
- }
-
- public ProfileStats getReport() {
-// TokenStream input = parser.getTokenStream();
-// for (int i=0; i getDecisionStats() {
- return decisions;
- }
-
- public List getDecisionEvents() {
- return decisionEvents;
- }
-
- public static String toString(ProfileStats stats) {
- StringBuilder buf = new StringBuilder();
- buf.append("ANTLR Runtime Report; Profile Version ");
- buf.append(stats.Version);
- buf.append(newline);
- buf.append("parser name ");
- buf.append(stats.name);
- buf.append(newline);
- buf.append("Number of rule invocations ");
- buf.append(stats.numRuleInvocations);
- buf.append(newline);
- buf.append("Number of unique rules visited ");
- buf.append(stats.numUniqueRulesInvoked);
- buf.append(newline);
- buf.append("Number of decision events ");
- buf.append(stats.numDecisionEvents);
- buf.append(newline);
- buf.append("Overall average k per decision event ");
- buf.append(stats.avgkPerDecisionEvent);
- buf.append(newline);
- buf.append("Number of backtracking occurrences (can be multiple per decision) ");
- buf.append(stats.numBacktrackOccurrences);
- buf.append(newline);
- buf.append("Overall average k per decision event that backtracks ");
- buf.append(stats.avgkPerBacktrackingDecisionEvent);
- buf.append(newline);
- buf.append("Number of rule invocations while backtracking ");
- buf.append(stats.numGuessingRuleInvocations);
- buf.append(newline);
- buf.append("num decisions that potentially backtrack ");
- buf.append(stats.numDecisionsThatPotentiallyBacktrack);
- buf.append(newline);
- buf.append("num decisions that do backtrack ");
- buf.append(stats.numDecisionsThatDoBacktrack);
- buf.append(newline);
- buf.append("num decisions that potentially backtrack but don't ");
- buf.append(stats.numDecisionsThatPotentiallyBacktrack - stats.numDecisionsThatDoBacktrack);
- buf.append(newline);
- buf.append("average % of time a potentially backtracking decision backtracks ");
- buf.append(stats.averageDecisionPercentBacktracks);
- buf.append(newline);
- buf.append("num unique decisions covered ");
- buf.append(stats.numDecisionsCovered);
- buf.append(newline);
- buf.append("max rule invocation nesting depth ");
- buf.append(stats.maxRuleInvocationDepth);
- buf.append(newline);
-
-// buf.append("number of fixed lookahead decisions ");
-// buf.append();
-// buf.append('\n');
-// buf.append("min lookahead used in a fixed lookahead decision ");
-// buf.append();
-// buf.append('\n');
-// buf.append("max lookahead used in a fixed lookahead decision ");
-// buf.append();
-// buf.append('\n');
-// buf.append("average lookahead depth used in fixed lookahead decisions ");
-// buf.append();
-// buf.append('\n');
-// buf.append("standard deviation of depth used in fixed lookahead decisions ");
-// buf.append();
-// buf.append('\n');
-// buf.append("number of arbitrary lookahead decisions ");
-// buf.append();
-// buf.append('\n');
-// buf.append("min lookahead used in an arbitrary lookahead decision ");
-// buf.append();
-// buf.append('\n');
-// buf.append("max lookahead used in an arbitrary lookahead decision ");
-// buf.append();
-// buf.append('\n');
-// buf.append("average lookahead depth used in arbitrary lookahead decisions ");
-// buf.append();
-// buf.append('\n');
-// buf.append("standard deviation of depth used in arbitrary lookahead decisions ");
-// buf.append();
-// buf.append('\n');
-// buf.append("number of evaluated syntactic predicates ");
-// buf.append();
-// buf.append('\n');
-// buf.append("min lookahead used in a syntactic predicate ");
-// buf.append();
-// buf.append('\n');
-// buf.append("max lookahead used in a syntactic predicate ");
-// buf.append();
-// buf.append('\n');
-// buf.append("average lookahead depth used in syntactic predicates ");
-// buf.append();
-// buf.append('\n');
-// buf.append("standard deviation of depth used in syntactic predicates ");
-// buf.append();
-// buf.append('\n');
- buf.append("rule memoization cache size ");
- buf.append(stats.numMemoizationCacheEntries);
- buf.append(newline);
- buf.append("number of rule memoization cache hits ");
- buf.append(stats.numMemoizationCacheHits);
- buf.append(newline);
- buf.append("number of rule memoization cache misses ");
- buf.append(stats.numMemoizationCacheMisses);
- buf.append(newline);
-// buf.append("number of evaluated semantic predicates ");
-// buf.append();
-// buf.append(newline);
- buf.append("number of tokens ");
- buf.append(stats.numTokens);
- buf.append(newline);
- buf.append("number of hidden tokens ");
- buf.append(stats.numHiddenTokens);
- buf.append(newline);
- buf.append("number of char ");
- buf.append(stats.numCharsMatched);
- buf.append(newline);
- buf.append("number of hidden char ");
- buf.append(stats.numHiddenCharsMatched);
- buf.append(newline);
- buf.append("number of syntax errors ");
- buf.append(stats.numReportedErrors);
- buf.append(newline);
- return buf.toString();
- }
-
- public String getDecisionStatsDump() {
- StringBuilder buf = new StringBuilder();
- buf.append("location");
- buf.append(DATA_SEP);
- buf.append("n");
- buf.append(DATA_SEP);
- buf.append("avgk");
- buf.append(DATA_SEP);
- buf.append("maxk");
- buf.append(DATA_SEP);
- buf.append("synpred");
- buf.append(DATA_SEP);
- buf.append("sempred");
- buf.append(DATA_SEP);
- buf.append("canbacktrack");
- buf.append("\n");
- for (String fileName : decisions.keySet()) {
- for (int d : decisions.keySet(fileName)) {
- DecisionDescriptor s = decisions.get(fileName, d);
- buf.append(s.decision);
- buf.append("@");
- buf.append(locationDescription(s.fileName,s.ruleName,s.line,s.pos)); // decision number
- buf.append(DATA_SEP);
- buf.append(s.n);
- buf.append(DATA_SEP);
- buf.append(String.format("%.2f",s.avgk));
- buf.append(DATA_SEP);
- buf.append(s.maxk);
- buf.append(DATA_SEP);
- buf.append(s.numBacktrackOccurrences);
- buf.append(DATA_SEP);
- buf.append(s.numSemPredEvals);
- buf.append(DATA_SEP);
- buf.append(s.couldBacktrack ?"1":"0");
- buf.append(newline);
- }
- }
- return buf.toString();
- }
-
- protected int[] trim(int[] X, int n) {
- if ( n a) {
- int[] x = new int[a.size()];
- for (int i = 0; i < a.size(); i++) {
- Integer I = a.get(i);
- x[i] = I;
- }
- return x;
- }
-
- /** Get num hidden tokens between i..j inclusive */
- public int getNumberOfHiddenTokens(int i, int j) {
- int n = 0;
- TokenStream input = parser.getTokenStream();
- for (int ti = i; ti"+channelStr+","+line+":"+getCharPositionInLine()+",@"+index+"]";
- }
- }
-
- public static class ProxyTree extends BaseTree {
- public int ID;
- public int type;
- public int line = 0;
- public int charPos = -1;
- public int tokenIndex = -1;
- public String text;
-
- public ProxyTree(int ID, int type, int line, int charPos, int tokenIndex, String text) {
- this.ID = ID;
- this.type = type;
- this.line = line;
- this.charPos = charPos;
- this.tokenIndex = tokenIndex;
- this.text = text;
- }
-
- public ProxyTree(int ID) { this.ID = ID; }
-
- @Override public int getTokenStartIndex() { return tokenIndex; }
- @Override public void setTokenStartIndex(int index) { }
- @Override public int getTokenStopIndex() { return 0; }
- @Override public void setTokenStopIndex(int index) { }
- @Override public Tree dupNode() { return null; }
- @Override public int getType() { return type; }
- @Override public String getText() { return text; }
- @Override public String toString() {
- return "fix this";
- }
- }
-
- public RemoteDebugEventSocketListener(DebugEventListener listener,
- String machine,
- int port) throws IOException
- {
- this.listener = listener;
- this.machine = machine;
- this.port = port;
-
- if( !openConnection() ) {
- throw new ConnectException();
- }
- }
-
- protected void eventHandler() {
- try {
- handshake();
- event = in.readLine();
- while ( event!=null ) {
- dispatch(event);
- ack();
- event = in.readLine();
- }
- }
- catch (Exception e) {
- System.err.println(e);
- e.printStackTrace(System.err);
- }
- finally {
- closeConnection();
- }
- }
-
- protected boolean openConnection() {
- boolean success = false;
- try {
- channel = new Socket(machine, port);
- channel.setTcpNoDelay(true);
- OutputStream os = channel.getOutputStream();
- OutputStreamWriter osw = new OutputStreamWriter(os, "UTF8");
- out = new PrintWriter(new BufferedWriter(osw));
- InputStream is = channel.getInputStream();
- InputStreamReader isr = new InputStreamReader(is, "UTF8");
- in = new BufferedReader(isr);
- success = true;
- } catch(Exception e) {
- System.err.println(e);
- }
- return success;
- }
-
- protected void closeConnection() {
- try {
- in.close(); in = null;
- out.close(); out = null;
- channel.close(); channel=null;
- }
- catch (Exception e) {
- System.err.println(e);
- e.printStackTrace(System.err);
- }
- finally {
- if ( in!=null ) {
- try {in.close();} catch (IOException ioe) {
- System.err.println(ioe);
- }
- }
- if ( out!=null ) {
- out.close();
- }
- if ( channel!=null ) {
- try {channel.close();} catch (IOException ioe) {
- System.err.println(ioe);
- }
- }
- }
-
- }
-
- protected void handshake() throws IOException {
- String antlrLine = in.readLine();
- String[] antlrElements = getEventElements(antlrLine);
- version = antlrElements[1];
- String grammarLine = in.readLine();
- String[] grammarElements = getEventElements(grammarLine);
- grammarFileName = grammarElements[1];
- ack();
- listener.commence(); // inform listener after handshake
- }
-
- protected void ack() {
- out.println("ack");
- out.flush();
- }
-
- protected void dispatch(String line) {
- //System.out.println("event: "+line);
- String[] elements = getEventElements(line);
- if ( elements==null || elements[0]==null ) {
- System.err.println("unknown debug event: "+line);
- return;
- }
- if ( elements[0].equals("enterRule") ) {
- listener.enterRule(elements[1], elements[2]);
- }
- else if ( elements[0].equals("exitRule") ) {
- listener.exitRule(elements[1], elements[2]);
- }
- else if ( elements[0].equals("enterAlt") ) {
- listener.enterAlt(Integer.parseInt(elements[1]));
- }
- else if ( elements[0].equals("enterSubRule") ) {
- listener.enterSubRule(Integer.parseInt(elements[1]));
- }
- else if ( elements[0].equals("exitSubRule") ) {
- listener.exitSubRule(Integer.parseInt(elements[1]));
- }
- else if ( elements[0].equals("enterDecision") ) {
- listener.enterDecision(Integer.parseInt(elements[1]), elements[2].equals("true"));
- }
- else if ( elements[0].equals("exitDecision") ) {
- listener.exitDecision(Integer.parseInt(elements[1]));
- }
- else if ( elements[0].equals("location") ) {
- listener.location(Integer.parseInt(elements[1]),
- Integer.parseInt(elements[2]));
- }
- else if ( elements[0].equals("consumeToken") ) {
- ProxyToken t = deserializeToken(elements, 1);
- if ( t.getTokenIndex() == previousTokenIndex ) {
- tokenIndexesInvalid = true;
- }
- previousTokenIndex = t.getTokenIndex();
- listener.consumeToken(t);
- }
- else if ( elements[0].equals("consumeHiddenToken") ) {
- ProxyToken t = deserializeToken(elements, 1);
- if ( t.getTokenIndex() == previousTokenIndex ) {
- tokenIndexesInvalid = true;
- }
- previousTokenIndex = t.getTokenIndex();
- listener.consumeHiddenToken(t);
- }
- else if ( elements[0].equals("LT") ) {
- Token t = deserializeToken(elements, 2);
- listener.LT(Integer.parseInt(elements[1]), t);
- }
- else if ( elements[0].equals("mark") ) {
- listener.mark(Integer.parseInt(elements[1]));
- }
- else if ( elements[0].equals("rewind") ) {
- if ( elements[1]!=null ) {
- listener.rewind(Integer.parseInt(elements[1]));
- }
- else {
- listener.rewind();
- }
- }
- else if ( elements[0].equals("beginBacktrack") ) {
- listener.beginBacktrack(Integer.parseInt(elements[1]));
- }
- else if ( elements[0].equals("endBacktrack") ) {
- int level = Integer.parseInt(elements[1]);
- int successI = Integer.parseInt(elements[2]);
- listener.endBacktrack(level, successI==DebugEventListener.TRUE);
- }
- else if ( elements[0].equals("exception") ) {
- String excName = elements[1];
- String indexS = elements[2];
- String lineS = elements[3];
- String posS = elements[4];
- Class extends RecognitionException> excClass;
- try {
- excClass = Class.forName(excName).asSubclass(RecognitionException.class);
- RecognitionException e = excClass.newInstance();
- e.index = Integer.parseInt(indexS);
- e.line = Integer.parseInt(lineS);
- e.charPositionInLine = Integer.parseInt(posS);
- listener.recognitionException(e);
- }
- catch (ClassNotFoundException cnfe) {
- System.err.println("can't find class "+cnfe);
- cnfe.printStackTrace(System.err);
- }
- catch (InstantiationException ie) {
- System.err.println("can't instantiate class "+ie);
- ie.printStackTrace(System.err);
- }
- catch (IllegalAccessException iae) {
- System.err.println("can't access class "+iae);
- iae.printStackTrace(System.err);
- }
- }
- else if ( elements[0].equals("beginResync") ) {
- listener.beginResync();
- }
- else if ( elements[0].equals("endResync") ) {
- listener.endResync();
- }
- else if ( elements[0].equals("terminate") ) {
- listener.terminate();
- }
- else if ( elements[0].equals("semanticPredicate") ) {
- Boolean result = Boolean.valueOf(elements[1]);
- String predicateText = elements[2];
- predicateText = unEscapeNewlines(predicateText);
- listener.semanticPredicate(result,
- predicateText);
- }
- else if ( elements[0].equals("consumeNode") ) {
- ProxyTree node = deserializeNode(elements, 1);
- listener.consumeNode(node);
- }
- else if ( elements[0].equals("LN") ) {
- int i = Integer.parseInt(elements[1]);
- ProxyTree node = deserializeNode(elements, 2);
- listener.LT(i, node);
- }
- else if ( elements[0].equals("createNodeFromTokenElements") ) {
- int ID = Integer.parseInt(elements[1]);
- int type = Integer.parseInt(elements[2]);
- String text = elements[3];
- text = unEscapeNewlines(text);
- ProxyTree node = new ProxyTree(ID, type, -1, -1, -1, text);
- listener.createNode(node);
- }
- else if ( elements[0].equals("createNode") ) {
- int ID = Integer.parseInt(elements[1]);
- int tokenIndex = Integer.parseInt(elements[2]);
- // create dummy node/token filled with ID, tokenIndex
- ProxyTree node = new ProxyTree(ID);
- ProxyToken token = new ProxyToken(tokenIndex);
- listener.createNode(node, token);
- }
- else if ( elements[0].equals("nilNode") ) {
- int ID = Integer.parseInt(elements[1]);
- ProxyTree node = new ProxyTree(ID);
- listener.nilNode(node);
- }
- else if ( elements[0].equals("errorNode") ) {
- // TODO: do we need a special tree here?
- int ID = Integer.parseInt(elements[1]);
- int type = Integer.parseInt(elements[2]);
- String text = elements[3];
- text = unEscapeNewlines(text);
- ProxyTree node = new ProxyTree(ID, type, -1, -1, -1, text);
- listener.errorNode(node);
- }
- else if ( elements[0].equals("becomeRoot") ) {
- int newRootID = Integer.parseInt(elements[1]);
- int oldRootID = Integer.parseInt(elements[2]);
- ProxyTree newRoot = new ProxyTree(newRootID);
- ProxyTree oldRoot = new ProxyTree(oldRootID);
- listener.becomeRoot(newRoot, oldRoot);
- }
- else if ( elements[0].equals("addChild") ) {
- int rootID = Integer.parseInt(elements[1]);
- int childID = Integer.parseInt(elements[2]);
- ProxyTree root = new ProxyTree(rootID);
- ProxyTree child = new ProxyTree(childID);
- listener.addChild(root, child);
- }
- else if ( elements[0].equals("setTokenBoundaries") ) {
- int ID = Integer.parseInt(elements[1]);
- ProxyTree node = new ProxyTree(ID);
- listener.setTokenBoundaries(
- node,
- Integer.parseInt(elements[2]),
- Integer.parseInt(elements[3]));
- }
- else {
- System.err.println("unknown debug event: "+line);
- }
- }
-
- protected ProxyTree deserializeNode(String[] elements, int offset) {
- int ID = Integer.parseInt(elements[offset+0]);
- int type = Integer.parseInt(elements[offset+1]);
- int tokenLine = Integer.parseInt(elements[offset+2]);
- int charPositionInLine = Integer.parseInt(elements[offset+3]);
- int tokenIndex = Integer.parseInt(elements[offset+4]);
- String text = elements[offset+5];
- text = unEscapeNewlines(text);
- return new ProxyTree(ID, type, tokenLine, charPositionInLine, tokenIndex, text);
- }
-
- protected ProxyToken deserializeToken(String[] elements,
- int offset)
- {
- String indexS = elements[offset+0];
- String typeS = elements[offset+1];
- String channelS = elements[offset+2];
- String lineS = elements[offset+3];
- String posS = elements[offset+4];
- String text = elements[offset+5];
- text = unEscapeNewlines(text);
- int index = Integer.parseInt(indexS);
- ProxyToken t =
- new ProxyToken(index,
- Integer.parseInt(typeS),
- Integer.parseInt(channelS),
- Integer.parseInt(lineS),
- Integer.parseInt(posS),
- text);
- return t;
- }
-
- /** Create a thread to listen to the remote running recognizer */
- public void start() {
- Thread t = new Thread(this);
- t.start();
- }
-
- @Override
- public void run() {
- eventHandler();
- }
-
- // M i s c
-
- public String[] getEventElements(String event) {
- if ( event==null ) {
- return null;
- }
- String[] elements = new String[MAX_EVENT_ELEMENTS];
- String str = null; // a string element if present (must be last)
- try {
- int firstQuoteIndex = event.indexOf('"');
- if ( firstQuoteIndex>=0 ) {
- // treat specially; has a string argument like "a comment\n
- // Note that the string is terminated by \n not end quote.
- // Easier to parse that way.
- String eventWithoutString = event.substring(0,firstQuoteIndex);
- str = event.substring(firstQuoteIndex+1,event.length());
- event = eventWithoutString;
- }
- StringTokenizer st = new StringTokenizer(event, "\t", false);
- int i = 0;
- while ( st.hasMoreTokens() ) {
- if ( i>=MAX_EVENT_ELEMENTS ) {
- // ErrorManager.internalError("event has more than "+MAX_EVENT_ELEMENTS+" args: "+event);
- return elements;
- }
- elements[i] = st.nextToken();
- i++;
- }
- if ( str!=null ) {
- elements[i] = str;
- }
- }
- catch (Exception e) {
- e.printStackTrace(System.err);
- }
- return elements;
- }
-
- protected String unEscapeNewlines(String txt) {
- // this unescape is slow but easy to understand
- txt = txt.replaceAll("%0A","\n"); // unescape \n
- txt = txt.replaceAll("%0D","\r"); // unescape \r
- txt = txt.replaceAll("%25","%"); // undo escaped escape chars
- return txt;
- }
-
- public boolean tokenIndexesAreInvalid() {
- return false;
- //return tokenIndexesInvalid;
- }
-
-}
-
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/TraceDebugEventListener.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/TraceDebugEventListener.java
deleted file mode 100644
index e6ab849fd33..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/TraceDebugEventListener.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime.debug;
-
-import org.eclipse.persistence.internal.libraries.antlr.runtime.Token;
-import org.eclipse.persistence.internal.libraries.antlr.runtime.tree.TreeAdaptor;
-
-/** Print out (most of) the events... Useful for debugging, testing... */
-public class TraceDebugEventListener extends BlankDebugEventListener {
- TreeAdaptor adaptor;
-
- public TraceDebugEventListener(TreeAdaptor adaptor) {
- this.adaptor = adaptor;
- }
-
- public void enterRule(String ruleName) { System.out.println("enterRule "+ruleName); }
- public void exitRule(String ruleName) { System.out.println("exitRule "+ruleName); }
- @Override
- public void enterSubRule(int decisionNumber) { System.out.println("enterSubRule"); }
- @Override
- public void exitSubRule(int decisionNumber) { System.out.println("exitSubRule"); }
- @Override
- public void location(int line, int pos) {System.out.println("location "+line+":"+pos);}
-
- // Tree parsing stuff
-
- @Override
- public void consumeNode(Object t) {
- int ID = adaptor.getUniqueID(t);
- String text = adaptor.getText(t);
- int type = adaptor.getType(t);
- System.out.println("consumeNode "+ID+" "+text+" "+type);
- }
-
- @Override
- public void LT(int i, Object t) {
- int ID = adaptor.getUniqueID(t);
- String text = adaptor.getText(t);
- int type = adaptor.getType(t);
- System.out.println("LT "+i+" "+ID+" "+text+" "+type);
- }
-
-
- // AST stuff
- @Override
- public void nilNode(Object t) {System.out.println("nilNode "+adaptor.getUniqueID(t));}
-
- @Override
- public void createNode(Object t) {
- int ID = adaptor.getUniqueID(t);
- String text = adaptor.getText(t);
- int type = adaptor.getType(t);
- System.out.println("create "+ID+": "+text+", "+type);
- }
-
- @Override
- public void createNode(Object node, Token token) {
- int ID = adaptor.getUniqueID(node);
- String text = adaptor.getText(node);
- int tokenIndex = token.getTokenIndex();
- System.out.println("create "+ID+": "+tokenIndex);
- }
-
- @Override
- public void becomeRoot(Object newRoot, Object oldRoot) {
- System.out.println("becomeRoot "+adaptor.getUniqueID(newRoot)+", "+
- adaptor.getUniqueID(oldRoot));
- }
-
- @Override
- public void addChild(Object root, Object child) {
- System.out.println("addChild "+adaptor.getUniqueID(root)+", "+
- adaptor.getUniqueID(child));
- }
-
- @Override
- public void setTokenBoundaries(Object t, int tokenStartIndex, int tokenStopIndex) {
- System.out.println("setTokenBoundaries "+adaptor.getUniqueID(t)+", "+
- tokenStartIndex+", "+tokenStopIndex);
- }
-}
-
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/Tracer.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/Tracer.java
deleted file mode 100644
index 50ca644bff5..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/debug/Tracer.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- [The "BSD license"]
- Copyright (c) 2005-2009 Terence Parr
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.persistence.internal.libraries.antlr.runtime.debug;
-
-import org.eclipse.persistence.internal.libraries.antlr.runtime.IntStream;
-import org.eclipse.persistence.internal.libraries.antlr.runtime.TokenStream;
-
-/** The default tracer mimics the traceParser behavior of ANTLR 2.x.
- * This listens for debugging events from the parser and implies
- * that you cannot debug and trace at the same time.
- */
-public class Tracer extends BlankDebugEventListener {
- public IntStream input;
- protected int level = 0;
-
- public Tracer(IntStream input) {
- this.input = input;
- }
-
- public void enterRule(String ruleName) {
- for (int i=1; i<=level; i++) {System.out.print(" ");}
- System.out.println("> "+ruleName+" lookahead(1)="+getInputSymbol(1));
- level++;
- }
-
- public void exitRule(String ruleName) {
- level--;
- for (int i=1; i<=level; i++) {System.out.print(" ");}
- System.out.println("< "+ruleName+" lookahead(1)="+getInputSymbol(1));
- }
-
- public Object getInputSymbol(int k) {
- if ( input instanceof TokenStream ) {
- return ((TokenStream)input).LT(k);
- }
- return (char) input.LA(k);
- }
-}
-
-
diff --git a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/misc/DoubleKeyMap.java b/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/misc/DoubleKeyMap.java
deleted file mode 100644
index 8753bdc8239..00000000000
--- a/eclipseLink.backup/org.eclipse.persistence.antlr/src/org/eclipse/persistence/internal/libraries/antlr/runtime/misc/DoubleKeyMap.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.eclipse.persistence.internal.libraries.antlr.runtime.misc;
-
-import java.util.*;
-
-/** Sometimes we need to map a key to a value but key is two pieces of data.
- * This nested hash table saves creating a single key each time we access
- * map; avoids mem creation.
- */
-public class DoubleKeyMap {
- Map> data = new LinkedHashMap>();
-
- public Value put(Key1 k1, Key2 k2, Value v) {
- Map data2 = data.get(k1);
- Value prev = null;
- if ( data2==null ) {
- data2 = new LinkedHashMap();
- data.put(k1, data2);
- }
- else {
- prev = data2.get(k2);
- }
- data2.put(k2, v);
- return prev;
- }
-
- public Value get(Key1 k1, Key2 k2) {
- Map data2 = data.get(k1);
- if ( data2==null ) return null;
- return data2.get(k2);
- }
-
- public Map