mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixed 69791 [Parser] Indexer complains about va_list
Fixed 72529 [Scanner] Separate GCC Extension from Scanner2 Fixed 72725 [Scanner] Parser missteps on \r in escaped macros Cleaned up IScannerExtension & implementation. Added GCCExtensionTestSuite to ParserTestSuite. Updated failed tests & restructured tests.
This commit is contained in:
parent
506adaf4b1
commit
9a9ffd59c2
27 changed files with 545 additions and 532 deletions
|
@ -143,18 +143,6 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
|
|||
// assertAllReferences( 4 /*should be 5 */, createTaskList( new Task( cl /* , 2 */ ), new Task( a), new Task( pm), new Task( f2)));
|
||||
}
|
||||
|
||||
public void testPredefinedSymbol_bug69791() throws Exception {
|
||||
// GNU builtin type __builtin_va_list
|
||||
try {
|
||||
parse("typedef __builtin_va_list __gnuc_va_list; \n");//$NON-NLS-1$
|
||||
fail();
|
||||
} catch ( ParserException e ){
|
||||
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
|
||||
}
|
||||
// Iterator i = parse("typedef unsigned char byte; \n").getDeclarations();;//$NON-NLS-1$
|
||||
// IASTTypedefDeclaration td = (IASTTypedefDeclaration) i.next();
|
||||
// assertFalse(i.hasNext());
|
||||
}
|
||||
|
||||
public void testUsingOverloadedName_bug71317() throws Exception {
|
||||
// using a globaly defined function overloaded in a namespace
|
||||
|
|
|
@ -1498,47 +1498,6 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
assertAllReferences( 1, createTaskList( new Task( SD_01 )));
|
||||
}
|
||||
|
||||
public void testBug39697() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "__asm__( \"CODE\" );\n" ); //$NON-NLS-1$
|
||||
writer.write( "__inline__ int foo() { return 4; }\n"); //$NON-NLS-1$
|
||||
writer.write( "__const__ int constInt;\n"); //$NON-NLS-1$
|
||||
writer.write( "__volatile__ int volInt;\n"); //$NON-NLS-1$
|
||||
writer.write( "__signed__ int signedInt;\n"); //$NON-NLS-1$
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
IASTASMDefinition asmDefinition = (IASTASMDefinition) i.next();
|
||||
assertEquals( asmDefinition.getBody(), "CODE"); //$NON-NLS-1$
|
||||
IASTFunction foo = (IASTFunction) i.next();
|
||||
assertTrue( foo.isInline() );
|
||||
IASTVariable constInt = (IASTVariable) i.next();
|
||||
assertTrue( constInt.getAbstractDeclaration().isConst());
|
||||
IASTVariable volInt = (IASTVariable) i.next();
|
||||
assertTrue( volInt.getAbstractDeclaration().isVolatile() );
|
||||
IASTVariable signedInt = (IASTVariable) i.next();
|
||||
assertTrue( ((IASTSimpleTypeSpecifier) signedInt.getAbstractDeclaration().getTypeSpecifier()).isSigned() );
|
||||
assertFalse( i.hasNext() );
|
||||
for( int j = 0; j < 2; ++j )
|
||||
{
|
||||
writer = new StringWriter();
|
||||
writer.write( "int * __restrict__ resPointer1;\n"); //$NON-NLS-1$
|
||||
writer.write( "int * __restrict resPointer2;\n"); //$NON-NLS-1$
|
||||
i = parse( writer.toString(), true, ((j == 0 )? ParserLanguage.C : ParserLanguage.CPP) ).getDeclarations();
|
||||
int count = 0;
|
||||
while( i.hasNext() )
|
||||
{
|
||||
++count;
|
||||
IASTVariable resPointer = (IASTVariable) i.next();
|
||||
Iterator pOps = resPointer.getAbstractDeclaration().getPointerOperators();
|
||||
assertTrue( pOps.hasNext() );
|
||||
ASTPointerOperator op = (ASTPointerOperator) pOps.next();
|
||||
assertFalse( pOps.hasNext() );
|
||||
assertEquals( op, ASTPointerOperator.RESTRICT_POINTER );
|
||||
}
|
||||
|
||||
assertEquals( count, 2 );
|
||||
}
|
||||
}
|
||||
public void testBug59149() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
|
|
|
@ -668,7 +668,10 @@ public class CompletionParseTest extends CompletionParseBaseTest {
|
|||
Set results = new HashSet();
|
||||
results.add( "aInteger"); //$NON-NLS-1$
|
||||
if( i == 0 )
|
||||
{
|
||||
results.add( "NMS"); //$NON-NLS-1$
|
||||
results.add( "__builtin_va_list "); //$NON-NLS-1$
|
||||
}
|
||||
validateLookupResult(result, results );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,18 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCSimpleTypeSpecifier;
|
||||
|
@ -24,12 +30,12 @@ import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCSimpleTypeSpecifier;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class GCCCompleteExtensionsParseTest extends CompleteParseBaseTest {
|
||||
public class GCCCompleteParseExtensionsTest extends CompleteParseBaseTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public GCCCompleteExtensionsParseTest() {
|
||||
public GCCCompleteParseExtensionsTest() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
@ -37,7 +43,7 @@ public class GCCCompleteExtensionsParseTest extends CompleteParseBaseTest {
|
|||
/**
|
||||
* @param name
|
||||
*/
|
||||
public GCCCompleteExtensionsParseTest(String name) {
|
||||
public GCCCompleteParseExtensionsTest(String name) {
|
||||
super(name);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
@ -75,4 +81,52 @@ public class GCCCompleteExtensionsParseTest extends CompleteParseBaseTest {
|
|||
assertEquals( ASTUtil.getExpressionString( exp ), "a >? b" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testPredefinedSymbol_bug69791() throws Exception {
|
||||
Iterator i = parse("typedef __builtin_va_list __gnuc_va_list; \n").getDeclarations();//$NON-NLS-1$
|
||||
IASTTypedefDeclaration td = (IASTTypedefDeclaration) i.next();
|
||||
assertFalse(i.hasNext());
|
||||
}
|
||||
|
||||
public void testBug39697() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "__asm__( \"CODE\" );\n" ); //$NON-NLS-1$
|
||||
writer.write( "__inline__ int foo() { return 4; }\n"); //$NON-NLS-1$
|
||||
writer.write( "__const__ int constInt;\n"); //$NON-NLS-1$
|
||||
writer.write( "__volatile__ int volInt;\n"); //$NON-NLS-1$
|
||||
writer.write( "__signed__ int signedInt;\n"); //$NON-NLS-1$
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
IASTASMDefinition asmDefinition = (IASTASMDefinition) i.next();
|
||||
assertEquals( asmDefinition.getBody(), "CODE"); //$NON-NLS-1$
|
||||
IASTFunction foo = (IASTFunction) i.next();
|
||||
assertTrue( foo.isInline() );
|
||||
IASTVariable constInt = (IASTVariable) i.next();
|
||||
assertTrue( constInt.getAbstractDeclaration().isConst());
|
||||
IASTVariable volInt = (IASTVariable) i.next();
|
||||
assertTrue( volInt.getAbstractDeclaration().isVolatile() );
|
||||
IASTVariable signedInt = (IASTVariable) i.next();
|
||||
assertTrue( ((IASTSimpleTypeSpecifier) signedInt.getAbstractDeclaration().getTypeSpecifier()).isSigned() );
|
||||
assertFalse( i.hasNext() );
|
||||
for( int j = 0; j < 2; ++j )
|
||||
{
|
||||
writer = new StringWriter();
|
||||
writer.write( "int * __restrict__ resPointer1;\n"); //$NON-NLS-1$
|
||||
writer.write( "int * __restrict resPointer2;\n"); //$NON-NLS-1$
|
||||
i = parse( writer.toString(), true, ((j == 0 )? ParserLanguage.C : ParserLanguage.CPP) ).getDeclarations();
|
||||
int count = 0;
|
||||
while( i.hasNext() )
|
||||
{
|
||||
++count;
|
||||
IASTVariable resPointer = (IASTVariable) i.next();
|
||||
Iterator pOps = resPointer.getAbstractDeclaration().getPointerOperators();
|
||||
assertTrue( pOps.hasNext() );
|
||||
ASTPointerOperator op = (ASTPointerOperator) pOps.next();
|
||||
assertFalse( pOps.hasNext() );
|
||||
assertEquals( op, ASTPointerOperator.RESTRICT_POINTER );
|
||||
}
|
||||
|
||||
assertEquals( count, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -26,7 +26,8 @@ public class GCCParserExtensionTestSuite extends TestCase {
|
|||
TestSuite suite= new TestSuite(GCCParserExtensionTestSuite.class.getName());
|
||||
suite.addTestSuite( GCCScannerExtensionsTest.class );
|
||||
suite.addTestSuite( GCCQuickParseExtensionsTest.class );
|
||||
suite.addTestSuite( GCCCompleteExtensionsParseTest.class );
|
||||
suite.addTestSuite( GCCCompleteParseExtensionsTest.class );
|
||||
suite.addTestSuite( GCCSelectionParseExtensionsTest.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.io.StringWriter;
|
|||
import java.io.Writer;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
|
@ -89,4 +90,19 @@ public class GCCQuickParseExtensionsTest extends BaseASTTest {
|
|||
parse("int c = a >? b;"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testBug39554() throws Exception
|
||||
{
|
||||
parse("_Pragma(\"foobar\")", true, true, ParserLanguage.C ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testBug39704B() throws Exception
|
||||
{
|
||||
IASTVariable d = (IASTVariable)assertSoleDeclaration("extern int (* import) (void) __attribute__((dllimport));"); //$NON-NLS-1$
|
||||
assertEquals( d.getName(), "import"); // false assertion //$NON-NLS-1$
|
||||
}
|
||||
public void testBug39704C() throws Exception
|
||||
{
|
||||
IASTFunction f = (IASTFunction)assertSoleDeclaration("int func2 (void) __attribute__((dllexport));"); //$NON-NLS-1$
|
||||
assertEquals( f.getName(), "func2"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002-2004 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.StringWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class GCCSelectionParseExtensionsTest extends SelectionParseBaseTest {
|
||||
|
||||
public void testBug43021() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "extern int johnc(__const char *__restrict __format, ...);\n" ); //$NON-NLS-1$
|
||||
writer.write( "void m() {johnc(\"HI\");}" ); //$NON-NLS-1$
|
||||
String code = writer.toString();
|
||||
int startIndex = code.indexOf( "{johnc") + 1; //$NON-NLS-1$
|
||||
IASTNode node = parse( code, startIndex, startIndex + 5 );
|
||||
assertNotNull( node );
|
||||
}
|
||||
}
|
|
@ -47,10 +47,8 @@ public class ParserTestSuite extends TestCase {
|
|||
suite.addTestSuite( CompleteParseASTTemplateTest.class );
|
||||
suite.addTestSuite( StructuralParseTest.class );
|
||||
suite.addTestSuite( ObjectMapTest.class );
|
||||
|
||||
suite.addTest( CompleteParsePluginTest.suite() );
|
||||
|
||||
// suite.addTest( GCCParserExtensionTestSuite.suite() );
|
||||
suite.addTest( GCCParserExtensionTestSuite.suite() );
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -804,10 +804,6 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
}
|
||||
|
||||
|
||||
public void testBug39554() throws Exception
|
||||
{
|
||||
parse("_Pragma(\"foobar\")", true, true, ParserLanguage.C ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testBug36702() throws Exception
|
||||
{
|
||||
|
@ -2130,16 +2126,7 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
|
||||
|
||||
|
||||
public void testBug39704B() throws Exception
|
||||
{
|
||||
IASTVariable d = (IASTVariable)assertSoleDeclaration("extern int (* import) (void) __attribute__((dllimport));"); //$NON-NLS-1$
|
||||
assertEquals( d.getName(), "import"); // false assertion //$NON-NLS-1$
|
||||
}
|
||||
public void testBug39704C() throws Exception
|
||||
{
|
||||
IASTFunction f = (IASTFunction)assertSoleDeclaration("int func2 (void) __attribute__((dllexport));"); //$NON-NLS-1$
|
||||
assertEquals( f.getName(), "func2"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -296,16 +296,7 @@ public class SelectionParseTest extends SelectionParseBaseTest {
|
|||
parse( code, startIndex, startIndex + 8 );
|
||||
}
|
||||
|
||||
public void testBug43021() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "extern int johnc(__const char *__restrict __format, ...);\n" ); //$NON-NLS-1$
|
||||
writer.write( "void m() {johnc(\"HI\");}" ); //$NON-NLS-1$
|
||||
String code = writer.toString();
|
||||
int startIndex = code.indexOf( "{johnc") + 1; //$NON-NLS-1$
|
||||
IASTNode node = parse( code, startIndex, startIndex + 5 );
|
||||
assertNotNull( node );
|
||||
}
|
||||
|
||||
|
||||
public void testBug68527() throws Exception
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.core.parser.tests.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IGCCToken;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -33,4 +34,12 @@ public class GCCScannerExtensionsTest extends BaseScanner2Test {
|
|||
validateEOF();
|
||||
}
|
||||
|
||||
public void test__attribute__() throws Exception {
|
||||
initializeScanner(
|
||||
"#define __cdecl __attribute__((cdecl))\n" + //$NON-NLS-1$
|
||||
"__cdecl;"); //$NON-NLS-1$
|
||||
validateToken(IToken.tSEMI);
|
||||
validateEOF();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -399,7 +399,7 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
validateEOF();
|
||||
|
||||
initializeScanner("#ifndef DEFINED\n#define DEFINED 100\n#endif\nint count = DEFINED;"); //$NON-NLS-1$
|
||||
scanner.addDefinition("DEFINED", "101"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("DEFINED", "101"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateDefinition("DEFINED", "101"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateToken(IToken.t_int);
|
||||
validateIdentifier("count"); //$NON-NLS-1$
|
||||
|
@ -418,6 +418,15 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @param string2
|
||||
*/
|
||||
private void addDefinition(String string, String string2) {
|
||||
scanner.addDefinition( string.toCharArray(), string2.toCharArray() );
|
||||
}
|
||||
|
||||
|
||||
public void testMultipleLines() throws Exception
|
||||
{
|
||||
Writer code = new StringWriter();
|
||||
|
@ -456,7 +465,7 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
validateToken(IToken.tSEMI);
|
||||
validateEOF();
|
||||
initializeScanner("#ifndef ONE\n#define ONE 1\n#ifdef TWO\n#define THREE ONE + TWO\n#endif\n#endif\nint three(THREE);"); //$NON-NLS-1$
|
||||
scanner.addDefinition("TWO", "2"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("TWO", "2"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateToken(IToken.t_int);
|
||||
validateDefinition("ONE", "1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateDefinition("TWO", "2"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -475,7 +484,7 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
validateDefinition("FOO", "4"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
initializeScanner("#ifndef FOO\n#define FOO 4\n#else\n#undef FOO\n#define FOO 6\n#endif"); //$NON-NLS-1$
|
||||
scanner.addDefinition("FOO", "2"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("FOO", "2"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateEOF();
|
||||
validateDefinition("FOO", "6"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
|
@ -502,20 +511,20 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
"# endif\n" + //$NON-NLS-1$
|
||||
"#endif\n"); //$NON-NLS-1$" +
|
||||
|
||||
scanner.addDefinition("ONE", "one"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("ONE", "one"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateEOF();
|
||||
validateDefinition("ONE", "one"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateDefinition("TWO", "ONE + ONE"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
initializeScanner("#ifndef ONE\n# define ONE 1\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#else\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#endif\n"); //$NON-NLS-1$
|
||||
scanner.addDefinition("ONE", "one"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
scanner.addDefinition("TWO", "two"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("ONE", "one"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("TWO", "two"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateEOF();
|
||||
validateDefinition("ONE", "one"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateDefinition("TWO", "2"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
initializeScanner("#ifndef ONE\n# define ONE 1\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#else\n# ifndef TWO\n# define TWO ONE + ONE \n# else\n# undef TWO\n# define TWO 2 \n# endif\n#endif\n"); //$NON-NLS-1$
|
||||
scanner.addDefinition("TWO", "two"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("TWO", "two"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateEOF();
|
||||
validateDefinition("ONE", "1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateDefinition("TWO", "2"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -540,9 +549,9 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
validateDefinition("Z", "X + Y"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
initializeScanner("#if T < 20\n#define Z T + 1\n#endif"); //$NON-NLS-1$
|
||||
scanner.addDefinition("X", "5"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
scanner.addDefinition("Y", "7"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
scanner.addDefinition("T", "X + Y"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("X", "5"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("Y", "7"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("T", "X + Y"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateEOF();
|
||||
validateDefinition("X", "5"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateDefinition("Y", "7"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -577,7 +586,7 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
"#define MISTAKE 1\n" + //$NON-NLS-1$
|
||||
"#error Five does not equal 10\n" + //$NON-NLS-1$
|
||||
"#endif\n", ParserMode.QUICK_PARSE, callback); //$NON-NLS-1$
|
||||
scanner.addDefinition("FIVE", "55"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("FIVE", "55"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateEOF();
|
||||
validateDefinition("FIVE", "55"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
validateDefinition("TEN", "2 * FIVE"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -588,11 +597,11 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
{
|
||||
initializeScanner("#if ((( FOUR / TWO ) * THREE )< FIVE )\n#error 6 is not less than 5 \n#endif\n#if ( ( FIVE * ONE ) != (( (FOUR) + ONE ) * ONE ) )\n#error 5 should equal 5\n#endif \n"); //$NON-NLS-1$
|
||||
|
||||
scanner.addDefinition("ONE", "1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
scanner.addDefinition("TWO", "(ONE + ONE)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
scanner.addDefinition("THREE", "(TWO + ONE)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
scanner.addDefinition("FOUR", "(TWO * TWO)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
scanner.addDefinition("FIVE", "(THREE + TWO)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("ONE", "1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("TWO", "(ONE + ONE)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("THREE", "(TWO + ONE)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("FOUR", "(TWO * TWO)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition("FIVE", "(THREE + TWO)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
validateEOF();
|
||||
validateDefinition("ONE", "1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -922,18 +931,18 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
switch( i )
|
||||
{
|
||||
case 0:
|
||||
scanner.addDefinition( "THIS", "1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
scanner.addDefinition( "THAT", "1" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition( "THIS", "1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition( "THAT", "1" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
break;
|
||||
case 1:
|
||||
scanner.addDefinition( "THIS", "1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
scanner.addDefinition( "THAT", "0" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition( "THIS", "1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition( "THAT", "0" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
break;
|
||||
case 2:
|
||||
scanner.addDefinition( "THAT", "1" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition( "THAT", "1" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
break;
|
||||
case 3:
|
||||
scanner.addDefinition( "THAT", "0" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
addDefinition( "THAT", "0" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1595,13 +1604,7 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
validateEOF();
|
||||
}
|
||||
|
||||
public void test__attribute__() throws Exception {
|
||||
initializeScanner(
|
||||
"#define __cdecl __attribute__((cdecl))\n" + //$NON-NLS-1$
|
||||
"__cdecl;"); //$NON-NLS-1$
|
||||
validateToken(IToken.tSEMI);
|
||||
validateEOF();
|
||||
}
|
||||
|
||||
|
||||
public void testUndef() throws Exception {
|
||||
initializeScanner(
|
||||
|
@ -1740,4 +1743,33 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
initializeScanner( writer.toString() );
|
||||
fullyTokenize();
|
||||
}
|
||||
|
||||
public void testBug72997() throws Exception
|
||||
{
|
||||
initializeScanner( "'\\\\'"); //$NON-NLS-1$
|
||||
validateChar( "\\\\"); //$NON-NLS-1$
|
||||
validateEOF();
|
||||
}
|
||||
|
||||
public void testBug72725() throws Exception
|
||||
{
|
||||
for( int i = 0; i < 2; ++i )
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( "#define a \\" ); //$NON-NLS-1$
|
||||
if( i == 0 )
|
||||
buffer.append( "\r"); //$NON-NLS-1$
|
||||
buffer.append( "\n"); //$NON-NLS-1$
|
||||
buffer.append( "long macro stuff" ); //$NON-NLS-1$
|
||||
if( i == 0 )
|
||||
buffer.append( "\r"); //$NON-NLS-1$
|
||||
buffer.append( "\n"); //$NON-NLS-1$
|
||||
|
||||
Callback callback = new Callback(ParserMode.COMPLETE_PARSE);
|
||||
initializeScanner( buffer.toString(), ParserMode.COMPLETE_PARSE, callback );
|
||||
validateEOF();
|
||||
assertTrue( callback.problems.isEmpty() );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,5 +18,8 @@ public class GCCKeywords {
|
|||
|
||||
public static final String TYPEOF = "typeof"; //$NON-NLS-1$
|
||||
public static final String __ALIGNOF__ = "__alignof__"; //$NON-NLS-1$
|
||||
|
||||
|
||||
public static final char [] cpTYPEOF = TYPEOF.toCharArray();
|
||||
public static final char [] cp__ALIGNOF__ = __ALIGNOF__.toCharArray();
|
||||
|
||||
}
|
||||
|
|
|
@ -20,15 +20,6 @@ import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
|||
*
|
||||
*/
|
||||
public interface IScanner {
|
||||
|
||||
public static final String __CPLUSPLUS = "__cplusplus"; //$NON-NLS-1$
|
||||
public static final String __STDC_VERSION__ = "__STDC_VERSION__"; //$NON-NLS-1$
|
||||
public static final String __STDC_HOSTED__ = "__STDC_HOSTED__"; //$NON-NLS-1$
|
||||
public static final String __STDC__ = "__STDC__"; //$NON-NLS-1$
|
||||
public static final String __FILE__ = "__FILE__"; //$NON-NLS-1$
|
||||
public static final String __TIME__ = "__TIME__"; //$NON-NLS-1$
|
||||
public static final String __DATE__ = "__DATE__"; //$NON-NLS-1$
|
||||
public static final String __LINE__ = "__LINE__"; //$NON-NLS-1$
|
||||
|
||||
public static final int tPOUNDPOUND = -6;
|
||||
public static final int tPOUND = -7;
|
||||
|
@ -36,7 +27,7 @@ public interface IScanner {
|
|||
public void setOffsetBoundary( int offset );
|
||||
public void setASTFactory( IASTFactory f );
|
||||
|
||||
public void addDefinition(String key, String value);
|
||||
public void addDefinition(char[] key, char[] value);
|
||||
public Map getDefinitions();
|
||||
public String[] getIncludePaths();
|
||||
|
||||
|
|
|
@ -15,8 +15,10 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||
|
@ -69,5 +71,7 @@ public interface IASTFactoryExtension {
|
|||
|
||||
public boolean overrideCreateDesignatorMethod( IASTDesignator.DesignatorKind kind );
|
||||
public IASTDesignator createDesignator( IASTDesignator.DesignatorKind kind, IASTExpression constantExpression, IToken fieldIdentifier, Map extensionParms );
|
||||
|
||||
public void initialize( IASTFactory factory, IASTCompilationUnit compilationUnit );
|
||||
|
||||
}
|
||||
|
|
|
@ -19,30 +19,15 @@ import org.eclipse.cdt.internal.core.parser.scanner2.IScannerData;
|
|||
*/
|
||||
public interface IScannerExtension {
|
||||
|
||||
public String initializeMacroValue( IScannerData scannerData, String original );
|
||||
public char[] initializeMacroValue( IScannerData scannerData, char[] original );
|
||||
public void setupBuiltInMacros(IScannerData scannerData);
|
||||
|
||||
public boolean canHandlePreprocessorDirective( String directive );
|
||||
public void handlePreprocessorDirective( IScannerData scannerData, String directive, String restOfLine );
|
||||
|
||||
public boolean isExtensionKeyword(ParserLanguage language, String tokenImage);
|
||||
public IToken createExtensionToken(IScannerData scannerData, String image);
|
||||
public boolean isExtensionKeyword(ParserLanguage language, char[] tokenImage);
|
||||
public IToken createExtensionToken(IScannerData scannerData, char[] image);
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean offersDifferentIdentifierCharacters();
|
||||
|
||||
/**
|
||||
* @param c
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidIdentifierStartCharacter(int c);
|
||||
public boolean isValidIdentifierCharacter( int c );
|
||||
/**
|
||||
* @param language TODO
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
public boolean isExtensionOperator(ParserLanguage language, String query);
|
||||
public boolean isExtensionOperator(ParserLanguage language, char[] query);
|
||||
}
|
||||
|
|
|
@ -53,4 +53,12 @@ public class CharArrayIntMap extends CharTable {
|
|||
return valueTable[i];
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param image
|
||||
* @return
|
||||
*/
|
||||
public int get(char[] image) {
|
||||
return get( image, 0, image.length );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfoProvider;
|
|||
*/
|
||||
public abstract class GCCASTExtension implements IASTFactoryExtension {
|
||||
protected final ParserMode mode;
|
||||
protected static final char[] EMPTY_STRING = new char[0]; //$NON-NLS-1$
|
||||
protected static final char[] EMPTY_STRING = "".toCharArray(); //$NON-NLS-1$
|
||||
/**
|
||||
* @param mode
|
||||
*/
|
||||
|
|
|
@ -16,6 +16,8 @@ package org.eclipse.cdt.internal.core.parser.ast;
|
|||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IExtensibleSymbol;
|
||||
|
||||
/**
|
||||
|
@ -26,6 +28,8 @@ public class SymbolIterator implements Iterator {
|
|||
Iterator interalIterator;
|
||||
|
||||
IExtensibleSymbol next = null;
|
||||
|
||||
private static final char[] EMPTY_CHAR_ARRAY = "".toCharArray(); //$NON-NLS-1$
|
||||
|
||||
public SymbolIterator( Iterator iter ){
|
||||
interalIterator = iter;
|
||||
|
@ -40,7 +44,12 @@ public class SymbolIterator implements Iterator {
|
|||
|
||||
while( interalIterator.hasNext() ){
|
||||
IExtensibleSymbol symbol = (IExtensibleSymbol) interalIterator.next();
|
||||
|
||||
if( symbol.getASTExtension() != null ){
|
||||
if( symbol.getASTExtension().getPrimaryDeclaration() instanceof IASTOffsetableElement &&
|
||||
CharArrayUtils.equals(((IASTOffsetableElement)symbol.getASTExtension().getPrimaryDeclaration()).getFilename(), EMPTY_CHAR_ARRAY ) )
|
||||
continue;
|
||||
|
||||
next = symbol;
|
||||
return true;
|
||||
}
|
||||
|
@ -59,7 +68,12 @@ public class SymbolIterator implements Iterator {
|
|||
}
|
||||
while( interalIterator.hasNext() ){
|
||||
temp = (IExtensibleSymbol) interalIterator.next();
|
||||
|
||||
if( temp.getASTExtension() != null ){
|
||||
if( temp.getASTExtension().getPrimaryDeclaration() instanceof IASTOffsetableElement &&
|
||||
CharArrayUtils.equals(((IASTOffsetableElement)temp.getASTExtension().getPrimaryDeclaration()).getFilename(), EMPTY_CHAR_ARRAY ) )
|
||||
continue;
|
||||
|
||||
return temp.getASTExtension().getPrimaryDeclaration();
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ public class ASTNode implements IASTNode {
|
|||
|
||||
if( context != null && ((ASTNode)context).shouldFilterLookupResult( s ) )
|
||||
iter.remove();
|
||||
|
||||
}
|
||||
|
||||
SymbolIterator iterator = new SymbolIterator( lookupResults.iterator() );
|
||||
|
|
|
@ -625,6 +625,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ISymbol symbol = pst.getCompilationUnit();
|
||||
ASTCompilationUnit compilationUnit = new ASTCompilationUnit( symbol );
|
||||
attachSymbolExtension(symbol, compilationUnit, true );
|
||||
extension.initialize( this, compilationUnit );
|
||||
return compilationUnit;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,14 +14,23 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.ast.complete.gcc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||
|
@ -31,12 +40,14 @@ import org.eclipse.cdt.internal.core.parser.ast.complete.ASTBinaryExpression;
|
|||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTypeIdExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTUnaryExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ExpressionFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.token.SimpleToken;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class GCCASTCompleteExtension extends GCCASTExtension {
|
||||
|
||||
private static final char [] __BUILTIN_VA_LIST = "__builtin_va_list".toCharArray(); //$NON-NLS-1$
|
||||
/**
|
||||
* @param mode
|
||||
*/
|
||||
|
@ -119,4 +130,22 @@ public class GCCASTCompleteExtension extends GCCASTExtension {
|
|||
|
||||
return ExpressionFactory.createExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression, literal, newDescriptor, references );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#initialize(org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable)
|
||||
*/
|
||||
public void initialize(IASTFactory factory, IASTCompilationUnit compilationUnit) {
|
||||
try
|
||||
{
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.CHAR, new SimpleToken( IToken.t_char, -1, EMPTY_STRING, -1), false, false, false, false, false, false, false, true, Collections.EMPTY_MAP );
|
||||
List pointers = new ArrayList( 1 );
|
||||
pointers.add( ASTPointerOperator.POINTER );
|
||||
IASTAbstractDeclaration abs = factory.createAbstractDeclaration( false, false, typeSpec, pointers, Collections.EMPTY_LIST, Collections.EMPTY_LIST, null );
|
||||
factory.createTypedef( compilationUnit, __BUILTIN_VA_LIST, abs, -1, -1, -1, -1, -1, EMPTY_STRING );
|
||||
}
|
||||
catch( ASTSemanticException ase )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,9 @@ import org.eclipse.cdt.core.parser.ITokenDuple;
|
|||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||
|
@ -134,4 +136,12 @@ public class GCCASTExpressionExtension extends GCCASTExtension {
|
|||
public IASTExpression createExpression(IASTScope scope, Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, IASTTypeId typeId, ITokenDuple idExpression, char[] literal, IASTNewExpressionDescriptor newDescriptor, List references) {
|
||||
return createExpression( kind, lhs, rhs, thirdExpression, typeId, (idExpression == null ) ? EMPTY_STRING : idExpression.toCharArray(), literal, newDescriptor );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#initialize(org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable)
|
||||
*/
|
||||
public void initialize(IASTFactory factory, IASTCompilationUnit compilationUnit) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002-2004 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.scanner2;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public abstract class DynamicStyleMacro {
|
||||
|
||||
public abstract char [] execute();
|
||||
|
||||
public DynamicStyleMacro( char [] n )
|
||||
{
|
||||
name = n;
|
||||
}
|
||||
public final char [] name;
|
||||
|
||||
}
|
|
@ -10,27 +10,20 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||
import org.eclipse.cdt.core.parser.IGCCToken;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.extension.IScannerExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||
import org.eclipse.cdt.internal.core.parser.token.ImagedToken;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class GCCScannerExtension implements IScannerExtension {
|
||||
|
||||
// protected static final ObjectMacroDescriptor STDC_VERSION_MACRO = new ObjectMacroDescriptor( IScanner.__STDC_VERSION__, "199001L"); //$NON-NLS-1$
|
||||
// protected static final ObjectMacroDescriptor STDC_HOSTED_MACRO = new ObjectMacroDescriptor( IScanner.__STDC_HOSTED__, "0"); //$NON-NLS-1$
|
||||
// protected static final ObjectMacroDescriptor CPLUSPLUS_MACRO = new ObjectMacroDescriptor( IScanner.__CPLUSPLUS, "1"); //$NON-NLS-1$
|
||||
private static final String [] simpleIdentifiersDeclSpec;
|
||||
private static final String [] simpleIdentifiersAttribute;
|
||||
static
|
||||
|
@ -42,176 +35,78 @@ public class GCCScannerExtension implements IScannerExtension {
|
|||
simpleIdentifiersAttribute[0] = "xyz"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
protected static final String POUND_IDENT = "#ident"; //$NON-NLS-1$
|
||||
protected static final String POUND_WARNING = "#warning"; //$NON-NLS-1$
|
||||
protected static final String POUND_INCLUDE_NEXT = "#include_next"; //$NON-NLS-1$
|
||||
|
||||
// private static final String __CONST__ = "__const__"; //$NON-NLS-1$
|
||||
// protected static final ObjectMacroDescriptor __CONST__MACRO = new ObjectMacroDescriptor( __CONST__, Keywords.CONST );
|
||||
// private static final String __CONST = "__const"; //$NON-NLS-1$
|
||||
// protected static final ObjectMacroDescriptor __CONST_MACRO = new ObjectMacroDescriptor( __CONST, Keywords.CONST );
|
||||
// private static final String __INLINE__ = "__inline__"; //$NON-NLS-1$
|
||||
// protected static final ObjectMacroDescriptor __INLINE__MACRO = new ObjectMacroDescriptor( __INLINE__, Keywords.INLINE );
|
||||
// private static final String __VOLATILE__ = "__volatile__"; //$NON-NLS-1$
|
||||
// protected static final ObjectMacroDescriptor __VOLATILE__MACRO = new ObjectMacroDescriptor( __VOLATILE__, Keywords.VOLATILE );
|
||||
// private static final String __SIGNED__ = "__signed__"; //$NON-NLS-1$
|
||||
// private static final ObjectMacroDescriptor __SIGNED__MACRO = new ObjectMacroDescriptor( __SIGNED__, Keywords.SIGNED );
|
||||
// private static final String __RESTRICT = "__restrict"; //$NON-NLS-1$
|
||||
// private static final String __RESTRICT__ = "__restrict__"; //$NON-NLS-1$
|
||||
// private static final ObjectMacroDescriptor __RESTRICT__MACRO = new ObjectMacroDescriptor( __RESTRICT__, Keywords.RESTRICT );
|
||||
// private static final String __ASM__ = "__asm__"; //$NON-NLS-1$
|
||||
// protected static final ObjectMacroDescriptor __ASM__MACRO = new ObjectMacroDescriptor( __ASM__, Keywords.ASM );
|
||||
// private static final String __TYPEOF__ = "__typeof__"; //$NON-NLS-1$
|
||||
// protected static final ObjectMacroDescriptor __TYPEOF__MACRO = new ObjectMacroDescriptor( __TYPEOF__, GCCKeywords.TYPEOF );
|
||||
|
||||
|
||||
// private static final String __ATTRIBUTE__ = "__attribute__"; //$NON-NLS-1$
|
||||
// private static final String __DECLSPEC = "__declspec"; //$NON-NLS-1$
|
||||
// private static final IToken [] EMPTY_TOKEN_ARRAY = new IToken[0];
|
||||
// protected static final FunctionMacroDescriptor DECLSPEC_MACRO = new FunctionMacroDescriptor( __ATTRIBUTE__, simpleIdentifiersDeclSpec, EMPTY_TOKEN_ARRAY, "" ); //$NON-NLS-1$
|
||||
//
|
||||
// protected static final FunctionMacroDescriptor ATTRIBUTE_MACRO = new FunctionMacroDescriptor( __ATTRIBUTE__, simpleIdentifiersAttribute, EMPTY_TOKEN_ARRAY, "" ); //$NON-NLS-1$
|
||||
|
||||
// private static final String __EXTENSION__ = "__extension__"; //$NON-NLS-1$
|
||||
// private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||
// protected static final ObjectMacroDescriptor EXTENSION_MACRO = new ObjectMacroDescriptor( __EXTENSION__, EMPTY_STRING );
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IScannerExtension#initializeMacroValue(java.lang.String)
|
||||
*/
|
||||
public String initializeMacroValue(IScannerData scannerData, String original) {
|
||||
if( original == null || original.trim().equals( "") ) //$NON-NLS-1$
|
||||
return "1"; //$NON-NLS-1$
|
||||
public char[] initializeMacroValue(IScannerData scannerData, char[] original) {
|
||||
if( original == null || original.length == 0 ) //$NON-NLS-1$
|
||||
return "1".toCharArray(); //$NON-NLS-1$
|
||||
return original;
|
||||
}
|
||||
private static final char [] emptyCharArray = "".toCharArray(); //$NON-NLS-1$
|
||||
// gcc built-ins
|
||||
private static final ObjectStyleMacro __inline__
|
||||
= new ObjectStyleMacro("__inline__".toCharArray(), "inline".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __extension__
|
||||
= new ObjectStyleMacro("__extension__".toCharArray(), emptyCharArray); //$NON-NLS-1$
|
||||
private static final ObjectStyleMacro __asm__
|
||||
= new ObjectStyleMacro("__asm__".toCharArray(), "asm".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __restrict__
|
||||
= new ObjectStyleMacro("__restrict__".toCharArray(), "restrict".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __restrict
|
||||
= new ObjectStyleMacro("__restrict".toCharArray(), "restrict".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __volatile__
|
||||
= new ObjectStyleMacro("__volatile__".toCharArray(), "volatile".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __const__
|
||||
= new ObjectStyleMacro("__const__".toCharArray(), "const".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __const
|
||||
= new ObjectStyleMacro("__const".toCharArray(), "const".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __signed__
|
||||
= new ObjectStyleMacro("__signed__".toCharArray(), "signed".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __cdecl = new
|
||||
ObjectStyleMacro( "__cdecl".toCharArray(), emptyCharArray ); //$NON-NLS-1$
|
||||
|
||||
|
||||
private static final FunctionStyleMacro __attribute__
|
||||
= new FunctionStyleMacro(
|
||||
"__attribute__".toCharArray(), //$NON-NLS-1$
|
||||
emptyCharArray,
|
||||
new char[][] { "arg".toCharArray() }); //$NON-NLS-1$
|
||||
private static final FunctionStyleMacro __declspec
|
||||
= new FunctionStyleMacro(
|
||||
"__declspec".toCharArray(), //$NON-NLS-1$
|
||||
emptyCharArray,
|
||||
new char[][] { "arg".toCharArray() }); //$NON-NLS-1$
|
||||
|
||||
private static final FunctionStyleMacro _Pragma = new FunctionStyleMacro(
|
||||
"_Pragma".toCharArray(), //$NON-NLS-1$
|
||||
emptyCharArray,
|
||||
new char[][] { "arg".toCharArray() } ); //$NON-NLS-1$
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IScannerExtension#setupBuiltInMacros()
|
||||
*/
|
||||
public void setupBuiltInMacros(IScannerData scannerData) {
|
||||
// gcc extensions
|
||||
scannerData.getRealDefinitions().put(__inline__.name, __inline__);
|
||||
scannerData.getRealDefinitions().put(__cdecl.name, __cdecl );
|
||||
scannerData.getRealDefinitions().put( __const__.name, __const__ );
|
||||
scannerData.getRealDefinitions().put( __const.name, __const );
|
||||
scannerData.getRealDefinitions().put(__extension__.name, __extension__);
|
||||
scannerData.getRealDefinitions().put(__attribute__.name, __attribute__);
|
||||
scannerData.getRealDefinitions().put( __declspec.name, __declspec );
|
||||
scannerData.getRealDefinitions().put(__restrict__.name, __restrict__);
|
||||
scannerData.getRealDefinitions().put(__restrict.name, __restrict);
|
||||
scannerData.getRealDefinitions().put(__volatile__.name, __volatile__);
|
||||
scannerData.getRealDefinitions().put(__signed__.name, __signed__ );
|
||||
if( scannerData.getLanguage() == ParserLanguage.CPP )
|
||||
scannerData.getRealDefinitions().put(__asm__.name, __asm__);
|
||||
else
|
||||
scannerData.getRealDefinitions().put(_Pragma.name, _Pragma );
|
||||
|
||||
// if( scannerData.getLanguage() == ParserLanguage.CPP )
|
||||
// if( scannerData.getScanner().getDefinition( IScanner.__CPLUSPLUS ) == null )
|
||||
// scannerData.getScanner().addDefinition( IScanner.__CPLUSPLUS, CPLUSPLUS_MACRO);
|
||||
//
|
||||
// if( scannerData.getScanner().getDefinition(IScanner.__STDC_HOSTED__) == null )
|
||||
// scannerData.getScanner().addDefinition(IScanner.__STDC_HOSTED__, STDC_HOSTED_MACRO);
|
||||
// if( scannerData.getScanner().getDefinition( IScanner.__STDC_VERSION__) == null )
|
||||
// scannerData.getScanner().addDefinition( IScanner.__STDC_VERSION__, STDC_VERSION_MACRO);
|
||||
//
|
||||
// // add these to private table
|
||||
//// if( scannerData.getScanner().getDefinition( __ATTRIBUTE__) == null )
|
||||
//// scannerData.getPrivateDefinitions().put( __ATTRIBUTE__, ATTRIBUTE_MACRO);
|
||||
////
|
||||
//// if( scannerData.getScanner().getDefinition( __DECLSPEC) == null )
|
||||
//// scannerData.getPrivateDefinitions().put( __DECLSPEC, DECLSPEC_MACRO );
|
||||
////
|
||||
// if( scannerData.getScanner().getDefinition( __EXTENSION__ ) == null )
|
||||
// scannerData.getPrivateDefinitions().put( __EXTENSION__, EXTENSION_MACRO);
|
||||
//
|
||||
// if( scannerData.getScanner().getDefinition( __CONST__ ) == null )
|
||||
// scannerData.getPrivateDefinitions().put( __CONST__, __CONST__MACRO);
|
||||
// if( scannerData.getScanner().getDefinition( __CONST ) == null )
|
||||
// scannerData.getPrivateDefinitions().put( __CONST, __CONST_MACRO);
|
||||
// if( scannerData.getScanner().getDefinition( __INLINE__ ) == null )
|
||||
// scannerData.getPrivateDefinitions().put( __INLINE__, __INLINE__MACRO);
|
||||
// if( scannerData.getScanner().getDefinition( __SIGNED__ ) == null )
|
||||
// scannerData.getPrivateDefinitions().put( __SIGNED__, __SIGNED__MACRO);
|
||||
// if( scannerData.getScanner().getDefinition( __VOLATILE__ ) == null )
|
||||
// scannerData.getPrivateDefinitions().put( __VOLATILE__, __VOLATILE__MACRO);
|
||||
// ObjectMacroDescriptor __RESTRICT_MACRO = new ObjectMacroDescriptor( __RESTRICT, Keywords.RESTRICT );
|
||||
// if( scannerData.getScanner().getDefinition( __RESTRICT ) == null )
|
||||
// scannerData.getPrivateDefinitions().put( __RESTRICT, __RESTRICT_MACRO);
|
||||
// if( scannerData.getScanner().getDefinition( __RESTRICT__ ) == null )
|
||||
// scannerData.getPrivateDefinitions().put( __RESTRICT__, __RESTRICT__MACRO);
|
||||
// if( scannerData.getScanner().getDefinition( __TYPEOF__ ) == null )
|
||||
// scannerData.getPrivateDefinitions().put( __TYPEOF__, __TYPEOF__MACRO);
|
||||
// if( scannerData.getLanguage() == ParserLanguage.CPP )
|
||||
// if( scannerData.getScanner().getDefinition( __ASM__ ) == null )
|
||||
// scannerData.getPrivateDefinitions().put( __ASM__, __ASM__MACRO);
|
||||
//
|
||||
}
|
||||
|
||||
private static final Set directives;
|
||||
static
|
||||
{
|
||||
directives = new HashSet();
|
||||
directives.add( POUND_INCLUDE_NEXT );
|
||||
directives.add( POUND_WARNING);
|
||||
directives.add( POUND_IDENT);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#canHandlePreprocessorDirective(java.lang.String)
|
||||
*/
|
||||
public boolean canHandlePreprocessorDirective(String directive) {
|
||||
return directives.contains( directive );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#handlePreprocessorDirective(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void handlePreprocessorDirective(IScannerData iscanner, String directive, String restOfLine) {
|
||||
if( directive.equals(POUND_INCLUDE_NEXT) )
|
||||
{
|
||||
TraceUtil.outputTrace(iscanner.getLogService(), "GCCScannerExtension handling #include_next directive" ); //$NON-NLS-1$
|
||||
// figure out the name of the current file and its path
|
||||
// IScannerContext context = iscanner.getContextStack().getCurrentContext();
|
||||
// if( context == null || context.getKind() != IScannerContext.ContextKind.INCLUSION )
|
||||
// return;
|
||||
//
|
||||
// String fullInclusionPath = context.getContextName();
|
||||
// IASTInclusion inclusion = ((ScannerContextInclusion)context).getExtension();
|
||||
//
|
||||
// Iterator iter = iscanner.getIncludePathNames().iterator();
|
||||
//
|
||||
// while (iter.hasNext()) {
|
||||
// String path = (String)iter.next();
|
||||
// String completePath = ScannerUtility.createReconciledPath(path, inclusion.getName() );
|
||||
// if( completePath.equals( fullInclusionPath ) )
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// ScannerUtility.InclusionDirective parsedDirective = null;
|
||||
// try {
|
||||
// parsedDirective = iscanner.parseInclusionDirective( restOfLine, iscanner.getContextStack().getCurrentContext().getOffset() );
|
||||
// } catch (InclusionParseException e) {
|
||||
// return;
|
||||
// }
|
||||
// CodeReader duple = null;
|
||||
// // search through include paths
|
||||
// while (iter.hasNext()) {
|
||||
// String path = (String)iter.next();
|
||||
// String finalPath = ScannerUtility.createReconciledPath(path, parsedDirective.getFilename());
|
||||
// duple = (CodeReader)iscanner.getFileCache().get(finalPath);
|
||||
// if (duple == null) {
|
||||
// duple = ScannerUtility.createReaderDuple( finalPath, iscanner.getClientRequestor(), iscanner.getWorkingCopies() );
|
||||
// if (duple != null && duple.isFile())
|
||||
// iscanner.getFileCache().put(duple.filename, duple);
|
||||
// }
|
||||
// if( duple != null )
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// if( duple != null )
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// iscanner.getContextStack().updateInclusionContext(duple, inclusion, iscanner.getClientRequestor() );
|
||||
// TraceUtil.outputTrace( iscanner.getLogService(), "GCCScannerExtension handling #include_next directive successfully pushed on new include file" ); //$NON-NLS-1$
|
||||
// }
|
||||
// catch (ContextException e1)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
}
|
||||
else if( directive.equals( POUND_WARNING) || directive.equals(POUND_IDENT))
|
||||
return; // good enough -- the rest of the line has been consumed
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#offersDifferentIdentifierCharacters()
|
||||
*/
|
||||
|
@ -237,69 +132,71 @@ public class GCCScannerExtension implements IScannerExtension {
|
|||
Character.isUnicodeIdentifierPart( (char)c);
|
||||
}
|
||||
|
||||
private static final Map additionalCPPKeywords;
|
||||
private static final Map additionalCKeywords;
|
||||
private static final Map additionalCPPOperators;
|
||||
private static final Map additionalCOperators;
|
||||
private static final String MAX_OPERATOR = ">?"; //$NON-NLS-1$
|
||||
private static final String MIN_OPERATOR = "<?"; //$NON-NLS-1$
|
||||
private static final CharArrayIntMap additionalCPPKeywords;
|
||||
private static final CharArrayIntMap additionalCKeywords;
|
||||
private static final CharArrayIntMap additionalCPPOperators;
|
||||
private static final CharArrayIntMap additionalCOperators;
|
||||
private static final char [] MAX_OPERATOR = ">?".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] MIN_OPERATOR = "<?".toCharArray(); //$NON-NLS-1$
|
||||
|
||||
static
|
||||
{
|
||||
additionalCKeywords = new HashMap();
|
||||
additionalCKeywords.put( GCCKeywords.__ALIGNOF__, new Integer( IGCCToken.t___alignof__ ));
|
||||
additionalCKeywords.put( GCCKeywords.TYPEOF, new Integer( IGCCToken.t_typeof ));
|
||||
additionalCPPKeywords = new HashMap(additionalCKeywords);
|
||||
additionalCPPKeywords.put( Keywords.RESTRICT, new Integer( IToken.t_restrict ));
|
||||
additionalCKeywords = new CharArrayIntMap( 2, -1 );
|
||||
additionalCKeywords.put( GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
|
||||
additionalCKeywords.put( GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
|
||||
additionalCPPKeywords = new CharArrayIntMap( 4, -1 );
|
||||
additionalCPPKeywords.put( GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
|
||||
additionalCPPKeywords.put( GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
|
||||
additionalCPPKeywords.put( Keywords.cRESTRICT, IToken.t_restrict );
|
||||
|
||||
additionalCOperators = new HashMap();
|
||||
|
||||
additionalCPPOperators = new HashMap();
|
||||
additionalCPPOperators.put( MAX_OPERATOR, new Integer( IGCCToken.tMAX ) );
|
||||
additionalCPPOperators.put( MIN_OPERATOR, new Integer( IGCCToken.tMIN ) );
|
||||
additionalCOperators = new CharArrayIntMap(2, -1);
|
||||
additionalCPPOperators = new CharArrayIntMap( 2, -1);
|
||||
additionalCPPOperators.put( MAX_OPERATOR, IGCCToken.tMAX );
|
||||
additionalCPPOperators.put( MIN_OPERATOR, IGCCToken.tMIN );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#isExtensionKeyword()
|
||||
*/
|
||||
public boolean isExtensionKeyword(ParserLanguage language, String tokenImage) {
|
||||
public boolean isExtensionKeyword(ParserLanguage language, char[] tokenImage) {
|
||||
if( language == ParserLanguage.CPP )
|
||||
return ( additionalCPPKeywords.get( tokenImage ) != null );
|
||||
return ( additionalCPPKeywords.containsKey( tokenImage ) );
|
||||
else if( language == ParserLanguage.C )
|
||||
return ( additionalCKeywords.get( tokenImage ) != null );
|
||||
return ( additionalCKeywords.containsKey( tokenImage ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#createExtensionToken()
|
||||
*/
|
||||
public IToken createExtensionToken(IScannerData scannerData, String image) {
|
||||
Integer get = null;
|
||||
public IToken createExtensionToken(IScannerData scannerData, char[] image) {
|
||||
int get = -1;
|
||||
if( scannerData.getLanguage() == ParserLanguage.CPP )
|
||||
{
|
||||
get = (Integer) additionalCPPKeywords.get( image );
|
||||
if( get == null )
|
||||
get = (Integer) additionalCPPOperators.get( image );
|
||||
get = additionalCPPKeywords.get( image );
|
||||
if( get == -1 )
|
||||
get = additionalCPPOperators.get( image );
|
||||
}
|
||||
else if( scannerData.getLanguage() == ParserLanguage.C )
|
||||
{
|
||||
get = (Integer) additionalCKeywords.get( image );
|
||||
if( get == null )
|
||||
get = (Integer) additionalCOperators.get( image );
|
||||
get = additionalCKeywords.get( image );
|
||||
if( get == -1 )
|
||||
get = additionalCOperators.get( image );
|
||||
}
|
||||
if( get == null ) return null;
|
||||
return null;
|
||||
// return TokenFactory.createUniquelyImagedToken(get.intValue(),image,scannerData);
|
||||
if( get == -1 ) return null;
|
||||
int o = scannerData.getCurrentOffset() + 1;
|
||||
IToken i = new ImagedToken(get, image, o, scannerData.getCurrentFilename(), scannerData.getLineNumber( o ));
|
||||
return i;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#isExtensionOperator(java.lang.String)
|
||||
*/
|
||||
public boolean isExtensionOperator(ParserLanguage language, String query) {
|
||||
public boolean isExtensionOperator(ParserLanguage language, char[] query) {
|
||||
if( language == ParserLanguage.CPP )
|
||||
return ( additionalCPPOperators.get( query ) != null );
|
||||
return ( additionalCPPOperators.containsKey( query ) );
|
||||
else if (language == ParserLanguage.C )
|
||||
return ( additionalCOperators.get( query ) != null );
|
||||
return ( additionalCOperators.containsKey( query ));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
||||
|
||||
/**
|
||||
|
@ -52,4 +53,29 @@ public interface IScannerData {
|
|||
* @return
|
||||
*/
|
||||
// public abstract InclusionDirective parseInclusionDirective(String restOfLine, int offset) throws InclusionParseException;
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getCurrentOffset();
|
||||
|
||||
|
||||
/**
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
public int getLineNumber(int o);
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public char [] getCurrentFilename();
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public abstract CharArrayObjectMap getRealDefinitions();
|
||||
}
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.parser.scanner2;
|
|||
import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -88,12 +89,12 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
|
||||
// The context stack
|
||||
private static final int bufferInitialSize = 8;
|
||||
private int bufferStackPos = -1;
|
||||
int bufferStackPos = -1;
|
||||
private char[][] bufferStack = new char[bufferInitialSize][];
|
||||
private Object[] bufferData = new Object[bufferInitialSize];
|
||||
private int[] bufferPos = new int[bufferInitialSize];
|
||||
private int[] bufferLimit = new int[bufferInitialSize];
|
||||
private int[] lineNumbers = new int[bufferInitialSize];
|
||||
int[] lineNumbers = new int[bufferInitialSize];
|
||||
private int[] lineOffsets = new int[bufferInitialSize];
|
||||
|
||||
//inclusion stack
|
||||
|
@ -160,7 +161,7 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
|
||||
if( value instanceof String ) {
|
||||
//TODO add in check here for '(' and ')'
|
||||
addDefinition( symbolName, scannerExtension.initializeMacroValue(this, (String) value));
|
||||
addDefinition( symbolName.toCharArray(), scannerExtension.initializeMacroValue(this, ((String)value).toCharArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -292,9 +293,8 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IScanner#addDefinition(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void addDefinition(String key, String value) {
|
||||
char[] ckey = key.toCharArray();
|
||||
definitions.put(ckey, new ObjectStyleMacro(ckey, value.toCharArray()));
|
||||
public void addDefinition(char[] key, char[] value) {
|
||||
definitions.put(key, new ObjectStyleMacro(key, value ));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -768,6 +768,16 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
++bufferPos[bufferStackPos];
|
||||
return newToken(IToken.tSHIFTL );
|
||||
}
|
||||
else
|
||||
{
|
||||
char [] queryCharArray = CharArrayUtils.extract( buffer, pos, 2 );
|
||||
if( scannerExtension.isExtensionOperator( language, queryCharArray ) )
|
||||
{
|
||||
++bufferPos[ bufferStackPos ];
|
||||
return scannerExtension.createExtensionToken( this, queryCharArray );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return newToken(IToken.tLT );
|
||||
|
||||
|
@ -786,6 +796,15 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
++bufferPos[bufferStackPos];
|
||||
return newToken(IToken.tSHIFTR);
|
||||
}
|
||||
else
|
||||
{
|
||||
char [] queryCharArray = CharArrayUtils.extract( buffer, pos, 2 );
|
||||
if( scannerExtension.isExtensionOperator( language, queryCharArray ) )
|
||||
{
|
||||
++bufferPos[ bufferStackPos ];
|
||||
return scannerExtension.createExtensionToken( this, queryCharArray );
|
||||
}
|
||||
}
|
||||
}
|
||||
return newToken(IToken.tGT );
|
||||
|
||||
|
@ -793,7 +812,7 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
return newToken(IToken.tCOMMA );
|
||||
|
||||
default:
|
||||
if( Character.isLetter( buffer[pos] ) ){
|
||||
if( Character.isLetter( buffer[pos] ) || scannerExtension.isValidIdentifierStartCharacter( buffer[pos ]) ){
|
||||
t = scanIdentifier();
|
||||
if (t instanceof MacroExpansionToken)
|
||||
continue;
|
||||
|
@ -864,6 +883,11 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
else if( scannerExtension.isValidIdentifierCharacter( c ))
|
||||
{
|
||||
++len;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -892,6 +916,14 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
char[] expText = expMacro.expansion;
|
||||
if (expText.length > 0)
|
||||
pushContext(expText, expMacro);
|
||||
}
|
||||
else if( expObject instanceof DynamicStyleMacro )
|
||||
{
|
||||
DynamicStyleMacro expMacro = (DynamicStyleMacro) expObject;
|
||||
char[] expText = expMacro.execute();
|
||||
if (expText.length > 0)
|
||||
pushContext(expText, expMacro);
|
||||
|
||||
} else if (expObject instanceof char[]) {
|
||||
char[] expText = (char[])expObject;
|
||||
if (expText.length > 0)
|
||||
|
@ -900,7 +932,11 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
return new MacroExpansionToken();
|
||||
}
|
||||
|
||||
char [] result = escapedNewline ? removedEscapedNewline( buffer, start, len ) : null;
|
||||
|
||||
|
||||
char [] result = escapedNewline ? removedEscapedNewline( buffer, start, len ) : CharArrayUtils.extract( buffer, start, len );
|
||||
if( scannerExtension.isExtensionKeyword( language, result))
|
||||
return scannerExtension.createExtensionToken( this, result );
|
||||
int tokenType = escapedNewline ? keywords.get(result, 0, result.length)
|
||||
: keywords.get(buffer, start, len );
|
||||
|
||||
|
@ -1040,7 +1076,7 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
* @param i
|
||||
* @return
|
||||
*/
|
||||
protected int getLineNumber(int offset) {
|
||||
public int getLineNumber(int offset) {
|
||||
if( parserMode == ParserMode.COMPLETION_PARSE ) return -1;
|
||||
int index = getCurrentFileIndex();
|
||||
if( offset >= bufferLimit[ index ]) return -1;
|
||||
|
@ -1992,6 +2028,14 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
++bufferPos[bufferStackPos];
|
||||
continue;
|
||||
}
|
||||
if( pos + 1 < limit && buffer[ pos + 1 ] == '\r')
|
||||
{
|
||||
if( pos + 2 < limit && buffer[ pos + 2] == '\n' )
|
||||
{
|
||||
bufferPos[bufferStackPos] +=2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2656,44 +2700,73 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
= new ObjectStyleMacro("__cplusplus".toCharArray(), "1".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __STDC__
|
||||
= new ObjectStyleMacro("__STDC__".toCharArray(), "1".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __STDC_HOSTED__
|
||||
= new ObjectStyleMacro("__STDC_HOSTED_".toCharArray(), "1".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __STDC_VERSION__
|
||||
= new ObjectStyleMacro("__STDC_VERSION_".toCharArray(), "199901L".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private final DynamicStyleMacro __FILE__ =
|
||||
new DynamicStyleMacro( "__FILE__".toCharArray()) { //$NON-NLS-1$
|
||||
|
||||
public char[] execute() {
|
||||
StringBuffer buffer = new StringBuffer( "\""); //$NON-NLS-1$
|
||||
buffer.append( getCurrentFilename() );
|
||||
buffer.append( '\"');
|
||||
return buffer.toString().toCharArray();
|
||||
} };
|
||||
private final DynamicStyleMacro __DATE__ =
|
||||
new DynamicStyleMacro( "__DATE__".toCharArray()) { //$NON-NLS-1$
|
||||
|
||||
private final void append( StringBuffer buffer, int value )
|
||||
{
|
||||
if( value < 10 )
|
||||
buffer.append( "0" ); //$NON-NLS-1$
|
||||
buffer.append( value );
|
||||
}
|
||||
|
||||
public char[] execute() {
|
||||
StringBuffer buffer = new StringBuffer( "\""); //$NON-NLS-1$
|
||||
Calendar cal = Calendar.getInstance();
|
||||
buffer.append( cal.get( Calendar.MONTH ));
|
||||
buffer.append( " " ); //$NON-NLS-1$
|
||||
append( buffer, cal.get( Calendar.DAY_OF_MONTH ));
|
||||
buffer.append( " " ); //$NON-NLS-1$
|
||||
buffer.append( cal.get(Calendar.YEAR));
|
||||
buffer.append( "\""); //$NON-NLS-1$
|
||||
return buffer.toString().toCharArray();
|
||||
}
|
||||
};
|
||||
private final DynamicStyleMacro __TIME__ =
|
||||
new DynamicStyleMacro( "__TIME__".toCharArray()) { //$NON-NLS-1$
|
||||
|
||||
private final void append( StringBuffer buffer, int value )
|
||||
{
|
||||
if( value < 10 )
|
||||
buffer.append( "0" ); //$NON-NLS-1$
|
||||
buffer.append( value );
|
||||
}
|
||||
public char[] execute() {
|
||||
StringBuffer buffer = new StringBuffer( "\""); //$NON-NLS-1$
|
||||
Calendar cal = Calendar.getInstance();
|
||||
append( buffer, cal.get( Calendar.HOUR ));
|
||||
buffer.append( ":"); //$NON-NLS-1$
|
||||
append( buffer, cal.get( Calendar.MINUTE));
|
||||
buffer.append( ":"); //$NON-NLS-1$
|
||||
append( buffer, cal.get( Calendar.SECOND));
|
||||
buffer.append( "\""); //$NON-NLS-1$
|
||||
return buffer.toString().toCharArray();
|
||||
}
|
||||
};
|
||||
private final DynamicStyleMacro __LINE__ =
|
||||
new DynamicStyleMacro( "__LINE__".toCharArray() ) { //$NON-NLS-1$
|
||||
|
||||
public char[] execute() {
|
||||
int lineNumber = lineNumbers[ bufferStackPos ];
|
||||
return Long.toString( lineNumber ).toCharArray();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// gcc built-ins
|
||||
private static final ObjectStyleMacro __inline__
|
||||
= new ObjectStyleMacro("__inline__".toCharArray(), "inline".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __extension__
|
||||
= new ObjectStyleMacro("__extension__".toCharArray(), emptyCharArray); //$NON-NLS-1$
|
||||
private static final ObjectStyleMacro __asm__
|
||||
= new ObjectStyleMacro("__asm__".toCharArray(), "asm".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __restrict__
|
||||
= new ObjectStyleMacro("__restrict__".toCharArray(), "restrict".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __restrict
|
||||
= new ObjectStyleMacro("__restrict".toCharArray(), "restrict".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __volatile__
|
||||
= new ObjectStyleMacro("__volatile__".toCharArray(), "volatile".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __const__
|
||||
= new ObjectStyleMacro("__const__".toCharArray(), "const".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __const
|
||||
= new ObjectStyleMacro("__const".toCharArray(), "const".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __signed__
|
||||
= new ObjectStyleMacro("__signed__".toCharArray(), "signed".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final ObjectStyleMacro __cdecl = new
|
||||
ObjectStyleMacro( "__cdecl".toCharArray(), emptyCharArray ); //$NON-NLS-1$
|
||||
|
||||
private static final FunctionStyleMacro __attribute__
|
||||
= new FunctionStyleMacro(
|
||||
"__attribute__".toCharArray(), //$NON-NLS-1$
|
||||
emptyCharArray,
|
||||
new char[][] { "arg".toCharArray() }); //$NON-NLS-1$
|
||||
private static final FunctionStyleMacro __declspec
|
||||
= new FunctionStyleMacro(
|
||||
"__declspec".toCharArray(), //$NON-NLS-1$
|
||||
emptyCharArray,
|
||||
new char[][] { "arg".toCharArray() }); //$NON-NLS-1$
|
||||
|
||||
private static final FunctionStyleMacro _Pragma = new FunctionStyleMacro(
|
||||
"_Pragma".toCharArray(), //$NON-NLS-1$
|
||||
emptyCharArray,
|
||||
new char[][] { "arg".toCharArray() } ); //$NON-NLS-1$
|
||||
|
||||
private IASTFactory astFactory;
|
||||
|
||||
|
@ -2702,156 +2775,21 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
protected void setupBuiltInMacros() {
|
||||
|
||||
definitions.put(__STDC__.name, __STDC__);
|
||||
definitions.put(__FILE__.name, __FILE__);
|
||||
definitions.put(__DATE__.name, __DATE__ );
|
||||
definitions.put(__TIME__.name, __TIME__ );
|
||||
definitions.put(__LINE__.name, __LINE__ );
|
||||
|
||||
if( language == ParserLanguage.CPP )
|
||||
definitions.put(__cplusplus.name, __cplusplus);
|
||||
|
||||
// gcc extensions
|
||||
definitions.put(__inline__.name, __inline__);
|
||||
definitions.put(__cdecl.name, __cdecl );
|
||||
definitions.put( __const__.name, __const__ );
|
||||
definitions.put( __const.name, __const );
|
||||
definitions.put(__extension__.name, __extension__);
|
||||
definitions.put(__attribute__.name, __attribute__);
|
||||
definitions.put( __declspec.name, __declspec );
|
||||
definitions.put(__restrict__.name, __restrict__);
|
||||
definitions.put(__restrict.name, __restrict);
|
||||
definitions.put(__volatile__.name, __volatile__);
|
||||
definitions.put(__signed__.name, __signed__ );
|
||||
if( language == ParserLanguage.CPP )
|
||||
definitions.put(__asm__.name, __asm__);
|
||||
else
|
||||
definitions.put(_Pragma.name, _Pragma );
|
||||
|
||||
/*
|
||||
|
||||
// add these to private table
|
||||
if( scannerData.getScanner().getDefinition( __ATTRIBUTE__) == null )
|
||||
scannerData.getPrivateDefinitions().put( __ATTRIBUTE__, ATTRIBUTE_MACRO);
|
||||
|
||||
if( scannerData.getScanner().getDefinition( __DECLSPEC) == null )
|
||||
scannerData.getPrivateDefinitions().put( __DECLSPEC, DECLSPEC_MACRO );
|
||||
|
||||
if( scannerData.getScanner().getDefinition( __EXTENSION__ ) == null )
|
||||
scannerData.getPrivateDefinitions().put( __EXTENSION__, EXTENSION_MACRO);
|
||||
|
||||
if( scannerData.getScanner().getDefinition( __CONST__ ) == null )
|
||||
scannerData.getPrivateDefinitions().put( __CONST__, __CONST__MACRO);
|
||||
if( scannerData.getScanner().getDefinition( __CONST ) == null )
|
||||
scannerData.getPrivateDefinitions().put( __CONST, __CONST_MACRO);
|
||||
if( scannerData.getScanner().getDefinition( __INLINE__ ) == null )
|
||||
scannerData.getPrivateDefinitions().put( __INLINE__, __INLINE__MACRO);
|
||||
if( scannerData.getScanner().getDefinition( __SIGNED__ ) == null )
|
||||
scannerData.getPrivateDefinitions().put( __SIGNED__, __SIGNED__MACRO);
|
||||
if( scannerData.getScanner().getDefinition( __VOLATILE__ ) == null )
|
||||
scannerData.getPrivateDefinitions().put( __VOLATILE__, __VOLATILE__MACRO);
|
||||
ObjectMacroDescriptor __RESTRICT_MACRO = new ObjectMacroDescriptor( __RESTRICT, Keywords.RESTRICT );
|
||||
if( scannerData.getScanner().getDefinition( __RESTRICT ) == null )
|
||||
scannerData.getPrivateDefinitions().put( __RESTRICT, __RESTRICT_MACRO);
|
||||
if( scannerData.getScanner().getDefinition( __RESTRICT__ ) == null )
|
||||
scannerData.getPrivateDefinitions().put( __RESTRICT__, __RESTRICT__MACRO);
|
||||
if( scannerData.getScanner().getDefinition( __TYPEOF__ ) == null )
|
||||
scannerData.getPrivateDefinitions().put( __TYPEOF__, __TYPEOF__MACRO);
|
||||
if( scannerData.getLanguage() == ParserLanguage.CPP )
|
||||
if( scannerData.getScanner().getDefinition( __ASM__ ) == null )
|
||||
scannerData.getPrivateDefinitions().put( __ASM__, __ASM__MACRO);
|
||||
*/
|
||||
|
||||
// standard extensions
|
||||
|
||||
/*
|
||||
if( getDefinition(__STDC__) == null )
|
||||
addDefinition( __STDC__, STDC_MACRO );
|
||||
|
||||
if( language == ParserLanguage.C )
|
||||
{
|
||||
if( getDefinition(__STDC_HOSTED__) == null )
|
||||
addDefinition( __STDC_HOSTED__, STDC_HOSTED_MACRO);
|
||||
if( getDefinition( __STDC_VERSION__) == null )
|
||||
addDefinition( __STDC_VERSION__, STDC_VERSION_MACRO);
|
||||
definitions.put( __STDC_HOSTED__.name, __STDC_HOSTED__ );
|
||||
definitions.put( __STDC_VERSION__.name, __STDC_VERSION__ );
|
||||
}
|
||||
else
|
||||
if( getDefinition( __CPLUSPLUS ) == null )
|
||||
addDefinition( __CPLUSPLUS, CPLUSPLUS_MACRO); //$NON-NLS-1$
|
||||
|
||||
if( getDefinition(__FILE__) == null )
|
||||
addDefinition( __FILE__,
|
||||
new DynamicMacroDescriptor( __FILE__, new DynamicMacroEvaluator() {
|
||||
public String execute() {
|
||||
return contextStack.getMostRelevantFileContext().getContextName();
|
||||
}
|
||||
} ) );
|
||||
scannerExtension.setupBuiltInMacros( this );
|
||||
|
||||
if( getDefinition( __LINE__) == null )
|
||||
addDefinition( __LINE__,
|
||||
new DynamicMacroDescriptor( __LINE__, new DynamicMacroEvaluator() {
|
||||
public String execute() {
|
||||
return new Integer( contextStack.getCurrentLineNumber() ).toString();
|
||||
}
|
||||
} ) );
|
||||
|
||||
|
||||
if( getDefinition( __DATE__ ) == null )
|
||||
addDefinition( __DATE__,
|
||||
new DynamicMacroDescriptor( __DATE__, new DynamicMacroEvaluator() {
|
||||
|
||||
public String getMonth()
|
||||
{
|
||||
if( Calendar.MONTH == Calendar.JANUARY ) return "Jan" ; //$NON-NLS-1$
|
||||
if( Calendar.MONTH == Calendar.FEBRUARY) return "Feb"; //$NON-NLS-1$
|
||||
if( Calendar.MONTH == Calendar.MARCH) return "Mar"; //$NON-NLS-1$
|
||||
if( Calendar.MONTH == Calendar.APRIL) return "Apr"; //$NON-NLS-1$
|
||||
if( Calendar.MONTH == Calendar.MAY) return "May"; //$NON-NLS-1$
|
||||
if( Calendar.MONTH == Calendar.JUNE) return "Jun"; //$NON-NLS-1$
|
||||
if( Calendar.MONTH == Calendar.JULY) return "Jul"; //$NON-NLS-1$
|
||||
if( Calendar.MONTH == Calendar.AUGUST) return "Aug"; //$NON-NLS-1$
|
||||
if( Calendar.MONTH == Calendar.SEPTEMBER) return "Sep"; //$NON-NLS-1$
|
||||
if( Calendar.MONTH == Calendar.OCTOBER) return "Oct"; //$NON-NLS-1$
|
||||
if( Calendar.MONTH == Calendar.NOVEMBER) return "Nov"; //$NON-NLS-1$
|
||||
if( Calendar.MONTH == Calendar.DECEMBER) return "Dec"; //$NON-NLS-1$
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public String execute() {
|
||||
StringBuffer result = new StringBuffer();
|
||||
result.append( getMonth() );
|
||||
result.append(" "); //$NON-NLS-1$
|
||||
if( Calendar.DAY_OF_MONTH < 10 )
|
||||
result.append(" "); //$NON-NLS-1$
|
||||
result.append(Calendar.DAY_OF_MONTH);
|
||||
result.append(" "); //$NON-NLS-1$
|
||||
result.append( Calendar.YEAR );
|
||||
return result.toString();
|
||||
}
|
||||
} ) );
|
||||
|
||||
if( getDefinition( __TIME__) == null )
|
||||
addDefinition( __TIME__,
|
||||
new DynamicMacroDescriptor( __TIME__, new DynamicMacroEvaluator() {
|
||||
|
||||
|
||||
public String execute() {
|
||||
StringBuffer result = new StringBuffer();
|
||||
if( Calendar.AM_PM == Calendar.PM )
|
||||
result.append( Calendar.HOUR + 12 );
|
||||
else
|
||||
{
|
||||
if( Calendar.HOUR < 10 )
|
||||
result.append( '0');
|
||||
result.append(Calendar.HOUR);
|
||||
}
|
||||
result.append(':');
|
||||
if( Calendar.MINUTE < 10 )
|
||||
result.append( '0');
|
||||
result.append(Calendar.MINUTE);
|
||||
result.append(':');
|
||||
if( Calendar.SECOND < 10 )
|
||||
result.append( '0');
|
||||
result.append(Calendar.SECOND);
|
||||
return result.toString();
|
||||
}
|
||||
} ) );
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -2920,7 +2858,7 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
}
|
||||
|
||||
|
||||
private final char[] getCurrentFilename() {
|
||||
public final char[] getCurrentFilename() {
|
||||
for( int i = bufferStackPos; i >= 0; --i )
|
||||
{
|
||||
if( bufferData[i] instanceof InclusionData )
|
||||
|
@ -3108,4 +3046,11 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
throw new OffsetLimitReachedException( new ASTCompletionNode( IASTCompletionNode.CompletionKind.PREPROCESSOR_DIRECTIVE, null, null, prefix, KeywordSets.getKeywords(KeywordSetKey.PP_DIRECTIVE, language ), EMPTY_STRING, null));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerData#getCurrentOffset()
|
||||
*/
|
||||
public int getCurrentOffset() {
|
||||
return bufferPos[ bufferStackPos ];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue