mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Updated Factory infrastructure, constructors, etc.
Introduced Preprocessor class for transitive closure calc. client.
This commit is contained in:
parent
b8059d7f27
commit
f61006c9fe
38 changed files with 686 additions and 227 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2003-06-23 John Camelon
|
||||||
|
Factory/constructor signature updates.
|
||||||
|
|
||||||
2003-06-17 Victor Mozgin
|
2003-06-17 Victor Mozgin
|
||||||
Added MacroTests.java (invocation in AllCoreTests).
|
Added MacroTests.java (invocation in AllCoreTests).
|
||||||
Added MacroTests.c to resources.
|
Added MacroTests.c to resources.
|
||||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.core.parser.tests;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
@ -21,7 +22,8 @@ import junit.framework.AssertionFailedError;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,12 +53,8 @@ public class AutomatedTest extends AutomatedFramework {
|
||||||
FileInputStream stream = new FileInputStream( file );
|
FileInputStream stream = new FileInputStream( file );
|
||||||
|
|
||||||
String filePath = file.getCanonicalPath();
|
String filePath = file.getCanonicalPath();
|
||||||
String nature = (String)natures.get( filePath );
|
parser = ParserFactory.createParser( ParserFactory.createScanner( new InputStreamReader (stream), filePath, null, null, ParserMode.QUICK_PARSE ), nullCallback, ParserMode.QUICK_PARSE);
|
||||||
|
parser.setCppNature( ((String)natures.get( filePath )).equalsIgnoreCase("cpp") );
|
||||||
boolean cppNature = nature.equalsIgnoreCase("cpp");
|
|
||||||
|
|
||||||
parser = new Parser( stream, nullCallback, true);
|
|
||||||
parser.setCppNature( cppNature );
|
|
||||||
parser.mapLineNumbers(true);
|
parser.mapLineNumbers(true);
|
||||||
|
|
||||||
assertTrue( parser.parse() );
|
assertTrue( parser.parse() );
|
||||||
|
|
|
@ -10,12 +10,15 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests;
|
package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
||||||
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
|
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,7 +39,8 @@ public class BaseDOMTest extends TestCase {
|
||||||
|
|
||||||
public TranslationUnit parse(String code, boolean quickParse, boolean throwOnError ) throws Exception {
|
public TranslationUnit parse(String code, boolean quickParse, boolean throwOnError ) throws Exception {
|
||||||
DOMBuilder domBuilder = new DOMBuilder();
|
DOMBuilder domBuilder = new DOMBuilder();
|
||||||
IParser parser = new Parser(code, domBuilder, quickParse );
|
ParserMode mode = quickParse ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
|
||||||
|
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, null, null, mode ), domBuilder, mode );
|
||||||
if( ! parser.parse() )
|
if( ! parser.parse() )
|
||||||
if( throwOnError ) throw new ParserException( "Parse failure" );
|
if( throwOnError ) throw new ParserException( "Parse failure" );
|
||||||
else domBuilder.getTranslationUnit().setParseSuccessful( false );
|
else domBuilder.getTranslationUnit().setParseSuccessful( false );
|
||||||
|
|
|
@ -15,10 +15,11 @@ import java.io.StringReader;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ScannerException;
|
import org.eclipse.cdt.core.parser.ScannerException;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||||
import org.eclipse.cdt.internal.core.parser.Scanner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -26,7 +27,7 @@ import org.eclipse.cdt.internal.core.parser.Scanner;
|
||||||
*/
|
*/
|
||||||
public class BaseScannerTest extends TestCase {
|
public class BaseScannerTest extends TestCase {
|
||||||
|
|
||||||
protected Scanner scanner;
|
protected IScanner scanner;
|
||||||
|
|
||||||
public BaseScannerTest( String x )
|
public BaseScannerTest( String x )
|
||||||
{
|
{
|
||||||
|
@ -35,8 +36,7 @@ public class BaseScannerTest extends TestCase {
|
||||||
|
|
||||||
public void initializeScanner(String input)
|
public void initializeScanner(String input)
|
||||||
{
|
{
|
||||||
scanner= new Scanner();
|
scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", null, null, null );
|
||||||
scanner.initialize( new StringReader(input),"TEXT");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fullyTokenize() throws Exception
|
public int fullyTokenize() throws Exception
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package org.eclipse.cdt.core.parser.tests;
|
package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.ExpressionEvaluator;
|
import org.eclipse.cdt.internal.core.parser.ExpressionEvaluator;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
|
||||||
|
|
||||||
public class ExprEvalTest extends TestCase {
|
public class ExprEvalTest extends TestCase {
|
||||||
|
|
||||||
|
@ -20,7 +22,7 @@ public class ExprEvalTest extends TestCase {
|
||||||
|
|
||||||
public void runTest(String code, int expectedValue) throws Exception {
|
public void runTest(String code, int expectedValue) throws Exception {
|
||||||
ExpressionEvaluator evaluator = new ExpressionEvaluator();
|
ExpressionEvaluator evaluator = new ExpressionEvaluator();
|
||||||
IParser parser = new Parser(code, evaluator);
|
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, null, null, null ), evaluator, null);
|
||||||
parser.expression(null);
|
parser.expression(null);
|
||||||
assertEquals(expectedValue, ((Integer)evaluator.getResult()).intValue());
|
assertEquals(expectedValue, ((Integer)evaluator.getResult()).intValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,16 @@ import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -234,7 +237,8 @@ public class FractionalAutomatedTest extends AutomatedFramework {
|
||||||
public void run(){
|
public void run(){
|
||||||
try{
|
try{
|
||||||
result = null;
|
result = null;
|
||||||
Parser parser = new Parser( code, nullCallback, true);
|
IParser parser = ParserFactory.createParser(
|
||||||
|
ParserFactory.createScanner( new StringReader( code ), null, null, null, ParserMode.QUICK_PARSE ), nullCallback, ParserMode.QUICK_PARSE);
|
||||||
parser.setCppNature( cppNature );
|
parser.setCppNature( cppNature );
|
||||||
parser.mapLineNumbers(true);
|
parser.mapLineNumbers(true);
|
||||||
parser.parse();
|
parser.parse();
|
||||||
|
|
|
@ -13,14 +13,17 @@ package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Reader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
||||||
import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier;
|
import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier;
|
||||||
|
@ -29,7 +32,6 @@ import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
|
||||||
import org.eclipse.cdt.internal.core.dom.SimpleDeclaration;
|
import org.eclipse.cdt.internal.core.dom.SimpleDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.dom.TemplateDeclaration;
|
import org.eclipse.cdt.internal.core.dom.TemplateDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||||
import org.eclipse.cdt.internal.core.parser.Scanner;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,9 +55,7 @@ public class LineNumberTest extends TestCase {
|
||||||
|
|
||||||
public void testLineNos() throws Exception
|
public void testLineNos() throws Exception
|
||||||
{
|
{
|
||||||
Scanner scanner = new Scanner();
|
IScanner scanner = ParserFactory.createScanner( new StringReader( "int x = 3;\n foo\nfire\nfoe " ), "string", null, null, null );
|
||||||
Reader reader = new StringReader( "int x = 3;\n foo\nfire\nfoe ");
|
|
||||||
scanner.initialize( reader, "string");
|
|
||||||
scanner.mapLineNumbers(true);
|
scanner.mapLineNumbers(true);
|
||||||
IToken t = scanner.nextToken();
|
IToken t = scanner.nextToken();
|
||||||
assertEquals( t.getType(), IToken.t_int );
|
assertEquals( t.getType(), IToken.t_int );
|
||||||
|
@ -92,7 +92,7 @@ public class LineNumberTest extends TestCase {
|
||||||
public void testDOMLineNos() throws Exception
|
public void testDOMLineNos() throws Exception
|
||||||
{
|
{
|
||||||
DOMBuilder domBuilder = new DOMBuilder();
|
DOMBuilder domBuilder = new DOMBuilder();
|
||||||
IParser parser = new Parser( fileIn, domBuilder, true );
|
IParser parser = ParserFactory.createParser( ParserFactory.createScanner( new InputStreamReader( fileIn ), null, null, null, ParserMode.QUICK_PARSE ), domBuilder, ParserMode.QUICK_PARSE );
|
||||||
parser.mapLineNumbers(true);
|
parser.mapLineNumbers(true);
|
||||||
if( ! parser.parse() ) fail( "Parse of file failed");
|
if( ! parser.parse() ) fail( "Parse of file failed");
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class ParserTestSuite extends TestCase {
|
||||||
suite.addTestSuite(ParserSymbolTableTest.class);
|
suite.addTestSuite(ParserSymbolTableTest.class);
|
||||||
suite.addTestSuite(CModelElementsTests.class);
|
suite.addTestSuite(CModelElementsTests.class);
|
||||||
suite.addTestSuite(MacroTests.class);
|
suite.addTestSuite(MacroTests.class);
|
||||||
|
suite.addTestSuite( PreprocessorTest.class );
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,345 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IPreprocessor;
|
||||||
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTConstructor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypedef;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PreprocessorTest extends TestCase {
|
||||||
|
|
||||||
|
public static class Callback implements ISourceElementRequestor
|
||||||
|
{
|
||||||
|
private List enteredInc = new ArrayList(), exitedInc = new ArrayList();
|
||||||
|
|
||||||
|
public boolean asExpected( int balance )
|
||||||
|
{
|
||||||
|
return( ( enteredInc.size() - exitedInc.size() ) == balance );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
|
||||||
|
*/
|
||||||
|
public void acceptProblem(IProblem problem) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMacro(org.eclipse.cdt.core.parser.ast.IASTMacro)
|
||||||
|
*/
|
||||||
|
public void acceptMacro(IASTMacro macro) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptVariable(org.eclipse.cdt.core.parser.ast.IASTVariable)
|
||||||
|
*/
|
||||||
|
public void acceptVariable(IASTVariable variable) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionDeclaration(org.eclipse.cdt.core.parser.ast.IASTFunction)
|
||||||
|
*/
|
||||||
|
public void acceptFunctionDeclaration(IASTFunction function) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDirective(org.eclipse.cdt.core.parser.ast.IASTUsingDirective)
|
||||||
|
*/
|
||||||
|
public void acceptUsingDirective(IASTUsingDirective usageDirective) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration)
|
||||||
|
*/
|
||||||
|
public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptASMDefinition(org.eclipse.cdt.core.parser.ast.IASTASMDefinition)
|
||||||
|
*/
|
||||||
|
public void acceptASMDefinition(IASTASMDefinition asmDefinition) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedef(org.eclipse.cdt.core.parser.ast.IASTTypedef)
|
||||||
|
*/
|
||||||
|
public void acceptTypedef(IASTTypedef typedef) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier)
|
||||||
|
*/
|
||||||
|
public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
|
||||||
|
*/
|
||||||
|
public void enterFunctionBody(IASTFunction function) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
|
||||||
|
*/
|
||||||
|
public void exitFunctionBody(IASTFunction function) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
|
||||||
|
*/
|
||||||
|
public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
|
||||||
|
*/
|
||||||
|
public void enterInclusion(IASTInclusion inclusion) {
|
||||||
|
enteredInc.add( inclusion );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
|
||||||
|
*/
|
||||||
|
public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
|
||||||
|
*/
|
||||||
|
public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
|
||||||
|
*/
|
||||||
|
public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
|
||||||
|
*/
|
||||||
|
public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
|
||||||
|
*/
|
||||||
|
public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
|
||||||
|
*/
|
||||||
|
public void enterTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMethodDeclaration(org.eclipse.cdt.core.parser.ast.IASTMethod)
|
||||||
|
*/
|
||||||
|
public void acceptMethodDeclaration(IASTMethod method) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
|
||||||
|
*/
|
||||||
|
public void enterMethodBody(IASTMethod method) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
|
||||||
|
*/
|
||||||
|
public void exitMethodBody(IASTMethod method) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptField(org.eclipse.cdt.core.parser.ast.IASTField)
|
||||||
|
*/
|
||||||
|
public void acceptField(IASTField field) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptConstructor(org.eclipse.cdt.core.parser.ast.IASTConstructor)
|
||||||
|
*/
|
||||||
|
public void acceptConstructor(IASTConstructor constructor) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptClassReference(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, int)
|
||||||
|
*/
|
||||||
|
public void acceptClassReference(IASTClassSpecifier classSpecifier, int referenceOffset) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
|
||||||
|
*/
|
||||||
|
public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
|
||||||
|
*/
|
||||||
|
public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
|
||||||
|
*/
|
||||||
|
public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
|
||||||
|
*/
|
||||||
|
public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
|
||||||
|
*/
|
||||||
|
public void exitClassSpecifier(IASTClassSpecifier classSpecification) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
|
||||||
|
*/
|
||||||
|
public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
|
||||||
|
*/
|
||||||
|
public void exitInclusion(IASTInclusion inclusion) {
|
||||||
|
exitedInc.add( inclusion );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
|
||||||
|
*/
|
||||||
|
public void exitCompilationUnit(IASTCompilationUnit compilationUnit) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PreprocessorTest( String name )
|
||||||
|
{
|
||||||
|
super( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSimpleExample()
|
||||||
|
{
|
||||||
|
Callback c = new Callback();
|
||||||
|
IPreprocessor p = setupPreprocessor( "#include <stdio.h>",
|
||||||
|
null, // NOTE -- to demonstrate simple example, this should be set up with the info from the
|
||||||
|
// build properties
|
||||||
|
null, c );
|
||||||
|
p.process();
|
||||||
|
c.asExpected(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPreprocessor setupPreprocessor( String text, List includePaths, Map defns, ISourceElementRequestor rq )
|
||||||
|
{
|
||||||
|
IPreprocessor p = ParserFactory.createPreprocesor( new StringReader( text ), "test", defns, includePaths, ParserMode.COMPLETE_PARSE );
|
||||||
|
p.setRequestor( rq );
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerException;
|
import org.eclipse.cdt.core.parser.ScannerException;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||||
import org.eclipse.cdt.internal.core.parser.Token;
|
import org.eclipse.cdt.internal.core.parser.Token;
|
||||||
|
@ -851,7 +852,7 @@ public class ScannerTestCase extends BaseScannerTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
initializeScanner( "#if X + 5 < 7\n int found = 1;\n#endif" );
|
initializeScanner( "#if X + 5 < 7\n int found = 1;\n#endif" );
|
||||||
scanner.setQuickScan( true );
|
scanner.setMode( ParserMode.QUICK_PARSE );
|
||||||
validateToken( IToken.t_int );
|
validateToken( IToken.t_int );
|
||||||
validateIdentifier( "found" );
|
validateIdentifier( "found" );
|
||||||
validateToken( IToken.tASSIGN );
|
validateToken( IToken.tASSIGN );
|
||||||
|
@ -868,7 +869,7 @@ public class ScannerTestCase extends BaseScannerTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
initializeScanner( "#if 0\n int error = 666;\n#endif" );
|
initializeScanner( "#if 0\n int error = 666;\n#endif" );
|
||||||
scanner.setQuickScan( true );
|
scanner.setMode( ParserMode.COMPLETE_PARSE );
|
||||||
validateEOF();
|
validateEOF();
|
||||||
}
|
}
|
||||||
catch( ScannerException se )
|
catch( ScannerException se )
|
||||||
|
@ -905,11 +906,7 @@ public class ScannerTestCase extends BaseScannerTest
|
||||||
initializeScanner("#include <Windows.h>");
|
initializeScanner("#include <Windows.h>");
|
||||||
prepareForWindowsH();
|
prepareForWindowsH();
|
||||||
int count= fullyTokenize();
|
int count= fullyTokenize();
|
||||||
if (verbose)
|
|
||||||
System.out.println(
|
|
||||||
"For Windows.h, Scanner produced "
|
|
||||||
+ scanner.getCount()
|
|
||||||
+ " tokens");
|
|
||||||
validateBalance();
|
validateBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,11 +916,6 @@ public class ScannerTestCase extends BaseScannerTest
|
||||||
prepareForWindowsRH();
|
prepareForWindowsRH();
|
||||||
validateEOF();
|
validateEOF();
|
||||||
validateBalance();
|
validateBalance();
|
||||||
if (verbose)
|
|
||||||
System.out.println(
|
|
||||||
"For WinUser.rh, Scanner produced "
|
|
||||||
+ scanner.getCount()
|
|
||||||
+ " tokens");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
@ -22,8 +23,9 @@ import junit.framework.AssertionFailedError;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,7 +202,8 @@ public class TortureTest extends FractionalAutomatedTest {
|
||||||
public void run(){
|
public void run(){
|
||||||
try {
|
try {
|
||||||
DOMBuilder domBuilder = new DOMBuilder();
|
DOMBuilder domBuilder = new DOMBuilder();
|
||||||
parser = new Parser(code.toString(), domBuilder, quickParse);
|
IParser parser = ParserFactory.createParser(
|
||||||
|
ParserFactory.createScanner( new StringReader( code ), null, null, null, ParserMode.QUICK_PARSE ), nullCallback, ParserMode.QUICK_PARSE);
|
||||||
|
|
||||||
parser.setCppNature(cppNature);
|
parser.setCppNature(cppNature);
|
||||||
parser.mapLineNumbers(true);
|
parser.mapLineNumbers(true);
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
TortureTest.properties
|
|
@ -35,7 +35,7 @@ public class Name {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
Token t = nameStart;
|
IToken t = nameStart;
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append( t.getImage() );
|
buffer.append( t.getImage() );
|
||||||
if( t.getType() == IToken.t_operator )
|
if( t.getType() == IToken.t_operator )
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
* Rational Software - initial implementation
|
* Rational Software - initial implementation
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -25,6 +26,8 @@ import org.eclipse.cdt.core.model.IStructure;
|
||||||
import org.eclipse.cdt.core.model.ITemplate;
|
import org.eclipse.cdt.core.model.ITemplate;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.dom.ArrayQualifier;
|
import org.eclipse.cdt.internal.core.dom.ArrayQualifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.ClassKey;
|
import org.eclipse.cdt.internal.core.dom.ClassKey;
|
||||||
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
||||||
|
@ -50,7 +53,6 @@ import org.eclipse.cdt.internal.core.dom.TemplateParameter;
|
||||||
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
|
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.dom.TypeSpecifier;
|
import org.eclipse.cdt.internal.core.dom.TypeSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.Name;
|
import org.eclipse.cdt.internal.core.parser.Name;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,8 +70,7 @@ public class CModelBuilder {
|
||||||
// Note - if a CModel client wishes to have a CModel with valid line numbers
|
// Note - if a CModel client wishes to have a CModel with valid line numbers
|
||||||
// DOMFactory.createDOMBuilder should be given the parameter 'true'
|
// DOMFactory.createDOMBuilder should be given the parameter 'true'
|
||||||
DOMBuilder domBuilder = new DOMBuilder();
|
DOMBuilder domBuilder = new DOMBuilder();
|
||||||
String code = translationUnit.getBuffer().getContents();
|
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( translationUnit.getBuffer().getContents() ), null, null, null, ParserMode.QUICK_PARSE ), domBuilder, ParserMode.QUICK_PARSE);
|
||||||
IParser parser = new Parser(code, domBuilder, true);
|
|
||||||
parser.mapLineNumbers(requiresLineNumbers);
|
parser.mapLineNumbers(requiresLineNumbers);
|
||||||
if( translationUnit.getCProject() != null )
|
if( translationUnit.getCProject() != null )
|
||||||
{
|
{
|
|
@ -1,3 +1,7 @@
|
||||||
|
2003-06-23 John Camelon
|
||||||
|
Updated Factory infrastructure, constructors, etc.
|
||||||
|
Introduced Preprocessor class for transitive closure calc. client.
|
||||||
|
|
||||||
2003-06-20 Victor Mozgin
|
2003-06-20 Victor Mozgin
|
||||||
Fixed PR 36463 : Offsets of macros are incorrect.
|
Fixed PR 36463 : Offsets of macros are incorrect.
|
||||||
|
|
||||||
|
|
|
@ -8,23 +8,15 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser;
|
package org.eclipse.cdt.core.parser;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.full.FullParseASTFactory;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.quick.QuickParseASTFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ParserFactory {
|
public interface IPreprocessor extends IScanner {
|
||||||
|
|
||||||
|
public void process();
|
||||||
|
|
||||||
public static IASTFactory createASTFactory( boolean quickParse )
|
|
||||||
{
|
|
||||||
if( quickParse )
|
|
||||||
return new QuickParseASTFactory();
|
|
||||||
else
|
|
||||||
return new FullParseASTFactory();
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package org.eclipse.cdt.core.parser;
|
package org.eclipse.cdt.core.parser;
|
||||||
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||||
|
@ -15,8 +14,7 @@ public interface IScanner {
|
||||||
public static final int tPOUNDPOUND = -6;
|
public static final int tPOUNDPOUND = -6;
|
||||||
public static final int tPOUND = -7;
|
public static final int tPOUND = -7;
|
||||||
|
|
||||||
public IScanner initialize( Reader sourceToBeRead, String fileName );
|
public void setASTFactory( IASTFactory f );
|
||||||
|
|
||||||
public void addDefinition(String key, IMacroDescriptor macroToBeAdded );
|
public void addDefinition(String key, IMacroDescriptor macroToBeAdded );
|
||||||
public void addDefinition(String key, String value);
|
public void addDefinition(String key, String value);
|
||||||
public Object getDefinition(String key);
|
public Object getDefinition(String key);
|
||||||
|
@ -24,13 +22,24 @@ public interface IScanner {
|
||||||
public Object[] getIncludePaths();
|
public Object[] getIncludePaths();
|
||||||
public void addIncludePath(String includePath);
|
public void addIncludePath(String includePath);
|
||||||
public void overwriteIncludePath( List newIncludePaths );
|
public void overwriteIncludePath( List newIncludePaths );
|
||||||
|
public void setRequestor( ISourceElementRequestor r );
|
||||||
|
|
||||||
public IToken nextToken() throws ScannerException, Parser.EndOfFile;
|
public IToken nextToken() throws ScannerException, Parser.EndOfFile;
|
||||||
|
public IToken nextToken( boolean next ) throws ScannerException, Parser.EndOfFile;
|
||||||
public int getLineNumberForOffset(int offset) throws NoSuchMethodException;
|
public int getLineNumberForOffset(int offset) throws NoSuchMethodException;
|
||||||
public void setCppNature( boolean value );
|
public void setCppNature( boolean value );
|
||||||
public void mapLineNumbers( boolean value );
|
public void mapLineNumbers( boolean value );
|
||||||
public void setQuickScan(boolean qs);
|
public void setMode(ParserMode mode);
|
||||||
public void setCallback(IParserCallback c);
|
public void setCallback(IParserCallback c);
|
||||||
public void setRequestor( ISourceElementRequestor r );
|
|
||||||
public void setASTFactory( IASTFactory f );
|
public int getCount();
|
||||||
|
public int getDepth();
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IToken nextTokenForStringizing() throws ScannerException, Parser.EndOfFile;
|
||||||
|
/**
|
||||||
|
* @param b
|
||||||
|
*/
|
||||||
|
public void setTokenizingMacroReplacementList(boolean b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,13 @@ public interface IToken {
|
||||||
public abstract String toString();
|
public abstract String toString();
|
||||||
public abstract int getType();
|
public abstract int getType();
|
||||||
public abstract String getImage();
|
public abstract String getImage();
|
||||||
|
public void setImage( String i );
|
||||||
public abstract int getOffset();
|
public abstract int getOffset();
|
||||||
public abstract int getLength();
|
public abstract int getLength();
|
||||||
public abstract int getEndOffset();
|
public abstract int getEndOffset();
|
||||||
public abstract int getDelta(IToken other);
|
public abstract int getDelta(IToken other);
|
||||||
public abstract Token getNext();
|
public abstract IToken getNext();
|
||||||
public abstract void setNext(Token t);
|
public abstract void setNext(IToken t);
|
||||||
public abstract boolean looksLikeExpression();
|
public abstract boolean looksLikeExpression();
|
||||||
public abstract boolean isPointer();
|
public abstract boolean isPointer();
|
||||||
public abstract boolean isOperator();
|
public abstract boolean isOperator();
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.core.parser;
|
||||||
|
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.Preprocessor;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.Scanner;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.full.FullParseASTFactory;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.quick.QuickParseASTFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ParserFactory {
|
||||||
|
|
||||||
|
public static IASTFactory createASTFactory( ParserMode mode )
|
||||||
|
{
|
||||||
|
if( mode == ParserMode.QUICK_PARSE )
|
||||||
|
return new QuickParseASTFactory();
|
||||||
|
else
|
||||||
|
return new FullParseASTFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IParser createParser( IScanner scanner, IParserCallback callback, ParserMode mode )
|
||||||
|
{
|
||||||
|
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||||
|
IParserCallback ourCallback = (( callback == null) ? new NullSourceElementRequestor() : callback );
|
||||||
|
return new Parser( scanner, ourCallback, ourMode );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IScanner createScanner( Reader input, String fileName, Map defns, List inclusions, ParserMode mode )
|
||||||
|
{
|
||||||
|
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||||
|
IScanner s = new Scanner( input, fileName, defns );
|
||||||
|
s.setMode( ourMode );
|
||||||
|
s.overwriteIncludePath(inclusions);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IPreprocessor createPreprocesor( Reader input, String fileName, Map defns, List inclusions, ParserMode mode )
|
||||||
|
{
|
||||||
|
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||||
|
IPreprocessor s = new Preprocessor( input, fileName, defns );
|
||||||
|
s.setMode( ourMode );
|
||||||
|
s.overwriteIncludePath(inclusions);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.core.parser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ParserMode {
|
||||||
|
|
||||||
|
// follow inclusions, parse function/method bodies
|
||||||
|
public static final ParserMode COMPLETE_PARSE = new ParserMode( 1 );
|
||||||
|
|
||||||
|
// follow inclusions, do not parse function/method bodies
|
||||||
|
public static final ParserMode STRUCTURAL_PARSE = new ParserMode( 2 );
|
||||||
|
|
||||||
|
// do not follow inclusions, do not parse function/method bodies
|
||||||
|
public static final ParserMode QUICK_PARSE = new ParserMode( 3 );
|
||||||
|
|
||||||
|
private ParserMode( int value )
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
}
|
|
@ -24,6 +24,6 @@ public interface IASTClassSpecifier extends IASTTypeSpecifier, IASTScope, IASTOf
|
||||||
|
|
||||||
public Iterator getBaseClauses();
|
public Iterator getBaseClauses();
|
||||||
|
|
||||||
public AccessVisibility getCurrentVisiblity();
|
public AccessVisibility getCurrentVisibilityMode();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,13 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.parser;
|
package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.StringReader;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
import org.eclipse.cdt.core.parser.IParserCallback;
|
import org.eclipse.cdt.core.parser.IParserCallback;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerException;
|
import org.eclipse.cdt.core.parser.ScannerException;
|
||||||
import org.eclipse.cdt.core.parser.ast.AccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.AccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.ClassKind;
|
import org.eclipse.cdt.core.parser.ast.ClassKind;
|
||||||
|
@ -49,7 +47,7 @@ public class Parser implements IParser {
|
||||||
private static int DEFAULT_OFFSET = -1; // sentinel initial value for offsets
|
private static int DEFAULT_OFFSET = -1; // sentinel initial value for offsets
|
||||||
private int firstErrorOffset = DEFAULT_OFFSET; // offset where the first parse error occurred
|
private int firstErrorOffset = DEFAULT_OFFSET; // offset where the first parse error occurred
|
||||||
private IParserCallback callback; // the parser callback that was registered with us
|
private IParserCallback callback; // the parser callback that was registered with us
|
||||||
private boolean quickParse = false; // are we doing the high-level parse, or an in depth parse?
|
private ParserMode mode = ParserMode.COMPLETE_PARSE; // are we doing the high-level parse, or an in depth parse?
|
||||||
private boolean parsePassed = true; // did the parse pass?
|
private boolean parsePassed = true; // did the parse pass?
|
||||||
private boolean cppNature = true; // true for C++, false for C
|
private boolean cppNature = true; // true for C++, false for C
|
||||||
private ISourceElementRequestor requestor = null; // new callback mechanism
|
private ISourceElementRequestor requestor = null; // new callback mechanism
|
||||||
|
@ -77,86 +75,18 @@ public class Parser implements IParser {
|
||||||
* @param c IParserCallback instance that will receive callbacks as we parse
|
* @param c IParserCallback instance that will receive callbacks as we parse
|
||||||
* @param quick Are we asking for a high level parse or not?
|
* @param quick Are we asking for a high level parse or not?
|
||||||
*/
|
*/
|
||||||
public Parser(IScanner s, IParserCallback c, boolean quick) {
|
public Parser(IScanner s, IParserCallback c, ParserMode m) {
|
||||||
callback = c;
|
callback = c;
|
||||||
scanner = s;
|
scanner = s;
|
||||||
if( c instanceof ISourceElementRequestor )
|
if( c instanceof ISourceElementRequestor )
|
||||||
setRequestor( (ISourceElementRequestor)c );
|
setRequestor( (ISourceElementRequestor)c );
|
||||||
quickParse = quick;
|
mode = m;
|
||||||
astFactory = ParserFactory.createASTFactory( quick );
|
astFactory = ParserFactory.createASTFactory( m );
|
||||||
scanner.setQuickScan(quick);
|
scanner.setMode( m );
|
||||||
scanner.setCallback(c);
|
scanner.setCallback(c);
|
||||||
scanner.setASTFactory( astFactory );
|
scanner.setASTFactory( astFactory );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An additional constructor provided for ease of use and tezting.
|
|
||||||
*
|
|
||||||
* @param s IScanner instance that has been initialized to the code input
|
|
||||||
* @param c IParserCallback instance that will receive callbacks as we parse
|
|
||||||
*/
|
|
||||||
public Parser(IScanner s, IParserCallback c) {
|
|
||||||
this(s, c, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An additional constructor provided for ease of use and tezting.
|
|
||||||
*
|
|
||||||
* @param s IScanner instance that has been initialized to the code input
|
|
||||||
*/
|
|
||||||
public Parser( IScanner s) {
|
|
||||||
this(s, new NullSourceElementRequestor(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An additional constructor provided for ease of use and tezting.
|
|
||||||
*
|
|
||||||
* * @param code The code that we wish to parse
|
|
||||||
*/
|
|
||||||
public Parser(String code) {
|
|
||||||
this(new Scanner().initialize( new StringReader( code ), null
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An additional constructor provided for ease of use and tezting.
|
|
||||||
*
|
|
||||||
* @param code The code that we wish to parse
|
|
||||||
* @param c IParserCallback instance that will receive callbacks as we parse
|
|
||||||
*/
|
|
||||||
public Parser(String code, IParserCallback c) {
|
|
||||||
this(new Scanner().initialize( new StringReader( code ), null
|
|
||||||
), c, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An additional constructor provided for ease of use and tezting.
|
|
||||||
*
|
|
||||||
* @param code The code that we wish to parse
|
|
||||||
* @param c IParserCallback instance that will receive callbacks as we parse
|
|
||||||
* @param quickParse Are we asking for a high level parse or not?
|
|
||||||
*/
|
|
||||||
public Parser(String code, IParserCallback c, boolean quickParse ) {
|
|
||||||
this(new Scanner().initialize( new StringReader( code ), null
|
|
||||||
), c, quickParse);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An additional constructor provided for ease of use and tezting.
|
|
||||||
*
|
|
||||||
* @param stream An InputStream represnting the code that we wish to parse
|
|
||||||
* @param c IParserCallback instance that will receive callbacks as we parse
|
|
||||||
* @param quickParse Are we asking for a high level parse or not?
|
|
||||||
*/
|
|
||||||
public Parser(InputStream stream, IParserCallback c, boolean quickParse) {
|
|
||||||
this(new Scanner().initialize( new InputStreamReader(stream), null ),
|
|
||||||
c, quickParse);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int parseCount = 0; // counter that keeps track of the number of times Parser.parse() is called
|
private static int parseCount = 0; // counter that keeps track of the number of times Parser.parse() is called
|
||||||
|
|
||||||
|
|
||||||
|
@ -788,7 +718,8 @@ c, quickParse);
|
||||||
if (forKR) throw backtrack;
|
if (forKR) throw backtrack;
|
||||||
Object function = null;
|
Object function = null;
|
||||||
try{ function = callback.functionBodyBegin(simpleDecl ); } catch( Exception e ) {}
|
try{ function = callback.functionBodyBegin(simpleDecl ); } catch( Exception e ) {}
|
||||||
if (quickParse) {
|
|
||||||
|
if ( mode == ParserMode.QUICK_PARSE ) {
|
||||||
// speed up the parser by skiping the body
|
// speed up the parser by skiping the body
|
||||||
// simply look for matching brace and return
|
// simply look for matching brace and return
|
||||||
consume(IToken.tLBRACE);
|
consume(IToken.tLBRACE);
|
||||||
|
@ -868,7 +799,7 @@ c, quickParse);
|
||||||
catch( Backtrack bt )
|
catch( Backtrack bt )
|
||||||
{
|
{
|
||||||
try { callback.constructorChainAbort( constructorChain );} catch( Exception e ) {}
|
try { callback.constructorChainAbort( constructorChain );} catch( Exception e ) {}
|
||||||
if( ! quickParse )
|
if( mode != ParserMode.QUICK_PARSE )
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IPreprocessor;
|
||||||
|
import org.eclipse.cdt.core.parser.ScannerException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Preprocessor extends Scanner implements IPreprocessor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param reader
|
||||||
|
* @param filename
|
||||||
|
* @param defns
|
||||||
|
*/
|
||||||
|
public Preprocessor(Reader reader, String filename, Map defns) {
|
||||||
|
super(reader, filename, defns);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while( true )
|
||||||
|
nextToken();
|
||||||
|
}
|
||||||
|
catch( ScannerException se )
|
||||||
|
{
|
||||||
|
// callback IProblem here
|
||||||
|
}
|
||||||
|
catch( Parser.EndOfFile eof )
|
||||||
|
{
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
@ -31,6 +32,8 @@ import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IScannerContext;
|
import org.eclipse.cdt.core.parser.IScannerContext;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerException;
|
import org.eclipse.cdt.core.parser.ScannerException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||||
|
@ -44,12 +47,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||||
|
|
||||||
public class Scanner implements IScanner {
|
public class Scanner implements IScanner {
|
||||||
|
|
||||||
public IScanner initialize(Reader reader, String filename) {
|
public Scanner(Reader reader, String filename, Map defns) {
|
||||||
init(reader, filename);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void init(Reader reader, String filename) {
|
|
||||||
try {
|
try {
|
||||||
//this is a hack to get around a sudden EOF experience
|
//this is a hack to get around a sudden EOF experience
|
||||||
contextStack.push(
|
contextStack.push(
|
||||||
|
@ -65,14 +63,8 @@ public class Scanner implements IScanner {
|
||||||
} catch( ScannerException se ) {
|
} catch( ScannerException se ) {
|
||||||
//won't happen since we aren't adding an include or a macro
|
//won't happen since we aren't adding an include or a macro
|
||||||
}
|
}
|
||||||
}
|
if( defns != null )
|
||||||
|
definitions.putAll( defns );
|
||||||
public Scanner() {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Scanner(Reader reader, String filename, Hashtable defns) {
|
|
||||||
initialize(reader, filename);
|
|
||||||
definitions = defns;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,6 +75,7 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void overwriteIncludePath(List newIncludePaths) {
|
public void overwriteIncludePath(List newIncludePaths) {
|
||||||
|
if( newIncludePaths == null ) return;
|
||||||
includePathNames = null;
|
includePathNames = null;
|
||||||
includePaths = null;
|
includePaths = null;
|
||||||
includePathNames = new ArrayList();
|
includePathNames = new ArrayList();
|
||||||
|
@ -223,7 +216,7 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCurrentToken(Token t) {
|
private void setCurrentToken(IToken t) {
|
||||||
if (currentToken != null)
|
if (currentToken != null)
|
||||||
currentToken.setNext(t);
|
currentToken.setNext(t);
|
||||||
currentToken = t;
|
currentToken = t;
|
||||||
|
@ -235,12 +228,12 @@ public class Scanner implements IScanner {
|
||||||
storageBuffer = null;
|
storageBuffer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Token newToken(int t, String i, IScannerContext c) {
|
protected IToken newToken(int t, String i, IScannerContext c) {
|
||||||
setCurrentToken(new Token(t, i, c));
|
setCurrentToken(new Token(t, i, c));
|
||||||
return currentToken;
|
return currentToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Token newToken(int t, String i) {
|
protected IToken newToken(int t, String i) {
|
||||||
setCurrentToken(new Token(t, i));
|
setCurrentToken(new Token(t, i));
|
||||||
return currentToken;
|
return currentToken;
|
||||||
}
|
}
|
||||||
|
@ -345,8 +338,8 @@ public class Scanner implements IScanner {
|
||||||
private static HashMap cKeywords = new HashMap();
|
private static HashMap cKeywords = new HashMap();
|
||||||
private static HashMap ppDirectives = new HashMap();
|
private static HashMap ppDirectives = new HashMap();
|
||||||
|
|
||||||
private Token currentToken = null;
|
private IToken currentToken = null;
|
||||||
private Token cachedToken = null;
|
private IToken cachedToken = null;
|
||||||
|
|
||||||
private boolean passOnToClient = true;
|
private boolean passOnToClient = true;
|
||||||
private BranchTracker branches = new BranchTracker();
|
private BranchTracker branches = new BranchTracker();
|
||||||
|
@ -368,9 +361,10 @@ public class Scanner implements IScanner {
|
||||||
tokenizingMacroReplacementList = mr;
|
tokenizingMacroReplacementList = mr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean quickScan = false;
|
private ParserMode mode = ParserMode.COMPLETE_PARSE;
|
||||||
public void setQuickScan(boolean qs) {
|
|
||||||
quickScan = qs;
|
public void setMode(ParserMode mode) {
|
||||||
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IParserCallback callback;
|
private IParserCallback callback;
|
||||||
|
@ -485,7 +479,7 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Token nextToken( boolean pasting ) throws ScannerException, Parser.EndOfFile
|
public IToken nextToken( boolean pasting ) throws ScannerException, Parser.EndOfFile
|
||||||
{
|
{
|
||||||
if( cachedToken != null ){
|
if( cachedToken != null ){
|
||||||
setCurrentToken( cachedToken );
|
setCurrentToken( cachedToken );
|
||||||
|
@ -569,16 +563,16 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
//If the next token is going to be a string as well, we need to concatenate
|
//If the next token is going to be a string as well, we need to concatenate
|
||||||
//it with this token.
|
//it with this token.
|
||||||
Token returnToken = newToken( type, buff.toString(), contextStack.getCurrentContext());
|
IToken returnToken = newToken( type, buff.toString(), contextStack.getCurrentContext());
|
||||||
Token next = null;
|
IToken next = null;
|
||||||
try{
|
try{
|
||||||
next = nextToken( true );
|
next = nextToken( true );
|
||||||
} catch( Parser.EndOfFile e ){
|
} catch( Parser.EndOfFile e ){
|
||||||
next = null;
|
next = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
while( next != null && next.type == returnToken.type ){
|
while( next != null && next.getType() == returnToken.getType() ){
|
||||||
returnToken.image += next.image;
|
returnToken.setImage( returnToken.getImage() + next.getImage() );
|
||||||
returnToken.setNext( null );
|
returnToken.setNext( null );
|
||||||
currentToken = returnToken;
|
currentToken = returnToken;
|
||||||
try{
|
try{
|
||||||
|
@ -895,7 +889,7 @@ public class Scanner implements IScanner {
|
||||||
// definition
|
// definition
|
||||||
String toBeUndefined = getNextIdentifier();
|
String toBeUndefined = getNextIdentifier();
|
||||||
|
|
||||||
if( ( definitions.remove(toBeUndefined) == null ) && ! quickScan )
|
if( ( definitions.remove(toBeUndefined) == null ) && mode == ParserMode.COMPLETE_PARSE )
|
||||||
throw new ScannerException( "Attempt to #undef symbol " + toBeUndefined + " when it was never defined");
|
throw new ScannerException( "Attempt to #undef symbol " + toBeUndefined + " when it was never defined");
|
||||||
|
|
||||||
skipOverTextUntilNewline();
|
skipOverTextUntilNewline();
|
||||||
|
@ -993,7 +987,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
String error = getRestOfPreprocessorLine();
|
String error = getRestOfPreprocessorLine();
|
||||||
|
|
||||||
if (!quickScan) {
|
if (mode == ParserMode.COMPLETE_PARSE) {
|
||||||
throw new ScannerException("#error " + error);
|
throw new ScannerException("#error " + error);
|
||||||
}
|
}
|
||||||
c = getChar();
|
c = getChar();
|
||||||
|
@ -1379,7 +1373,7 @@ public class Scanner implements IScanner {
|
||||||
// the static instance we always use
|
// the static instance we always use
|
||||||
protected static endOfMacroTokenException endOfMacroToken = new endOfMacroTokenException();
|
protected static endOfMacroTokenException endOfMacroToken = new endOfMacroTokenException();
|
||||||
|
|
||||||
protected IToken nextTokenForStringizing() throws ScannerException, Parser.EndOfFile
|
public IToken nextTokenForStringizing() throws ScannerException, Parser.EndOfFile
|
||||||
{
|
{
|
||||||
int c = getChar();
|
int c = getChar();
|
||||||
StringBuffer tokenImage = new StringBuffer();
|
StringBuffer tokenImage = new StringBuffer();
|
||||||
|
@ -1648,7 +1642,7 @@ public class Scanner implements IScanner {
|
||||||
protected boolean evaluateExpression(String expression )
|
protected boolean evaluateExpression(String expression )
|
||||||
throws ScannerException {
|
throws ScannerException {
|
||||||
|
|
||||||
if( quickScan )
|
if( mode == ParserMode.QUICK_PARSE )
|
||||||
{
|
{
|
||||||
if( expression.trim().equals( "0" ) )
|
if( expression.trim().equals( "0" ) )
|
||||||
return false;
|
return false;
|
||||||
|
@ -1659,13 +1653,13 @@ public class Scanner implements IScanner {
|
||||||
Object expressionEvalResult = null;
|
Object expressionEvalResult = null;
|
||||||
try {
|
try {
|
||||||
ExpressionEvaluator evaluator = new ExpressionEvaluator();
|
ExpressionEvaluator evaluator = new ExpressionEvaluator();
|
||||||
Scanner trial =
|
IScanner trial =
|
||||||
new Scanner(
|
ParserFactory.createScanner(
|
||||||
// Semicolon makes this valid C (hopefully)
|
|
||||||
new StringReader(expression + ";"),
|
new StringReader(expression + ";"),
|
||||||
EXPRESSION,
|
EXPRESSION,
|
||||||
definitions);
|
definitions,
|
||||||
IParser parser = new Parser(trial, evaluator);
|
null, ParserMode.COMPLETE_PARSE );
|
||||||
|
IParser parser = ParserFactory.createParser(trial, evaluator, ParserMode.COMPLETE_PARSE );
|
||||||
parser.expression(null);
|
parser.expression(null);
|
||||||
|
|
||||||
expressionEvalResult = evaluator.getResult();
|
expressionEvalResult = evaluator.getResult();
|
||||||
|
@ -1792,7 +1786,7 @@ public class Scanner implements IScanner {
|
||||||
String f = fileName.toString();
|
String f = fileName.toString();
|
||||||
offset = contextStack.getCurrentContext().getOffset() - f.length() - 1; // -1 for the end quote
|
offset = contextStack.getCurrentContext().getOffset() - f.length() - 1; // -1 for the end quote
|
||||||
|
|
||||||
if( quickScan )
|
if( mode == ParserMode.QUICK_PARSE )
|
||||||
{
|
{
|
||||||
if( callback != null )
|
if( callback != null )
|
||||||
{
|
{
|
||||||
|
@ -1818,7 +1812,7 @@ public class Scanner implements IScanner {
|
||||||
String key = getNextIdentifier();
|
String key = getNextIdentifier();
|
||||||
int offset = contextStack.getCurrentContext().getOffset() - key.length() - contextStack.getCurrentContext().undoStackSize();
|
int offset = contextStack.getCurrentContext().getOffset() - key.length() - contextStack.getCurrentContext().undoStackSize();
|
||||||
|
|
||||||
if (!quickScan) {
|
if (mode == ParserMode.COMPLETE_PARSE) {
|
||||||
String checkForRedefinition = (String) definitions.get(key);
|
String checkForRedefinition = (String) definitions.get(key);
|
||||||
if (checkForRedefinition != null) {
|
if (checkForRedefinition != null) {
|
||||||
throw new ScannerException(
|
throw new ScannerException(
|
||||||
|
@ -1884,21 +1878,18 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
if( ! replacementString.equals( "" ) )
|
if( ! replacementString.equals( "" ) )
|
||||||
{
|
{
|
||||||
Scanner helperScanner = new Scanner();
|
IScanner helperScanner = ParserFactory.createScanner( new StringReader(replacementString), null, null, null, mode );
|
||||||
helperScanner.initialize(
|
|
||||||
new StringReader(replacementString),
|
|
||||||
null);
|
|
||||||
helperScanner.setTokenizingMacroReplacementList( true );
|
helperScanner.setTokenizingMacroReplacementList( true );
|
||||||
Token t = helperScanner.nextToken(false);
|
IToken t = helperScanner.nextToken(false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
//each # preprocessing token in the replacement list shall be followed
|
//each # preprocessing token in the replacement list shall be followed
|
||||||
//by a parameter as the next reprocessing token in the list
|
//by a parameter as the next reprocessing token in the list
|
||||||
if( t.type == tPOUND ){
|
if( t.getType() == tPOUND ){
|
||||||
macroReplacementTokens.add( t );
|
macroReplacementTokens.add( t );
|
||||||
t = helperScanner.nextToken(false);
|
t = helperScanner.nextToken(false);
|
||||||
int index = parameterIdentifiers.indexOf(t.image);
|
int index = parameterIdentifiers.indexOf(t.getImage());
|
||||||
if (index == -1 ) {
|
if (index == -1 ) {
|
||||||
//not found
|
//not found
|
||||||
if (throwExceptionOnBadPreprocessorSyntax)
|
if (throwExceptionOnBadPreprocessorSyntax)
|
||||||
|
@ -1985,7 +1976,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
protected Vector getMacroParameters (String params, boolean forStringizing) throws ScannerException {
|
protected Vector getMacroParameters (String params, boolean forStringizing) throws ScannerException {
|
||||||
|
|
||||||
Scanner tokenizer = new Scanner(new StringReader(params), TEXT, definitions);
|
IScanner tokenizer = ParserFactory.createScanner(new StringReader(params), TEXT, definitions, null, mode );
|
||||||
Vector parameterValues = new Vector();
|
Vector parameterValues = new Vector();
|
||||||
Token t = null;
|
Token t = null;
|
||||||
String str = new String();
|
String str = new String();
|
||||||
|
|
|
@ -61,9 +61,9 @@ public class Token implements IToken {
|
||||||
return other.getOffset() + other.getLength() - getOffset();
|
return other.getOffset() + other.getLength() - getOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Token next;
|
private IToken next;
|
||||||
public Token getNext() { return next; }
|
public IToken getNext() { return next; }
|
||||||
public void setNext(Token t) { next = t; }
|
public void setNext(IToken t) { next = t; }
|
||||||
|
|
||||||
public boolean looksLikeExpression()
|
public boolean looksLikeExpression()
|
||||||
{
|
{
|
||||||
|
@ -141,4 +141,11 @@ public class Token implements IToken {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.IToken#setImage()
|
||||||
|
*/
|
||||||
|
public void setImage( String i ) {
|
||||||
|
image = i;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class ASTClassSpecifier implements IASTFClassSpecifier, IPSTSymbolExtensi
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getCurrentVisiblity()
|
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getCurrentVisiblity()
|
||||||
*/
|
*/
|
||||||
public AccessVisibility getCurrentVisiblity() {
|
public AccessVisibility getCurrentVisibilityMode() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class ASTClassSpecifier extends ASTDeclaration implements IASTQClassSpeci
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getCurrentVisiblity()
|
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getCurrentVisiblity()
|
||||||
*/
|
*/
|
||||||
public AccessVisibility getCurrentVisiblity() {
|
public AccessVisibility getCurrentVisibilityMode() {
|
||||||
return access;
|
return access;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2003-06-23 John Camelon
|
||||||
|
Updated Factory infrastructure, constructors, etc.
|
||||||
|
Introduced Preprocessor class for transitive closure calc. client.
|
||||||
|
|
||||||
2003-06-20 Sean Evoy
|
2003-06-20 Sean Evoy
|
||||||
Moved the ManagedBuildInfo extension point to the plugin file in org.eclipse.cdt.core.tests
|
Moved the ManagedBuildInfo extension point to the plugin file in org.eclipse.cdt.core.tests
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.core.parser.tests;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
@ -21,7 +22,8 @@ import junit.framework.AssertionFailedError;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,12 +53,8 @@ public class AutomatedTest extends AutomatedFramework {
|
||||||
FileInputStream stream = new FileInputStream( file );
|
FileInputStream stream = new FileInputStream( file );
|
||||||
|
|
||||||
String filePath = file.getCanonicalPath();
|
String filePath = file.getCanonicalPath();
|
||||||
String nature = (String)natures.get( filePath );
|
parser = ParserFactory.createParser( ParserFactory.createScanner( new InputStreamReader (stream), filePath, null, null, ParserMode.QUICK_PARSE ), nullCallback, ParserMode.QUICK_PARSE);
|
||||||
|
parser.setCppNature( ((String)natures.get( filePath )).equalsIgnoreCase("cpp") );
|
||||||
boolean cppNature = nature.equalsIgnoreCase("cpp");
|
|
||||||
|
|
||||||
parser = new Parser( stream, nullCallback, true);
|
|
||||||
parser.setCppNature( cppNature );
|
|
||||||
parser.mapLineNumbers(true);
|
parser.mapLineNumbers(true);
|
||||||
|
|
||||||
assertTrue( parser.parse() );
|
assertTrue( parser.parse() );
|
||||||
|
|
|
@ -10,12 +10,15 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests;
|
package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
||||||
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
|
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,7 +39,8 @@ public class BaseDOMTest extends TestCase {
|
||||||
|
|
||||||
public TranslationUnit parse(String code, boolean quickParse, boolean throwOnError ) throws Exception {
|
public TranslationUnit parse(String code, boolean quickParse, boolean throwOnError ) throws Exception {
|
||||||
DOMBuilder domBuilder = new DOMBuilder();
|
DOMBuilder domBuilder = new DOMBuilder();
|
||||||
IParser parser = new Parser(code, domBuilder, quickParse );
|
ParserMode mode = quickParse ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
|
||||||
|
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, null, null, mode ), domBuilder, mode );
|
||||||
if( ! parser.parse() )
|
if( ! parser.parse() )
|
||||||
if( throwOnError ) throw new ParserException( "Parse failure" );
|
if( throwOnError ) throw new ParserException( "Parse failure" );
|
||||||
else domBuilder.getTranslationUnit().setParseSuccessful( false );
|
else domBuilder.getTranslationUnit().setParseSuccessful( false );
|
||||||
|
|
|
@ -15,10 +15,12 @@ import java.io.StringReader;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerException;
|
import org.eclipse.cdt.core.parser.ScannerException;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||||
import org.eclipse.cdt.internal.core.parser.Scanner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -26,7 +28,7 @@ import org.eclipse.cdt.internal.core.parser.Scanner;
|
||||||
*/
|
*/
|
||||||
public class BaseScannerTest extends TestCase {
|
public class BaseScannerTest extends TestCase {
|
||||||
|
|
||||||
protected Scanner scanner;
|
protected IScanner scanner;
|
||||||
|
|
||||||
public BaseScannerTest( String x )
|
public BaseScannerTest( String x )
|
||||||
{
|
{
|
||||||
|
@ -35,8 +37,7 @@ public class BaseScannerTest extends TestCase {
|
||||||
|
|
||||||
public void initializeScanner(String input)
|
public void initializeScanner(String input)
|
||||||
{
|
{
|
||||||
scanner= new Scanner();
|
scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", null, null, ParserMode.COMPLETE_PARSE );
|
||||||
scanner.initialize( new StringReader(input),"TEXT");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fullyTokenize() throws Exception
|
public int fullyTokenize() throws Exception
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package org.eclipse.cdt.core.parser.tests;
|
package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.ExpressionEvaluator;
|
import org.eclipse.cdt.internal.core.parser.ExpressionEvaluator;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
|
||||||
|
|
||||||
public class ExprEvalTest extends TestCase {
|
public class ExprEvalTest extends TestCase {
|
||||||
|
|
||||||
|
@ -20,7 +22,7 @@ public class ExprEvalTest extends TestCase {
|
||||||
|
|
||||||
public void runTest(String code, int expectedValue) throws Exception {
|
public void runTest(String code, int expectedValue) throws Exception {
|
||||||
ExpressionEvaluator evaluator = new ExpressionEvaluator();
|
ExpressionEvaluator evaluator = new ExpressionEvaluator();
|
||||||
IParser parser = new Parser(code, evaluator);
|
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, null, null, null ), evaluator, null);;
|
||||||
parser.expression(null);
|
parser.expression(null);
|
||||||
assertEquals(expectedValue, ((Integer)evaluator.getResult()).intValue());
|
assertEquals(expectedValue, ((Integer)evaluator.getResult()).intValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,16 @@ import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -234,7 +237,8 @@ public class FractionalAutomatedTest extends AutomatedFramework {
|
||||||
public void run(){
|
public void run(){
|
||||||
try{
|
try{
|
||||||
result = null;
|
result = null;
|
||||||
Parser parser = new Parser( code, nullCallback, true);
|
IParser parser = ParserFactory.createParser(
|
||||||
|
ParserFactory.createScanner( new StringReader( code ), null, null, null, ParserMode.QUICK_PARSE ), nullCallback, ParserMode.QUICK_PARSE);
|
||||||
parser.setCppNature( cppNature );
|
parser.setCppNature( cppNature );
|
||||||
parser.mapLineNumbers(true);
|
parser.mapLineNumbers(true);
|
||||||
parser.parse();
|
parser.parse();
|
||||||
|
|
|
@ -13,14 +13,17 @@ package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Reader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
||||||
import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier;
|
import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier;
|
||||||
|
@ -29,7 +32,6 @@ import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
|
||||||
import org.eclipse.cdt.internal.core.dom.SimpleDeclaration;
|
import org.eclipse.cdt.internal.core.dom.SimpleDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.dom.TemplateDeclaration;
|
import org.eclipse.cdt.internal.core.dom.TemplateDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||||
import org.eclipse.cdt.internal.core.parser.Scanner;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,9 +55,7 @@ public class LineNumberTest extends TestCase {
|
||||||
|
|
||||||
public void testLineNos() throws Exception
|
public void testLineNos() throws Exception
|
||||||
{
|
{
|
||||||
Scanner scanner = new Scanner();
|
IScanner scanner = ParserFactory.createScanner( new StringReader( "int x = 3;\n foo\nfire\nfoe " ), "string", null, null, null );
|
||||||
Reader reader = new StringReader( "int x = 3;\n foo\nfire\nfoe ");
|
|
||||||
scanner.initialize( reader, "string");
|
|
||||||
scanner.mapLineNumbers(true);
|
scanner.mapLineNumbers(true);
|
||||||
IToken t = scanner.nextToken();
|
IToken t = scanner.nextToken();
|
||||||
assertEquals( t.getType(), IToken.t_int );
|
assertEquals( t.getType(), IToken.t_int );
|
||||||
|
@ -92,7 +92,7 @@ public class LineNumberTest extends TestCase {
|
||||||
public void testDOMLineNos() throws Exception
|
public void testDOMLineNos() throws Exception
|
||||||
{
|
{
|
||||||
DOMBuilder domBuilder = new DOMBuilder();
|
DOMBuilder domBuilder = new DOMBuilder();
|
||||||
IParser parser = new Parser( fileIn, domBuilder, true );
|
IParser parser = ParserFactory.createParser( ParserFactory.createScanner( new InputStreamReader( fileIn ), null, null, null, ParserMode.QUICK_PARSE ), domBuilder, ParserMode.QUICK_PARSE );
|
||||||
parser.mapLineNumbers(true);
|
parser.mapLineNumbers(true);
|
||||||
if( ! parser.parse() ) fail( "Parse of file failed");
|
if( ! parser.parse() ) fail( "Parse of file failed");
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerException;
|
import org.eclipse.cdt.core.parser.ScannerException;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||||
import org.eclipse.cdt.internal.core.parser.Token;
|
import org.eclipse.cdt.internal.core.parser.Token;
|
||||||
|
@ -851,7 +852,7 @@ public class ScannerTestCase extends BaseScannerTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
initializeScanner( "#if X + 5 < 7\n int found = 1;\n#endif" );
|
initializeScanner( "#if X + 5 < 7\n int found = 1;\n#endif" );
|
||||||
scanner.setQuickScan( true );
|
scanner.setMode( ParserMode.QUICK_PARSE );
|
||||||
validateToken( IToken.t_int );
|
validateToken( IToken.t_int );
|
||||||
validateIdentifier( "found" );
|
validateIdentifier( "found" );
|
||||||
validateToken( IToken.tASSIGN );
|
validateToken( IToken.tASSIGN );
|
||||||
|
@ -868,7 +869,7 @@ public class ScannerTestCase extends BaseScannerTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
initializeScanner( "#if 0\n int error = 666;\n#endif" );
|
initializeScanner( "#if 0\n int error = 666;\n#endif" );
|
||||||
scanner.setQuickScan( true );
|
scanner.setMode( ParserMode.COMPLETE_PARSE );
|
||||||
validateEOF();
|
validateEOF();
|
||||||
}
|
}
|
||||||
catch( ScannerException se )
|
catch( ScannerException se )
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
@ -22,8 +23,9 @@ import junit.framework.AssertionFailedError;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,7 +202,8 @@ public class TortureTest extends FractionalAutomatedTest {
|
||||||
public void run(){
|
public void run(){
|
||||||
try {
|
try {
|
||||||
DOMBuilder domBuilder = new DOMBuilder();
|
DOMBuilder domBuilder = new DOMBuilder();
|
||||||
parser = new Parser(code.toString(), domBuilder, quickParse);
|
IParser parser = ParserFactory.createParser(
|
||||||
|
ParserFactory.createScanner( new StringReader( code ), null, null, null, ParserMode.QUICK_PARSE ), nullCallback, ParserMode.QUICK_PARSE);
|
||||||
|
|
||||||
parser.setCppNature(cppNature);
|
parser.setCppNature(cppNature);
|
||||||
parser.mapLineNumbers(true);
|
parser.mapLineNumbers(true);
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2003-06-23 John Camelon
|
||||||
|
Updated Factory infrastructure, constructors, etc.
|
||||||
|
Introduced Preprocessor class for transitive closure calc. client.
|
||||||
|
|
||||||
2003-06-20 Sean Evoy
|
2003-06-20 Sean Evoy
|
||||||
Added (again) the icons required for the new managed project wizard and property pages
|
Added (again) the icons required for the new managed project wizard and property pages
|
||||||
* icons/full/build16/config-command.gif
|
* icons/full/build16/config-command.gif
|
||||||
|
|
|
@ -11,10 +11,14 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.compare;
|
package org.eclipse.cdt.internal.ui.compare;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.dom.ClassKey;
|
import org.eclipse.cdt.internal.core.dom.ClassKey;
|
||||||
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
||||||
|
@ -31,7 +35,6 @@ import org.eclipse.cdt.internal.core.dom.TemplateDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
|
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.dom.TypeSpecifier;
|
import org.eclipse.cdt.internal.core.dom.TypeSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.Name;
|
import org.eclipse.cdt.internal.core.parser.Name;
|
||||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
|
||||||
import org.eclipse.cdt.internal.parser.IStructurizerCallback;
|
import org.eclipse.cdt.internal.parser.IStructurizerCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,8 +57,7 @@ public class ComparatorModelBuilder {
|
||||||
public void parse() {
|
public void parse() {
|
||||||
DOMBuilder domBuilder = new DOMBuilder();
|
DOMBuilder domBuilder = new DOMBuilder();
|
||||||
try {
|
try {
|
||||||
|
IParser parser = ParserFactory.createParser(ParserFactory.createScanner( new StringReader( code ), null, null, null, ParserMode.QUICK_PARSE ), domBuilder, ParserMode.QUICK_PARSE);
|
||||||
Parser parser = new Parser(code, domBuilder, true);
|
|
||||||
parser.parse();
|
parser.parse();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
callback.reportError(e);
|
callback.reportError(e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue