1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Got rid of the old parser.

This commit is contained in:
Doug Schaefer 2003-09-10 14:26:08 +00:00
parent 492f586b96
commit 5a1119fd18
22 changed files with 10 additions and 14149 deletions

View file

@ -20,7 +20,6 @@ import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.INamespace; import org.eclipse.cdt.core.model.INamespace;
@ -77,8 +76,6 @@ public class CModelElementsFailedTests extends TestCase {
if (!fCProject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) { if (!fCProject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
addNatureToProject(fCProject.getProject(), CCProjectNature.CC_NATURE_ID, null); addNatureToProject(fCProject.getProject(), CCProjectNature.CC_NATURE_ID, null);
} }
CCorePlugin.getDefault().setUseNewParser(true);
} }
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException { private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {

View file

@ -78,9 +78,7 @@ public class CompletionProposalsTest extends TestCase{
addNatureToProject(fCProject.getProject(), CCProjectNature.CC_NATURE_ID, null); addNatureToProject(fCProject.getProject(), CCProjectNature.CC_NATURE_ID, null);
} }
CCorePlugin.getDefault().setUseNewParser(true);
// use the new indexer // use the new indexer
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager(); IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
indexManager.setEnabled(fCProject.getProject(),true); indexManager.setEnabled(fCProject.getProject(),true);

View file

@ -19,7 +19,6 @@ import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IEnumeration; import org.eclipse.cdt.core.model.IEnumeration;
@ -85,8 +84,6 @@ public class CModelElementsTests extends TestCase {
if (!fCProject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) { if (!fCProject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
addNatureToProject(fCProject.getProject(), CCProjectNature.CC_NATURE_ID, null); addNatureToProject(fCProject.getProject(), CCProjectNature.CC_NATURE_ID, null);
} }
CCorePlugin.getDefault().setUseNewParser(true);
} }
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException { private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {

View file

@ -21,7 +21,6 @@ import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ElementChangedEvent; import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.IBuffer; import org.eclipse.cdt.core.model.IBuffer;
@ -93,8 +92,8 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
addedElements = new Vector(10); addedElements = new Vector(10);
removedElements = new Vector(10); removedElements = new Vector(10);
changedElements = new Vector(20); changedElements = new Vector(20);
CCorePlugin.getDefault().setUseNewParser(true);
} }
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException { private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = proj.getDescription(); IProjectDescription description = proj.getDescription();
String[] prevNatures= description.getNatureIds(); String[] prevNatures= description.getNatureIds();

View file

@ -4,14 +4,16 @@
*/ */
package org.eclipse.cdt.core.model.tests; package org.eclipse.cdt.core.model.tests;
import junit.framework.TestCase;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.testplugin.CProjectHelper; import junit.framework.TestCase;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.internal.resources.ResourceException; import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -20,9 +22,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.core.model.TranslationUnit;
/** /**
* @author bnicolle * @author bnicolle
@ -78,8 +77,6 @@ public abstract class IntegratedCModelTest extends TestCase {
if (!fCProject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) { if (!fCProject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
addNatureToProject(fCProject.getProject(), CCProjectNature.CC_NATURE_ID, null); addNatureToProject(fCProject.getProject(), CCProjectNature.CC_NATURE_ID, null);
} }
CCorePlugin.getDefault().setUseNewParser(true);
} }
protected void tearDown() { protected void tearDown() {

View file

@ -18,7 +18,6 @@ import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.IBuffer; import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
@ -77,9 +76,8 @@ public class WorkingCopyTests extends TestCase {
if (!fCProject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) { if (!fCProject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
addNatureToProject(fCProject.getProject(), CCProjectNature.CC_NATURE_ID, null); addNatureToProject(fCProject.getProject(), CCProjectNature.CC_NATURE_ID, null);
} }
CCorePlugin.getDefault().setUseNewParser(true);
} }
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException { private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = proj.getDescription(); IProjectDescription description = proj.getDescription();
String[] prevNatures= description.getNatureIds(); String[] prevNatures= description.getNatureIds();

View file

@ -1,183 +0,0 @@
package org.eclipse.cdt.internal.core.model;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.internal.parser.IStructurizerCallback;
public class ModelBuilder implements IStructurizerCallback {
private TranslationUnit fCurrFile;
private CElement fCurrElement;
public ModelBuilder(TranslationUnit file) {
fCurrFile = file;
fCurrElement = file;
}
private final int fixLength(int startPos, int endPos) {
if (endPos < startPos) {
return 0;
} else {
return endPos - startPos + 1;
}
}
public void includeDecl(String name, int startPos, int endPos, int startLine, int endLine) {
Include elem= new Include(fCurrFile, name, true ); // assume standard inclusion
elem.setPos(startPos, fixLength(startPos, endPos));
elem.setIdPos(startPos, fixLength(startPos, endPos));
elem.setLines(startLine, endLine);
fCurrFile.addChild(elem);
}
public void defineDecl(String name, int startPos, int endPos, int startLine, int endLine) {
Macro elem= new Macro(fCurrFile, name);
elem.setPos(startPos, fixLength(startPos, endPos));
elem.setIdPos(startPos, fixLength(startPos, endPos));
elem.setLines(startLine, endLine);
fCurrFile.addChild(elem);
}
public void functionDeclBegin(String name, int nameStartPos, int nameEndPos,
int declStartPos, int startPos, int type, int modifiers) {
//if (!assertCurrElement( new int[] { CElement.C_FILE, CElement.C_STRUCTURE, CElement.C_UNION, CElement.C_CLASS})) {
// return;
//}
CElement elem;
if (fCurrElement instanceof IStructure) {
elem = new Method(fCurrElement, name);
} else {
if(type == ICElement.C_FUNCTION_DECLARATION) {
elem = new FunctionDeclaration(fCurrElement, name);
} else {
elem= new Function(fCurrElement, name);
}
}
elem.setPos(declStartPos, 0);
elem.setIdPos(nameStartPos, fixLength(nameStartPos, nameEndPos));
elem.setLines(startPos, -1);
fCurrElement.addChild(elem);
fCurrElement= elem;
}
public void functionDeclEnd(int declEndPos, int endLine, boolean prototype) {
//if (!assertCurrElement( new int[] { CElement.C_FUNCTION })) {
// return;
//}
if(prototype == true && fCurrElement.getParent() instanceof Parent) {
// Need to delete the current function and create a new object
CElement elem, oldElem = fCurrElement;
elem = new FunctionDeclaration(fCurrElement.getParent(), fCurrElement.getElementName());
elem.setPos(oldElem.getStartPos(), 0);
elem.setIdPos(oldElem.getIdStartPos(), oldElem.getIdLength());
elem.setLines(oldElem.getStartLine(), -1);
((Parent)fCurrElement.getParent()).addChild(elem);
((Parent)fCurrElement.getParent()).removeChild(oldElem);
fCurrElement = elem;
}
int declStartPos= fCurrElement.getStartPos();
fCurrElement.setPos(declStartPos, fixLength(declStartPos, declEndPos));
int startLine = fCurrElement.getStartLine();
fCurrElement.setLines(startLine, endLine);
fCurrElement= (CElement)fCurrElement.getParent();
}
public void fieldDecl(String name, int nameStartPos, int nameEndPos, int declStartPos,
int declEndPos, int startLine, int endLine, int modifiers) {
CElement elem;
if (fCurrElement instanceof IStructure) {
elem = new Field(fCurrElement, name);
} else {
elem = new Variable(fCurrElement, name);
}
//System.out.println(elem.toDebugString() + " --> " + fCurrElement.toDebugString());
elem.setPos(declStartPos, fixLength(declStartPos, declEndPos));
elem.setIdPos(nameStartPos, fixLength(nameStartPos, nameEndPos));
elem.setLines(startLine, endLine);
fCurrElement.addChild(elem);
}
public void structDeclBegin(String name, int kind, int nameStartPos, int nameEndPos,
int declStartPos, int startLine, int modifiers) {
//if (!assertCurrElement( new int[] { CElement.C_FILE, CElement.C_STRUCTURE, CElement.C_UNION, CElement.C_CLASS })) {
// return;
//}
if(isAnonymousStructure(name)) {
name = new String("[anonymous]");
}
Structure elem= new Structure(fCurrElement, kind, name);
elem.setPos(declStartPos, 0);
elem.setIdPos(nameStartPos, fixLength(nameStartPos, nameEndPos));
elem.setLines(startLine, -1);
fCurrElement.addChild(elem);
fCurrElement= elem;
//System.out.println(elem.toDebugString() + " --> " + fCurrElement.toDebugString());
}
public void structDeclEnd(int declEndPos, int endLine) {
//assertCurrElement( new int[] { CElement.C_STRUCTURE, CElement.C_UNION, CElement.C_CLASS });
int declStartPos= fCurrElement.getStartPos();
fCurrElement.setPos(declStartPos, fixLength(declStartPos, declEndPos));
int startLine= fCurrElement.getStartLine();
fCurrElement.setLines(startLine, endLine);
fCurrElement= (CElement)fCurrElement.getParent();
}
public void superDecl(String name) {
//assertCurrElement( new int[] { CElement.C_STRUCTURE, CElement.C_UNION, CElement.C_CLASS });
if (fCurrElement instanceof IStructure) {
((Structure)fCurrElement).addSuperClass(name);
}
}
public void reportError(Throwable throwable) {
// System.out.println("ModelBuilder: error " + throwable.getMessage());
}
private boolean assertCurrElement(int[] acceptedTypes) {
boolean isOk= false;
int currType= fCurrElement.getElementType();
for (int i= 0; i < acceptedTypes.length; i++) {
if (currType == acceptedTypes[i]) {
isOk= true;
}
}
if (!isOk) {
StringBuffer buf= new StringBuffer();
buf.append("ModelBuilder: type check failed, is: ");
buf.append(CElement.getTypeString(currType));
buf.append(", should be [ ");
for (int i= 0; i < acceptedTypes.length; i++) {
buf.append(CElement.getTypeString(acceptedTypes[i]));
buf.append(" ");
}
buf.append("]");
//CPlugin.getPlugin().logErrorStatus(buf.toString(), null);
}
return isOk;
}
private boolean isAnonymousStructure(String name) {
if (Character.isJavaIdentifierStart(name.charAt(0))) {
return false;
} else {
return true;
}
}
}

View file

@ -12,7 +12,6 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IBuffer; import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
@ -22,7 +21,6 @@ import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IUsing; import org.eclipse.cdt.core.model.IUsing;
import org.eclipse.cdt.internal.parser.CStructurizer;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -206,20 +204,13 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} }
return sourceManipulationInfo; return sourceManipulationInfo;
} }
protected Map parse(InputStream in) { protected Map parse(InputStream in) {
try { try {
removeChildren(); removeChildren();
if (CCorePlugin.getDefault().useNewParser()) {
// new parser
CModelBuilder modelBuilder = new CModelBuilder(this);
return (modelBuilder.parse());
} else { CModelBuilder modelBuilder = new CModelBuilder(this);
// cdt 1.0 parser return modelBuilder.parse();
ModelBuilder modelBuilder= new ModelBuilder(this);
CStructurizer.getCStructurizer().parse(modelBuilder, in);
return null;
}
} catch (Exception e) { } catch (Exception e) {
System.out.println(e); System.out.println(e);
return null; return null;

View file

@ -68,8 +68,6 @@ public class CCorePlugin extends Plugin {
public final static String DEFAULT_BINARY_PARSER_SIMPLE_ID = "ELF"; public final static String DEFAULT_BINARY_PARSER_SIMPLE_ID = "ELF";
public final static String DEFAULT_BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_BINARY_PARSER_SIMPLE_ID; public final static String DEFAULT_BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_BINARY_PARSER_SIMPLE_ID;
public final static String PREF_USE_NEW_PARSER = "useNewParser";
public final static String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$ public final static String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$
// Build Model Interface Discovery // Build Model Interface Discovery
@ -244,9 +242,6 @@ public class CCorePlugin extends Plugin {
fDescriptorManager = new CDescriptorManager(); fDescriptorManager = new CDescriptorManager();
fDescriptorManager.startup(); fDescriptorManager.startup();
// Set the default for using the new parser
getPluginPreferences().setDefault(PREF_USE_NEW_PARSER, true);
} }
@ -772,16 +767,6 @@ public class CCorePlugin extends Plugin {
return provider; return provider;
} }
// Preference to turn on/off the new parser
public void setUseNewParser(boolean useNewParser) {
getPluginPreferences().setValue(PREF_USE_NEW_PARSER, useNewParser);
savePluginPreferences();
}
public boolean useNewParser() {
return getPluginPreferences().getBoolean(PREF_USE_NEW_PARSER);
}
/** /**
* @param path * @param path
* @return * @return

View file

@ -1,414 +0,0 @@
/* Generated By:JavaCC: Do not edit this line. ASCII_CharStream.java Version 0.7pre6 */
package org.eclipse.cdt.internal.parser;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/* fixed ASCII_CharStream: tab is counting only one character for column */
/**
* An implementation of interface CharStream, where the stream is assumed to
* contain only ASCII characters (without unicode processing).
*/
public final class ASCII_CharStream {
public static final boolean staticFlag= true;
static int bufsize;
static int available;
static int tokenBegin;
static public int bufpos= -1;
static private int bufline[];
static private int bufcolumn[];
static private int column= 0;
static private int line= 1;
static private boolean prevCharIsCR= false;
static private boolean prevCharIsLF= false;
static private java.io.Reader inputStream;
static private char[] buffer;
static private int maxNextCharInd= 0;
static private int inBuf= 0;
static private final void ExpandBuff(boolean wrapAround) {
char[] newbuffer= new char[bufsize + 2048];
int newbufline[]= new int[bufsize + 2048];
int newbufcolumn[]= new int[bufsize + 2048];
try {
if (wrapAround) {
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
buffer= newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
bufline= newbufline;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
bufcolumn= newbufcolumn;
maxNextCharInd= (bufpos += (bufsize - tokenBegin));
} else {
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
buffer= newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
bufline= newbufline;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
bufcolumn= newbufcolumn;
maxNextCharInd= (bufpos -= tokenBegin);
}
} catch (Throwable t) {
throw new Error(t.getMessage());
}
bufsize += 2048;
available= bufsize;
tokenBegin= 0;
}
static private final void FillBuff() throws java.io.IOException {
if (maxNextCharInd == available) {
if (available == bufsize) {
if (tokenBegin > 2048) {
bufpos= maxNextCharInd= 0;
available= tokenBegin;
} else
if (tokenBegin < 0)
bufpos= maxNextCharInd= 0;
else
ExpandBuff(false);
} else
if (available > tokenBegin)
available= bufsize;
else
if ((tokenBegin - available) < 2048)
ExpandBuff(true);
else
available= tokenBegin;
}
int i;
try {
if ((i= inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) {
inputStream.close();
throw new java.io.IOException();
} else {
maxNextCharInd += i;
}
return;
} catch (java.io.IOException e) {
--bufpos;
backup(0);
if (tokenBegin == -1)
tokenBegin= bufpos;
throw e;
}
}
static public final char BeginToken() throws java.io.IOException {
tokenBegin= -1;
char c= readChar();
tokenBegin= bufpos;
return c;
}
static private final void UpdateLineColumn(char c) {
column++;
if (prevCharIsLF) {
prevCharIsLF= false;
line += (column= 1);
} else
if (prevCharIsCR) {
prevCharIsCR= false;
if (c == '\n') {
prevCharIsLF= true;
} else
line += (column= 1);
}
switch (c) {
case '\r' :
prevCharIsCR= true;
break;
case '\n' :
prevCharIsLF= true;
break;
default :
break;
}
bufline[bufpos]= line;
bufcolumn[bufpos]= column;
}
static public final char readChar() throws java.io.IOException {
if (inBuf > 0) {
--inBuf;
return (char) ((char) 0xff & buffer[(bufpos == bufsize - 1) ? (bufpos= 0) : ++bufpos]);
}
if (++bufpos >= maxNextCharInd) {
FillBuff();
}
char c= (char) ((char) 0xff & buffer[bufpos]);
// Remove '\' line continuations
if(c == '\\') {
int pos = bufpos+1;
if((bufpos+1) >= maxNextCharInd) {
// Safe to do so here, we already have the character
FillBuff();
pos = bufpos;
}
char n = (char) ((char) 0xff & buffer[pos]);
if((n == '\n') || (n == '\r')) {
UpdateLineColumn(n);
// We eat the \\\n combo.
bufpos++;
if(n == '\r') {
while((c = readChar()) == '\n');
}
} else {
UpdateLineColumn(c);
}
} else {
UpdateLineColumn(c);
}
return (c);
}
/**
* @deprecated
* @see #getEndColumn
*/
static public final int getColumn() {
return bufcolumn[bufpos];
}
/**
* @deprecated
* @see #getEndLine
*/
static public final int getLine() {
return bufline[bufpos];
}
static public final int getEndColumn() {
return bufcolumn[bufpos];
}
static public final int getEndLine() {
return bufline[bufpos];
}
static public final int getBeginColumn() {
return bufcolumn[tokenBegin];
}
static public final int getBeginLine() {
return bufline[tokenBegin];
}
static public final void backup(int amount) {
inBuf += amount;
if ((bufpos -= amount) < 0)
bufpos += bufsize;
}
public ASCII_CharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) {
if (inputStream != null)
throw new Error(
"\n ERROR: Second call to the constructor of a static ASCII_CharStream. You must\n"
+ " either use ReInit() or set the JavaCC option STATIC to false\n"
+ " during the generation of this class.");
inputStream= dstream;
line= startline;
column= startcolumn - 1;
available= bufsize= buffersize;
buffer= new char[buffersize];
bufline= new int[buffersize];
bufcolumn= new int[buffersize];
}
public ASCII_CharStream(java.io.Reader dstream, int startline, int startcolumn) {
this(dstream, startline, startcolumn, 4096);
}
static public void ReInit(java.io.Reader dstream, int startline, int startcolumn, int buffersize) {
inputStream= dstream;
line= startline;
column= startcolumn - 1;
if (buffer == null || buffersize != buffer.length) {
available= bufsize= buffersize;
buffer= new char[buffersize];
bufline= new int[buffersize];
bufcolumn= new int[buffersize];
}
prevCharIsLF= prevCharIsCR= false;
tokenBegin= inBuf= maxNextCharInd= 0;
bufpos= -1;
}
static public void ReInit(java.io.Reader dstream, int startline, int startcolumn) {
ReInit(dstream, startline, startcolumn, 4096);
}
public ASCII_CharStream(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) {
this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
public ASCII_CharStream(java.io.InputStream dstream, int startline, int startcolumn) {
this(dstream, startline, startcolumn, 4096);
}
static public void ReInit(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) {
ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
static public void ReInit(java.io.InputStream dstream, int startline, int startcolumn) {
ReInit(dstream, startline, startcolumn, 4096);
}
static public final String GetImage() {
if (bufpos >= tokenBegin)
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
else
return new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1);
}
static public final char[] GetSuffix(int len) {
char[] ret= new char[len];
if ((bufpos + 1) >= len)
System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
else {
System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1);
System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
}
return ret;
}
static public void Done() {
buffer= null;
bufline= null;
bufcolumn= null;
}
/**
* Method to adjust line and column numbers for the start of a token.<BR>
*/
static public void adjustBeginLineColumn(int newLine, int newCol) {
int start= tokenBegin;
int len;
if (bufpos >= tokenBegin) {
len= bufpos - tokenBegin + inBuf + 1;
} else {
len= bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i= 0, j= 0, k= 0;
int nextColDiff= 0, columnDiff= 0;
while (i < len && bufline[j= start % bufsize] == bufline[k= ++start % bufsize]) {
bufline[j]= newLine;
nextColDiff= columnDiff + bufcolumn[k] - bufcolumn[j];
bufcolumn[j]= newCol + columnDiff;
columnDiff= nextColDiff;
i++;
}
if (i < len) {
bufline[j]= newLine++;
bufcolumn[j]= newCol + columnDiff;
while (i++ < len) {
if (bufline[j= start % bufsize] != bufline[++start % bufsize])
bufline[j]= newLine++;
else
bufline[j]= newLine;
}
}
line= bufline[j];
column= bufcolumn[j];
}
}

View file

@ -1,46 +0,0 @@
package org.eclipse.cdt.internal.parser;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.cdt.internal.parser.generated.CPPParser;
import org.eclipse.cdt.internal.parser.generated.ParseException;
import org.eclipse.cdt.internal.parser.generated.TokenMgrError;
public class CStructurizer {
private static CStructurizer fgStructurizerSingelton= new CStructurizer();
public static CStructurizer getCStructurizer() {
return fgStructurizerSingelton;
}
private CPPParser fParser;
private CStructurizer() {
}
public synchronized void parse(IStructurizerCallback callback, InputStream inputStream) throws IOException {
LinePositionInputStream lpiStream= new LinePositionInputStream(inputStream);
try {
ParserCallback cb= new ParserCallback(lpiStream, callback);
if (fParser == null) {
fParser= new CPPParser(lpiStream);
} else {
fParser.ReInit(lpiStream);
}
fParser.setParserCallback(cb);
fParser.translation_unit();
} catch (TokenMgrError error) {
callback.reportError(error);
} catch (ParseException e) {
callback.reportError(e);
}
}
}

View file

@ -1,26 +0,0 @@
package org.eclipse.cdt.internal.parser;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
public interface IStructurizerCallback {
void includeDecl(String name, int startPos, int endPos, int startLine, int endLine);
void defineDecl(String name, int startPos, int endPos, int startLine, int endLine);
void functionDeclBegin(String name, int nameStartPos, int nameEndPos, int declStartPos, int startLine, int kind, int modifiers);
void functionDeclEnd(int declEndPos, int endLine, boolean prototype);
void fieldDecl(String name, int nameStartPos, int nameEndPos, int declStartPos, int declEndPos, int startLine, int endLine, int modifiers);
void structDeclBegin(String name, int kind, int nameStartPos, int nameEndPos, int declStartPos, int startLine, int modifiers);
void structDeclEnd(int declEndPos, int endLine);
void superDecl(String name);
void reportError(Throwable throwable);
}

View file

@ -1,68 +0,0 @@
package org.eclipse.cdt.internal.parser;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* An input stream that only observes the stream and remembers the position of new
* lines
*/
public class LinePositionInputStream extends InputStream {
private List fLinePositions;
private BufferedInputStream buffered;
private boolean fRRead;
private boolean fAddLine;
private int fCurrPosition;
public LinePositionInputStream(InputStream inputStream) throws IOException {
buffered = new BufferedInputStream(inputStream);
fLinePositions= new ArrayList(30);
fAddLine= true;
fRRead= false;
fCurrPosition= 0;
}
public int read() throws IOException {
int ch = buffered.read();
if (fRRead && ch == '\n') {
fRRead= false;
} else {
if (fAddLine) {
fLinePositions.add(new Integer(fCurrPosition));
fAddLine= false;
}
if (ch == '\n' || ch == '\r') {
fAddLine= true;
fRRead= (ch == '\r');
} else {
fRRead= false;
}
}
fCurrPosition++;
return ch;
}
public int getPosition(int line, int col) {
line--;
col--;
if (line < fLinePositions.size()) {
Integer lineStart= (Integer)fLinePositions.get(line);
return lineStart.intValue() + col;
}
return -1;
}
}

View file

@ -1,135 +0,0 @@
package org.eclipse.cdt.internal.parser;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.parser.generated.Token;
public final class ParserCallback {
public final static int K_CLASS= ICElement.C_CLASS;
public final static int K_STRUCT= ICElement.C_STRUCT;
public final static int K_UNION= ICElement.C_UNION;
public final static int K_FUNCTION= ICElement.C_FUNCTION;
public final static int K_DECL= ICElement.C_FUNCTION_DECLARATION;
public final static int K_CTOR= ICElement.C_CLASS_CTOR;
public final static int K_DTOR= ICElement.C_CLASS_DTOR;
public final static int K_STATIC= ICElement.C_STORAGE_STATIC;
public final static int K_EXTERN= ICElement.C_STORAGE_EXTERN;
private LinePositionInputStream fLinePositions;
private IStructurizerCallback fCallback;
private int fStorage;
public ParserCallback(LinePositionInputStream lpiStream, IStructurizerCallback callback) {
fLinePositions= lpiStream;
fCallback= callback;
}
public void functionDeclBegin(Token nameToken, Token firstToken, int kind) {
int declStart= fLinePositions.getPosition(firstToken.beginLine, firstToken.beginColumn);
int nameStart= fLinePositions.getPosition(nameToken.beginLine, nameToken.beginColumn);
int nameEnd= fLinePositions.getPosition(nameToken.endLine, nameToken.endColumn);
fCallback.functionDeclBegin(nameToken.image, nameStart, nameEnd, declStart,
firstToken.beginLine, kind, fStorage);
fStorage = 0;
}
public void functionDeclEnd(Token lastToken) {
int declEnd= fLinePositions.getPosition(lastToken.endLine, lastToken.endColumn);
boolean prototype = ";".equals(lastToken.image);
fCallback.functionDeclEnd(declEnd, lastToken.endLine, prototype);
}
public void structDeclBegin(Token nameToken, int kind, Token firstToken) {
int declStart= fLinePositions.getPosition(firstToken.beginLine, firstToken.beginColumn);
int nameStart= fLinePositions.getPosition(nameToken.beginLine, nameToken.beginColumn);
int nameEnd= fLinePositions.getPosition(nameToken.endLine, nameToken.endColumn);
fCallback.structDeclBegin(nameToken.image, kind, nameStart, nameEnd, declStart, firstToken.beginLine, fStorage);
fStorage = 0;
}
public void structDeclEnd(Token lastToken) {
int declEnd= fLinePositions.getPosition(lastToken.endLine, lastToken.endColumn);
fCallback.structDeclEnd(declEnd, lastToken.endLine);
}
public void fieldDecl(Token nameToken, Token firstToken, Token lastToken) {
int declStart= fLinePositions.getPosition(firstToken.beginLine, firstToken.beginColumn);
int declEnd= fLinePositions.getPosition(lastToken.endLine, lastToken.endColumn);
int nameStart= fLinePositions.getPosition(nameToken.beginLine, nameToken.beginColumn);
int nameEnd= fLinePositions.getPosition(nameToken.endLine, nameToken.endColumn);
fCallback.fieldDecl(nameToken.image, nameStart, nameEnd, declStart, declEnd,
firstToken.beginLine, lastToken.endLine, fStorage);
fStorage = 0;
}
public void superDecl(String name) {
fCallback.superDecl(name);
}
public void includeDecl(String name, int line, int column) {
int start= fLinePositions.getPosition(line, column);
int end= fLinePositions.getPosition(line, column + name.length()) - 1;
fCallback.includeDecl(name, start, end, line, line);
}
public void defineDecl(String name, int line, int column) {
int start= fLinePositions.getPosition(line, column);
int end= fLinePositions.getPosition(line, column + name.length()) - 1;
fCallback.defineDecl(name, start, end, line, line);
}
public void storageSpecifier(int kind) {
fStorage |= kind;
}
public boolean isStorageClassSpecifier(Token token) {
String str= token.image;
if (str != null) {
if ("JNIEXPORT".equals(str)) {
return true;
}
if (str.startsWith("__declspec")) {
return true;
}
if ("JNICALL".equals(str)) {
return true;
}
}
return false;
}
public boolean overreadBlocks() {
return true;
}
// ---- util functions -----
public static Token createToken(String name, Token positions) {
Token res= new Token();
res.image= name;
res.beginColumn= positions.beginColumn;
res.beginLine= positions.beginLine;
res.endColumn= positions.endColumn;
res.endLine= positions.endLine;
return res;
}
public static Token createToken(String name, Token positionBegin, Token positionEnd) {
Token res= new Token();
res.image= name;
res.beginColumn= positionBegin.beginColumn;
res.beginLine= positionBegin.beginLine;
res.endColumn= positionEnd.endColumn;
res.endLine= positionEnd.endLine;
return res;
}
}

View file

@ -1,39 +0,0 @@
package org.eclipse.cdt.internal.parser;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
/**
* generates the parser from the CPLUSPLUS.jj file. after running, import the sources
* from the given temporary output directory
* needs javacc in the class path (www.metamata.com)
* version used for this release 1.2
*/
public class RunParserGenerator {
private static final String tempOutputDir="c:\\temp\\jccout";
public static void main(String[] args) {
/* URL url= (new RunParserGenerator()).getClass().getResource("/com/ibm/cdt/parser/generated/CPLUSPLUS.jj");
File file= new File(url.getFile());
String[] arguments= new String[] {
"-OUTPUT_DIRECTORY=" + tempOutputDir,
file.getPath()
};
try {
System.out.println("start javacc...");
COM.sun.labs.javacc.Main.main(arguments);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("javacc finished..."); */
}
}

View file

@ -1,283 +0,0 @@
/* Generated By:JavaCC: Do not edit this line. CPPParserConstants.java */
package org.eclipse.cdt.internal.parser.generated;
public interface CPPParserConstants {
int EOF = 0;
int LCURLYBRACE = 28;
int RCURLYBRACE = 29;
int LSQUAREBRACKET = 30;
int RSQUAREBRACKET = 31;
int LPARENTHESIS = 32;
int RPARENTHESIS = 33;
int SCOPE = 34;
int COLON = 35;
int SEMICOLON = 36;
int COMMA = 37;
int QUESTIONMARK = 38;
int ELLIPSIS = 39;
int ASSIGNEQUAL = 40;
int TIMESEQUAL = 41;
int DIVIDEEQUAL = 42;
int MODEQUAL = 43;
int PLUSEQUAL = 44;
int MINUSEQUAL = 45;
int SHIFTLEFTEQUAL = 46;
int SHIFTRIGHTEQUAL = 47;
int BITWISEANDEQUAL = 48;
int BITWISEXOREQUAL = 49;
int BITWISEOREQUAL = 50;
int OR = 51;
int AND = 52;
int BITWISEOR = 53;
int BITWISEXOR = 54;
int AMPERSAND = 55;
int EQUAL = 56;
int NOTEQUAL = 57;
int LESSTHAN = 58;
int GREATERTHAN = 59;
int LESSTHANOREQUALTO = 60;
int GREATERTHANOREQUALTO = 61;
int SHIFTLEFT = 62;
int SHIFTRIGHT = 63;
int PLUS = 64;
int MINUS = 65;
int STAR = 66;
int DIVIDE = 67;
int MOD = 68;
int PLUSPLUS = 69;
int MINUSMINUS = 70;
int TILDE = 71;
int NOT = 72;
int DOT = 73;
int POINTERTO = 74;
int DOTSTAR = 75;
int ARROWSTAR = 76;
int AUTO = 77;
int BREAK = 78;
int CASE = 79;
int CATCH = 80;
int CHAR = 81;
int CONST = 82;
int CONTINUE = 83;
int _DEFAULT = 84;
int DELETE = 85;
int DO = 86;
int DOUBLE = 87;
int ELSE = 88;
int ENUM = 89;
int EXTERN = 90;
int FINALLY = 91;
int FLOAT = 92;
int FOR = 93;
int FRIEND = 94;
int GOTO = 95;
int IF = 96;
int INLINE = 97;
int INT = 98;
int LONG = 99;
int NEW = 100;
int PRIVATE = 101;
int PROTECTED = 102;
int PUBLIC = 103;
int REDECLARED = 104;
int REGISTER = 105;
int RETURN = 106;
int SHORT = 107;
int SIGNED = 108;
int SIZEOF = 109;
int STATIC = 110;
int STRUCT = 111;
int CLASS = 112;
int SWITCH = 113;
int TEMPLATE = 114;
int THIS = 115;
int TRY = 116;
int TYPEDEF = 117;
int UNION = 118;
int UNSIGNED = 119;
int VIRTUAL = 120;
int VOID = 121;
int VOLATILE = 122;
int WHILE = 123;
int OPERATOR = 124;
int TRUETOK = 125;
int FALSETOK = 126;
int THROW = 127;
int OCTALINT = 128;
int OCTALLONG = 129;
int UNSIGNED_OCTALINT = 130;
int UNSIGNED_OCTALLONG = 131;
int DECIMALINT = 132;
int DECIMALLONG = 133;
int UNSIGNED_DECIMALINT = 134;
int UNSIGNED_DECIMALLONG = 135;
int HEXADECIMALINT = 136;
int HEXADECIMALLONG = 137;
int UNSIGNED_HEXADECIMALINT = 138;
int UNSIGNED_HEXADECIMALLONG = 139;
int FLOATONE = 140;
int FLOATTWO = 141;
int CHARACTER = 142;
int STRING = 143;
int ID = 144;
int DEFAULT = 0;
int DEFINE_STMT = 1;
int INCLUDE_STMT = 2;
int LINE_NUMBER = 3;
int LINE_DIRECTIVE = 4;
int AFTER_LINE_DIRECTIVE = 5;
int IN_LINE_COMMENT = 6;
int IN_COMMENT = 7;
int PREPROCESSOR_OUTPUT = 8;
String[] tokenImage = {
"<EOF>",
"\" \"",
"\"\\t\"",
"\"\\n\"",
"\"\\r\"",
"\"//\"",
"\"/*\"",
"<token of kind 7>",
"<token of kind 8>",
"<token of kind 9>",
"<token of kind 10>",
"\"#\"",
"<token of kind 12>",
"<token of kind 13>",
"<token of kind 14>",
"<token of kind 15>",
"<token of kind 16>",
"<token of kind 17>",
"<token of kind 18>",
"<token of kind 19>",
"<token of kind 20>",
"<token of kind 21>",
"<token of kind 22>",
"<token of kind 23>",
"\"*/\"",
"<token of kind 25>",
"<token of kind 26>",
"<token of kind 27>",
"\"{\"",
"\"}\"",
"\"[\"",
"\"]\"",
"\"(\"",
"\")\"",
"\"::\"",
"\":\"",
"\";\"",
"\",\"",
"\"?\"",
"\"...\"",
"\"=\"",
"\"*=\"",
"\"/=\"",
"\"%=\"",
"\"+=\"",
"\"-=\"",
"\"<<=\"",
"\">>=\"",
"\"&=\"",
"\"^=\"",
"\"|=\"",
"\"||\"",
"\"&&\"",
"\"|\"",
"\"^\"",
"\"&\"",
"\"==\"",
"\"!=\"",
"\"<\"",
"\">\"",
"\"<=\"",
"\">=\"",
"\"<<\"",
"\">>\"",
"\"+\"",
"\"-\"",
"\"*\"",
"\"/\"",
"\"%\"",
"\"++\"",
"\"--\"",
"\"~\"",
"\"!\"",
"\".\"",
"\"->\"",
"\".*\"",
"\"->*\"",
"\"auto\"",
"\"break\"",
"\"case\"",
"\"catch\"",
"\"char\"",
"\"const\"",
"\"continue\"",
"\"default\"",
"\"delete\"",
"\"do\"",
"\"double\"",
"\"else\"",
"\"enum\"",
"\"extern\"",
"\"finally\"",
"\"float\"",
"\"for\"",
"\"friend\"",
"\"goto\"",
"\"if\"",
"\"inline\"",
"\"int\"",
"\"long\"",
"\"new\"",
"\"private\"",
"\"protected\"",
"\"public\"",
"\"redeclared\"",
"\"register\"",
"\"return\"",
"\"short\"",
"\"signed\"",
"\"sizeof\"",
"\"static\"",
"\"struct\"",
"\"class\"",
"\"switch\"",
"\"template\"",
"\"this\"",
"\"try\"",
"\"typedef\"",
"\"union\"",
"\"unsigned\"",
"\"virtual\"",
"\"void\"",
"\"volatile\"",
"\"while\"",
"\"operator\"",
"\"true\"",
"\"false\"",
"\"throw\"",
"<OCTALINT>",
"<OCTALLONG>",
"<UNSIGNED_OCTALINT>",
"<UNSIGNED_OCTALLONG>",
"<DECIMALINT>",
"<DECIMALLONG>",
"<UNSIGNED_DECIMALINT>",
"<UNSIGNED_DECIMALLONG>",
"<HEXADECIMALINT>",
"<HEXADECIMALLONG>",
"<UNSIGNED_HEXADECIMALINT>",
"<UNSIGNED_HEXADECIMALLONG>",
"<FLOATONE>",
"<FLOATTWO>",
"<CHARACTER>",
"<STRING>",
"<ID>",
};
}

View file

@ -1,207 +0,0 @@
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 0.7pre6 */
package org.eclipse.cdt.internal.parser.generated;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* This exception is thrown when parse errors are encountered.
* You can explicitly create objects of this exception type by
* calling the method generateParseException in the generated
* parser.
*
* You can modify this class to customize your error reporting
* mechanisms so long as you retain the public fields.
*/
public class ParseException extends Exception {
/**
* This constructor is used by the method "generateParseException"
* in the generated parser. Calling this constructor generates
* a new object of this type with the fields "currentToken",
* "expectedTokenSequences", and "tokenImage" set. The boolean
* flag "specialConstructor" is also set to true to indicate that
* this constructor was used to create this object.
* This constructor calls its super class with the empty string
* to force the "toString" method of parent class "Throwable" to
* print the error message in the form:
* ParseException: <result of getMessage>
*/
public ParseException(Token currentTokenVal,
int[][] expectedTokenSequencesVal,
String[] tokenImageVal
)
{
super("");
specialConstructor = true;
currentToken = currentTokenVal;
expectedTokenSequences = expectedTokenSequencesVal;
tokenImage = tokenImageVal;
}
/**
* The following constructors are for use by you for whatever
* purpose you can think of. Constructing the exception in this
* manner makes the exception behave in the normal way - i.e., as
* documented in the class "Throwable". The fields "errorToken",
* "expectedTokenSequences", and "tokenImage" do not contain
* relevant information. The JavaCC generated code does not use
* these constructors.
*/
public ParseException() {
super();
specialConstructor = false;
}
public ParseException(String message) {
super(message);
specialConstructor = false;
}
/**
* This variable determines which constructor was used to create
* this object and thereby affects the semantics of the
* "getMessage" method (see below).
*/
protected boolean specialConstructor;
/**
* This is the last token that has been consumed successfully. If
* this object has been created due to a parse error, the token
* followng this token will (therefore) be the first error token.
*/
public Token currentToken;
/**
* Each entry in this array is an array of integers. Each array
* of integers represents a sequence of tokens (by their ordinal
* values) that is expected at this point of the parse.
*/
public int[][] expectedTokenSequences;
/**
* This is a reference to the "tokenImage" array of the generated
* parser within which the parse error occurred. This array is
* defined in the generated ...Constants interface.
*/
public String[] tokenImage;
/**
* This method has the standard behavior when this object has been
* created using the standard constructors. Otherwise, it uses
* "currentToken" and "expectedTokenSequences" to generate a parse
* error message and returns it. If this object has been created
* due to a parse error, and you do not catch it (it gets thrown
* from the parser), then this method is called during the printing
* of the final stack trace, and hence the correct error message
* gets displayed.
*/
public String getMessage() {
if (!specialConstructor) {
return super.getMessage();
}
String expected = "";
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
if (maxSize < expectedTokenSequences[i].length) {
maxSize = expectedTokenSequences[i].length;
}
for (int j = 0; j < expectedTokenSequences[i].length; j++) {
expected += tokenImage[expectedTokenSequences[i][j]] + " ";
}
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected += "...";
}
expected += eol + " ";
}
String retval = "Encountered \"";
Token tok = currentToken.next;
for (int i = 0; i < maxSize; i++) {
if (i != 0) retval += " ";
if (tok.kind == 0) {
retval += tokenImage[0];
break;
}
retval += add_escapes(tok.image);
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn + "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
} else {
retval += "Was expecting one of:" + eol + " ";
}
retval += expected;
return retval;
}
/**
* The end of line string for this machine.
*/
protected String eol = System.getProperty("line.separator", "\n");
/**
* Used to convert raw characters to their escaped version
* when these raw version cannot be used as part of an ASCII
* string literal.
*/
protected String add_escapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
case '\t':
retval.append("\\t");
continue;
case '\n':
retval.append("\\n");
continue;
case '\f':
retval.append("\\f");
continue;
case '\r':
retval.append("\\r");
continue;
case '\"':
retval.append("\\\"");
continue;
case '\'':
retval.append("\\\'");
continue;
case '\\':
retval.append("\\\\");
continue;
default:
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
String s = "0000" + Integer.toString(ch, 16);
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
} else {
retval.append(ch);
}
continue;
}
}
return retval.toString();
}
}

View file

@ -1,95 +0,0 @@
/* Generated By:JavaCC: Do not edit this line. Token.java Version 0.7pre3 */
package org.eclipse.cdt.internal.parser.generated;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
/**
* Describes the input token stream.
*/
public class Token {
/**
* An integer that describes the kind of this token. This numbering
* system is determined by JavaCCParser, and a table of these numbers is
* stored in the file ...Constants.java.
*/
public int kind;
/**
* beginLine and beginColumn describe the position of the first character
* of this token; endLine and endColumn describe the position of the
* last character of this token.
*/
public int beginLine, beginColumn, endLine, endColumn;
/**
* The string image of the token.
*/
public String image;
/**
* A reference to the next regular (non-special) token from the input
* stream. If this is the last token from the input stream, or if the
* token manager has not read tokens beyond this one, this field is
* set to null. This is true only if this token is also a regular
* token. Otherwise, see below for a description of the contents of
* this field.
*/
public Token next;
/**
* This field is used to access special tokens that occur prior to this
* token, but after the immediately preceding regular (non-special) token.
* If there are no such special tokens, this field is set to null.
* When there are more than one such special token, this field refers
* to the last of these special tokens, which in turn refers to the next
* previous special token through its specialToken field, and so on
* until the first special token (whose specialToken field is null).
* The next fields of special tokens refer to other special tokens that
* immediately follow it (without an intervening regular token). If there
* is no such token, this field is null.
*/
public Token specialToken;
/**
* Returns the image.
*/
public final String toString()
{
return image;
}
/**
* Returns a new Token object, by default. However, if you want, you
* can create and return subclass objects based on the value of ofKind.
* Simply add the cases to the switch for all those special cases.
* For example, if you have a subclass of Token called IDToken that
* you want to create if ofKind is ID, simlpy add something like :
*
* case MyParserConstants.ID : return new IDToken();
*
* to the following switch statement. Then you can cast matchedToken
* variable to the appropriate type and use it in your lexical actions.
*/
public static final Token newToken(int ofKind)
{
switch(ofKind)
{
default : return new Token();
}
}
}

View file

@ -1,150 +0,0 @@
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 0.7pre2 */
package org.eclipse.cdt.internal.parser.generated;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
public class TokenMgrError extends Error
{
/*
* Ordinals for various reasons why an Error of this type can be thrown.
*/
/**
* Lexical error occured.
*/
static final int LEXICAL_ERROR = 0;
/**
* An attempt wass made to create a second instance of a static token manager.
*/
static final int STATIC_LEXER_ERROR = 1;
/**
* Tried to change to an invalid lexical state.
*/
static final int INVALID_LEXICAL_STATE = 2;
/**
* Detected (and bailed out of) an infinite loop in the token manager.
*/
static final int LOOP_DETECTED = 3;
/**
* Indicates the reason why the exception is thrown. It will have
* one of the above 4 values.
*/
int errorCode;
/**
* Replaces unprintable characters by their espaced (or unicode escaped)
* equivalents in the given string
*/
protected static final String addEscapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
case '\t':
retval.append("\\t");
continue;
case '\n':
retval.append("\\n");
continue;
case '\f':
retval.append("\\f");
continue;
case '\r':
retval.append("\\r");
continue;
case '\"':
retval.append("\\\"");
continue;
case '\'':
retval.append("\\\'");
continue;
case '\\':
retval.append("\\\\");
continue;
default:
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
String s = "0000" + Integer.toString(ch, 16);
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
} else {
retval.append(ch);
}
continue;
}
}
return retval.toString();
}
/**
* Returns a detailed message for the Error when it is thrown by the
* token manager to indicate a lexical error.
* Parameters :
* EOFSeen : indicates if EOF caused the lexicl error
* curLexState : lexical state in which this error occured
* errorLine : line number when the error occured
* errorColumn : column number when the error occured
* errorAfter : prefix that was seen before this error occured
* curchar : the offending character
* Note: You can customize the lexical error message by modifying this method.
*/
private static final String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
return("Lexical error at line " +
errorLine + ", column " +
errorColumn + ". Encountered: " +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
"after : \"" + addEscapes(errorAfter) + "\"");
}
/**
* You can also modify the body of this method to customize your error messages.
* For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
* of end-users concern, so you can return something like :
*
* "Internal Error : Please file a bug report .... "
*
* from this method for such cases in the release version of your parser.
*/
public String getMessage() {
return super.getMessage();
}
/*
* Constructors of various flavors follow.
*/
public TokenMgrError() {
}
public TokenMgrError(String message, int reason) {
super(message);
errorCode = reason;
}
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}

View file

@ -5,7 +5,6 @@ package org.eclipse.cdt.internal.ui.preferences;
* All Rights Reserved. * All Rights Reserved.
*/ */
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.PreferenceConstants;
@ -51,9 +50,6 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
BooleanFieldEditor showCUChildrenEditor= new BooleanFieldEditor(PreferenceConstants.PREF_SHOW_CU_CHILDREN, CUIPlugin.getResourceString(SHOW_CU_CHILDREN_LABEL), parent); BooleanFieldEditor showCUChildrenEditor= new BooleanFieldEditor(PreferenceConstants.PREF_SHOW_CU_CHILDREN, CUIPlugin.getResourceString(SHOW_CU_CHILDREN_LABEL), parent);
addField(showCUChildrenEditor); addField(showCUChildrenEditor);
BooleanFieldEditor useNewParserEditor= new BooleanFieldEditor(CCorePlugin.PREF_USE_NEW_PARSER, CUIPlugin.getResourceString(USE_NEW_PARSER_LABEL), parent);
addField(useNewParserEditor);
} }
@ -65,15 +61,10 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN); return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
} }
public static boolean useNewParser() {
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(CCorePlugin.PREF_USE_NEW_PARSER);
}
/** /**
* @see IWorkbenchPreferencePage#init * @see IWorkbenchPreferencePage#init
*/ */
public void init(IWorkbench workbench) { public void init(IWorkbench workbench) {
CUIPlugin.getDefault().getPreferenceStore().setValue(CCorePlugin.PREF_USE_NEW_PARSER, CCorePlugin.getDefault().useNewParser());
} }
/** /**
@ -82,7 +73,6 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
public static void initDefaults(IPreferenceStore prefs) { public static void initDefaults(IPreferenceStore prefs) {
prefs.setDefault(PreferenceConstants.PREF_LINK_TO_EDITOR, true); prefs.setDefault(PreferenceConstants.PREF_LINK_TO_EDITOR, true);
prefs.setDefault(PreferenceConstants.PREF_SHOW_CU_CHILDREN, true); prefs.setDefault(PreferenceConstants.PREF_SHOW_CU_CHILDREN, true);
prefs.setDefault(CCorePlugin.PREF_USE_NEW_PARSER, CCorePlugin.getDefault().useNewParser());
prefs.setDefault(PreferenceConstants.EDITOR_SHOW_SEGMENTS, false); prefs.setDefault(PreferenceConstants.EDITOR_SHOW_SEGMENTS, false);
} }
@ -93,7 +83,6 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
if (!super.performOk()) if (!super.performOk())
return false; return false;
CCorePlugin.getDefault().setUseNewParser(useNewParser());
return true; return true;
} }