Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.core/parser/ChangeLog6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java59
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java49
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/Name.java17
7 files changed, 128 insertions, 19 deletions
diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog
index eeb26efd48..220f17893b 100644
--- a/core/org.eclipse.cdt.core/parser/ChangeLog
+++ b/core/org.eclipse.cdt.core/parser/ChangeLog
@@ -1,3 +1,9 @@
+2003-04-01 John Camelon
+ Updated Scanner to convert control-characters to ' '.
+ Fixed logic error in SimpleDeclarationWrapper.
+ Added operator support to grammar.
+ Fixed Name.toString() to support non-qualified yet multi-part names.
+
2003-04-01 Andrew Niefer
Parser Symbol Table, modified lookup with respect to resolving ambiguous names,
reducing the number of temporary lists/sets. Modified adding using declarations
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
index 33ba0fff14..7d19adce1f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
@@ -354,8 +354,8 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
elem.setElementName( elementName );
if( wrapper.getName() != null )
{
- elem.setIdPos(wrapper.getName().getStartOffset(), elementName.length());
- elem.setPos(wrapper.getName().getStartOffset(), elementName.length());
+ elem.setIdPos(wrapper.getName().getStartOffset(), wrapper.getName().length());
+ elem.setPos(wrapper.getName().getStartOffset(), wrapper.getName().length());
}
else
{
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
index e8ecefcc46..ad4bb7dcfc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
@@ -14,10 +14,6 @@ import org.eclipse.cdt.internal.core.parser.util.Name;
/**
* @author jcamelon
*
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
*/
public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpecifier.Container, ICElementWrapper {
@@ -29,7 +25,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
public SimpleDeclarationWrapper( IParent item )
{
- this.element = item;
+ this.parent = item;
}
public SimpleDeclarationWrapper()
@@ -139,8 +135,8 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
if( currentDeclarator.getName() != null )
{
// hook up the offsets
- declaration.setIdPos( currentDeclarator.getName().getStartOffset(), declaratorName.length());
- declaration.setPos( currentDeclarator.getName().getStartOffset(), declaratorName.length() );
+ declaration.setIdPos( currentDeclarator.getName().getStartOffset(), currentDeclarator.getName().length() );
+ declaration.setPos( currentDeclarator.getName().getStartOffset(), currentDeclarator.getName().length());
}
else
{
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
index adaca8b0a5..253bb9d674 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
@@ -914,7 +914,7 @@ c, quick);
*/
protected Object initDeclarator( Object owner ) throws Backtrack {
Object declarator = declarator( owner );
-
+
// handle = initializerClause
if (LT(1) == Token.tASSIGN) {
consume();
@@ -1011,9 +1011,60 @@ c, quick);
return declarator;
}
- name();
- try{ callback.declaratorId(declarator);} catch( Exception e ) {}
-
+ if( LT(1) == Token.t_operator )
+ {
+ // we know this is an operator
+ Token operatorToken = consume( Token.t_operator );
+ Token toSend = null;
+ if( LA(1).isOperator() || LT(1) == Token.tLPAREN || LT(1) == Token.tLBRACKET )
+ {
+ if( (LT(1) == Token.t_new || LT(1) == Token.t_delete ) &&
+ LT(2) == Token.tLBRACKET && LT(3) == Token.tRBRACKET )
+ {
+ consume();
+ consume( Token.tLBRACKET );
+ toSend = consume( Token.tRBRACKET );
+ // vector new and delete operators
+ }
+ else if ( LT(1) == Token.tLPAREN && LT(2) == Token.tRPAREN )
+ {
+ // operator ()
+ consume( Token.tLPAREN );
+ toSend = toSend = consume( Token.tRPAREN );
+ }
+ else if ( LT(1) == Token.tLBRACKET && LT(2) == Token.tRBRACKET )
+ {
+ consume( Token.tLBRACKET );
+ toSend = consume( Token.tRBRACKET );
+ }
+ else if( LA(1).isOperator() )
+ toSend = consume();
+ else
+ throw backtrack;
+
+ }
+ else
+ {
+ // temporary
+ while( LT(1) != Token.tLPAREN )
+ {
+ toSend = consume();
+ }
+ }
+
+ try{
+ callback.nameBegin( operatorToken );
+ callback.nameEnd( toSend );
+ } catch( Exception e ) {}
+
+
+ }
+ else
+ {
+ name();
+ }
+
+ try{ callback.declaratorId(declarator);} catch( Exception e ) {}
for (;;) {
switch (LT(1)) {
case Token.tLPAREN:
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java
index e5baf23b94..f373942ba0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java
@@ -1196,7 +1196,7 @@ public class Scanner implements IScanner {
throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + currentContext.getOffset() + " of file " + currentContext.getFilename() );
else
{
- c = getChar();
+ c = ' ';
continue;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java
index 8924a50f63..27d83ecc62 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java
@@ -43,6 +43,54 @@ public class Token {
private Token next;
public Token getNext() { return next; }
public void setNext(Token t) { next = t; }
+
+ public boolean isOperator()
+ {
+ switch( getType() )
+ {
+ case Token.t_new:
+ case Token.t_delete:
+ case Token.tPLUS:
+ case Token.tMINUS:
+ case Token.tSTAR:
+ case Token.tDIV:
+ case Token.tXOR:
+ case Token.tMOD:
+ case Token.tAMPER:
+ case Token.tBITOR:
+ case Token.tCOMPL:
+ case Token.tNOT:
+ case Token.tASSIGN:
+ case Token.tLT:
+ case Token.tGT:
+ case Token.tPLUSASSIGN:
+ case Token.tMINUSASSIGN:
+ case Token.tSTARASSIGN:
+ case Token.tDIVASSIGN:
+ case Token.tMODASSIGN:
+ case Token.tBITORASSIGN:
+ case Token.tAMPERASSIGN:
+ case Token.tXORASSIGN:
+ case Token.tSHIFTL:
+ case Token.tSHIFTR:
+ case Token.tSHIFTLASSIGN:
+ case Token.tSHIFTRASSIGN:
+ case Token.tEQUAL:
+ case Token.tNOTEQUAL:
+ case Token.tLTEQUAL:
+ case Token.tGTEQUAL:
+ case Token.tAND:
+ case Token.tOR:
+ case Token.tINCR:
+ case Token.tDECR:
+ case Token.tCOMMA:
+ case Token.tARROW:
+ case Token.tARROWSTAR:
+ return true;
+ default:
+ return false;
+ }
+ }
// Token types
static public final int tIDENTIFIER = 1;
@@ -83,7 +131,6 @@ public class Token {
static public final int tNOT = 36;
static public final int tEQUAL = 37;
static public final int tASSIGN = 38;
- static public final int tSHIFLASSIGN = 39;
static public final int tSHIFTL = 40;
static public final int tLTEQUAL = 41;
static public final int tLT = 42;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/Name.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/Name.java
index b161db4170..e95ea2ceb3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/Name.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/Name.java
@@ -35,13 +35,22 @@ public class Name {
public String toString() {
Token t = nameStart;
- String name = t.getImage();
-
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( t.getImage() );
+ if( t.getType() == Token.t_operator )
+ buffer.append( " " );
+
while (t != nameEnd) {
t = t.getNext();
- name += t.getImage();
+
+ buffer.append( t.getImage() );
}
- return name;
+ return buffer.toString();
+ }
+
+ public int length()
+ {
+ return getEndOffset() - getStartOffset() + nameEnd.getImage().length();
}
}

Back to the top