diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index 1ceb1b5e498..cec9eca2486 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,3 +1,6 @@ +2003-12-12 John Camelon + Updated testBaseCase_SimpleDeclaration() for keyword assertions. + 2003-12-11 John Camelon Expanded ContextualParseTest::testBaseCase(). Updated tests to deal with new signatures/exceptions. diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContextualParseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContextualParseTest.java index 49424eb50ec..c59cd2fe9e6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContextualParseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContextualParseTest.java @@ -8,6 +8,7 @@ package org.eclipse.cdt.core.parser.tests; import java.io.StringReader; import java.io.StringWriter; +import java.util.Iterator; import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.IParserLogService; @@ -57,19 +58,24 @@ public class ContextualParseTest extends CompleteParseBaseTest { } - public void testBaseCase() throws Exception + public void testBaseCase_SimpleDeclaration() throws Exception { StringWriter writer = new StringWriter(); writer.write( "class ABC " ); writer.write( "{int x;}; " ); writer.write( "AB\n\n" ); - IASTCompletionNode node = parse( writer.toString(), 21); + IASTCompletionNode node = null; + Iterator keywords = null; + + node = parse( writer.toString(), 21); assertNotNull( node ); assertNotNull( node.getCompletionPrefix() ); assertEquals( node.getCompletionScope(), ((Scope)callback.getCompilationUnit()).getScope() ); assertEquals( node.getCompletionPrefix(), "A"); assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.VARIABLE_TYPE ); + keywords = node.getKeywords(); + assertFalse( keywords.hasNext() ); node = parse( writer.toString(), 12); assertNotNull( node ); @@ -77,7 +83,11 @@ public class ContextualParseTest extends CompleteParseBaseTest { assertTrue( node.getCompletionScope() instanceof IASTClassSpecifier ); assertEquals( node.getCompletionPrefix(), "i"); assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.FIELD_TYPE ); - + keywords = node.getKeywords(); + assertTrue( keywords.hasNext() ); + assertEquals( (String) keywords.next(), "inline"); + assertEquals( (String) keywords.next(), "int"); + assertFalse( keywords.hasNext() ); node = parse( writer.toString(), 22); assertNotNull( node ); @@ -85,6 +95,8 @@ public class ContextualParseTest extends CompleteParseBaseTest { assertEquals( node.getCompletionScope(), ((Scope)callback.getCompilationUnit()).getScope() ); assertEquals( node.getCompletionPrefix(), "AB"); assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.VARIABLE_TYPE ); + keywords = node.getKeywords(); + assertFalse( keywords.hasNext() ); node = parse( writer.toString(), 6); assertNotNull( node ); @@ -92,6 +104,7 @@ public class ContextualParseTest extends CompleteParseBaseTest { assertEquals( node.getCompletionScope(), ((Scope)callback.getCompilationUnit()).getScope() ); assertEquals( node.getCompletionPrefix(), ""); assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.USER_SPECIFIED_NAME ); - + keywords = node.getKeywords(); + assertFalse( keywords.hasNext() ); } } diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser index 59d2c640b62..d7a9f8a851d 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser +++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser @@ -1,3 +1,7 @@ +2003-12-12 John Camelon + Added preliminary keyword support into IASTCompletionNode::getKeywords(). + Refactored parser to put keyword string literals in one utility class. + 2003-12-11 John Camelon Added OffsetLimitReachedException and restructured Parser exceptions. Continued support for code assist/selection search parser. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java new file mode 100644 index 00000000000..f5ebb89d15c --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java @@ -0,0 +1,97 @@ +/********************************************************************** + * 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 Keywords { + + public static final String _BOOL = "_Bool"; + public static final String _COMPLEX = "_Complex"; + public static final String _IMAGINARY = "_Imaginary"; + public static final String AND = "and"; + public static final String AND_EQ = "and_eq"; + public static final String ASM = "asm"; + public static final String AUTO = "auto"; + public static final String BITAND = "bitand"; + public static final String BITOR = "bitor"; + public static final String BOOL = "bool"; + public static final String BREAK = "break"; + public static final String CASE = "case"; + public static final String CATCH = "catch"; + public static final String CHAR = "char"; + public static final String CLASS = "class"; + public static final String COMPL = "compl"; + public static final String CONST = "const"; + public static final String CONST_CAST = "const_cast"; + public static final String CONTINUE = "continue"; + public static final String DEFAULT = "default"; + public static final String DELETE = "delete"; + public static final String DO = "do"; + public static final String DOUBLE = "double"; + public static final String DYNAMIC_CAST = "dynamic_cast"; + public static final String ELSE = "else"; + public static final String ENUM = "enum"; + public static final String EXPLICIT = "explicit"; + public static final String EXPORT = "export"; + public static final String EXTERN = "extern"; + public static final String FALSE = "false"; + public static final String FLOAT = "float"; + public static final String FOR = "for"; + public static final String FRIEND = "friend"; + public static final String GOTO = "goto"; + public static final String IF = "if"; + public static final String INLINE = "inline"; + public static final String INT = "int"; + public static final String LONG = "long"; + public static final String MUTABLE = "mutable"; + public static final String NAMESPACE = "namespace"; + public static final String NEW = "new"; + public static final String NOT = "not"; + public static final String NOT_EQ = "not_eq"; + public static final String OPERATOR = "operator"; + public static final String OR = "or"; + public static final String OR_EQ = "or_eq"; + public static final String PRIVATE = "private"; + public static final String PROTECTED = "protected"; + public static final String PUBLIC = "public"; + public static final String REGISTER = "register"; + public static final String REINTERPRET_CAST = "reinterpret_cast"; + public static final String RESTRICT = "restrict"; + public static final String RETURN = "return"; + public static final String SHORT = "short"; + public static final String SIGNED = "signed"; + public static final String SIZEOF = "sizeof"; + public static final String STATIC = "static"; + public static final String STATIC_CAST = "static_cast"; + public static final String STRUCT = "struct"; + public static final String SWITCH = "switch"; + public static final String TEMPLATE = "template"; + public static final String THIS = "this"; + public static final String THROW = "throw"; + public static final String TRUE = "true"; + public static final String TRY = "try"; + public static final String TYPEDEF = "typedef"; + public static final String TYPEID = "typeid"; + public static final String TYPENAME = "typename"; + public static final String UNION = "union"; + public static final String UNSIGNED = "unsigned"; + public static final String USING = "using"; + public static final String VIRTUAL = "virtual"; + public static final String VOID = "void"; + public static final String VOLATILE = "volatile"; + public static final String WCHAR_T = "wchar_t"; + public static final String WHILE = "while"; + public static final String XOR = "xor"; + public static final String XOR_EQ = "xor_eq"; + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserLanguage.java index f1bfd66ff3a..c97f2f8c9d6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserLanguage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserLanguage.java @@ -25,4 +25,11 @@ public class ParserLanguage extends Enum { { super( value ); } + + /** + * @return + */ + public boolean isCPP() { + return ( this == CPP ); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTCompletionNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTCompletionNode.java index eef0bd9e028..5c3e6e75656 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTCompletionNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTCompletionNode.java @@ -105,7 +105,7 @@ public interface IASTCompletionNode { public String getCompletionPrefix(); /** - * @return + * @return iterator of string keywords */ public Iterator getKeywords(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ContextualParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ContextualParser.java similarity index 69% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ContextualParser.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ContextualParser.java index c1b71095b95..20cd002426c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ContextualParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ContextualParser.java @@ -8,17 +8,29 @@ * Contributors: * IBM Rational Software - Initial API and implementation ***********************************************************************/ -package org.eclipse.cdt.core.parser; +package org.eclipse.cdt.internal.core.parser; -import java.util.HashSet; +import java.util.Iterator; import java.util.Set; +import java.util.TreeSet; +import org.eclipse.cdt.core.parser.BacktrackException; +import org.eclipse.cdt.core.parser.EndOfFileException; +import org.eclipse.cdt.core.parser.IParser; +import org.eclipse.cdt.core.parser.IParserLogService; +import org.eclipse.cdt.core.parser.IScanner; +import org.eclipse.cdt.core.parser.ISourceElementRequestor; +import org.eclipse.cdt.core.parser.IToken; +import org.eclipse.cdt.core.parser.OffsetLimitReachedException; +import org.eclipse.cdt.core.parser.ParserFactory; +import org.eclipse.cdt.core.parser.ParserLanguage; +import org.eclipse.cdt.core.parser.ParserMode; +import org.eclipse.cdt.core.parser.ParserNotImplementedException; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode; import org.eclipse.cdt.core.parser.ast.IASTNode; import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; -import org.eclipse.cdt.internal.core.parser.Parser; -import org.eclipse.cdt.internal.core.parser.ast.*; +import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode; /** * @author jcamelon @@ -29,7 +41,7 @@ public class ContextualParser extends Parser implements IParser { protected IASTScope scope; protected IASTNode context; protected IToken finalToken; - private Set keywordSet = new HashSet(); + private Set keywordSet; /** * @param scanner @@ -49,7 +61,26 @@ public class ContextualParser extends Parser implements IParser { public IASTCompletionNode parse(int offset) throws ParserNotImplementedException { scanner.setOffsetBoundary(offset); translationUnit(); - return new ASTCompletionNode( getCompletionKind(), getCompletionScope(), getCompletionContext(), getCompletionPrefix(), getKeywordSet() ); + return new ASTCompletionNode( getCompletionKind(), getCompletionScope(), getCompletionContext(), getCompletionPrefix(), reconcileKeywords( getKeywordSet(), getCompletionPrefix() ) ); + } + + /** + * @param set + * @param string + * @return + */ + private Set reconcileKeywords(Set keywords, String prefix) { + Set resultSet = new TreeSet(); + Iterator i = keywords.iterator(); + while( i.hasNext() ) + { + String value = (String) i.next(); + if( value.startsWith( prefix ) ) + resultSet.add( value ); + else if( value.compareTo( prefix ) > 0 ) + break; + } + return resultSet; } /** @@ -115,6 +146,7 @@ public class ContextualParser extends Parser implements IParser { this.kind = kind; } + protected void handleFunctionBody(IASTScope scope, boolean isInlineFunction) throws BacktrackException, EndOfFileException { if ( isInlineFunction ) @@ -136,4 +168,11 @@ public class ContextualParser extends Parser implements IParser { throw exception; } + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.parser.Parser#setCompletionKeywords(java.lang.String[]) + */ + protected void setCompletionKeywords(Set keywords) { + this.keywordSet = keywords; + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/KeywordSets.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/KeywordSets.java new file mode 100644 index 00000000000..de239a05b9a --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/KeywordSets.java @@ -0,0 +1,112 @@ +/********************************************************************** + * 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.util.HashSet; +import java.util.Hashtable; +import java.util.Set; +import java.util.TreeSet; + +import org.eclipse.cdt.core.parser.Enum; +import org.eclipse.cdt.core.parser.Keywords; +import org.eclipse.cdt.core.parser.ParserLanguage; + +/** + * @author jcamelon + */ +public class KeywordSets { + + + public static class Key extends Enum + { + public static final Key EMPTY = new Key( 0 ); + public static final Key DECL_SPECIFIER_SEQUENCE = new Key( 1 ); + /** + * @param enumValue + */ + protected Key(int enumValue) { + super(enumValue); + } + + } + + public static Set getKeywords( Key kind, ParserLanguage language ) + { + if( kind == Key.EMPTY ) + return EMPTY; + if( kind == Key.DECL_SPECIFIER_SEQUENCE ) + return (Set) DECL_SPECIFIER_SEQUENCE.get( language ); + + //TODO finish this + return null; + } + + private static final Set EMPTY = new HashSet(); + + private static final Set DECL_SPECIFIER_SEQUENCE_C; + static + { + DECL_SPECIFIER_SEQUENCE_C = new TreeSet(); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.INLINE ); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.AUTO); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.REGISTER); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.STATIC); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.EXTERN); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.MUTABLE); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.TYPEDEF); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.CONST); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.VOLATILE); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.SIGNED); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.UNSIGNED); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.SHORT); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.LONG); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords._COMPLEX); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords._IMAGINARY); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.CHAR); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.WCHAR_T); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords._BOOL); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.INT); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.FLOAT); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.DOUBLE); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.VOID); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.STRUCT); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.UNION); + DECL_SPECIFIER_SEQUENCE_C.add( Keywords.ENUM); + } + + private static final Set DECL_SPECIFIER_SEQUENCE_CPP; + static + { + DECL_SPECIFIER_SEQUENCE_CPP = new TreeSet(); + // add all of C then remove the ones we don't need + DECL_SPECIFIER_SEQUENCE_CPP.addAll( DECL_SPECIFIER_SEQUENCE_C ); + DECL_SPECIFIER_SEQUENCE_CPP.remove( Keywords._COMPLEX); + DECL_SPECIFIER_SEQUENCE_CPP.remove( Keywords._IMAGINARY); + DECL_SPECIFIER_SEQUENCE_CPP.remove( Keywords._BOOL); + // CPP specific stuff + DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.VIRTUAL); + DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.MUTABLE); + DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.EXPLICIT); + DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.FRIEND); + DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.BOOL); + DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.TYPENAME); + DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.CLASS); + } + + private static final Hashtable DECL_SPECIFIER_SEQUENCE; + static + { + DECL_SPECIFIER_SEQUENCE = new Hashtable(); + DECL_SPECIFIER_SEQUENCE.put( ParserLanguage.CPP, DECL_SPECIFIER_SEQUENCE_CPP ); + DECL_SPECIFIER_SEQUENCE.put( ParserLanguage.C, DECL_SPECIFIER_SEQUENCE_C ); + } + +} 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 648b05d6009..fe107d13a8f 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 @@ -10,9 +10,9 @@ ***********************************************************************/ package org.eclipse.cdt.internal.core.parser; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.Set; import java.util.Stack; import org.eclipse.cdt.core.parser.BacktrackException; @@ -931,6 +931,7 @@ public abstract class Parser implements IParser DeclarationWrapper sdw = new DeclarationWrapper(scope, firstToken.getOffset(), ownerTemplate); + setCompletionKeywords( KeywordSets.getKeywords( KeywordSets.Key.DECL_SPECIFIER_SEQUENCE, language ) ); declSpecifierSeq(false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR, sdw ); if (sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.Type.UNSPECIFIED ) try @@ -2685,6 +2686,7 @@ public abstract class Parser implements IParser ITokenDuple duple = null; setCompletionKind( CompletionKind.USER_SPECIFIED_NAME ); + setCompletionKeywords( KeywordSets.getKeywords( KeywordSets.Key.EMPTY, language ) ); // class name if (LT(1) == IToken.tIDENTIFIER) duple = className(); @@ -5278,7 +5280,7 @@ public abstract class Parser implements IParser { } - protected void setCompletionKeywords( Collection keywords ) + protected void setCompletionKeywords( Set keywords ) { } 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 e0876f31984..a15716ca6f7 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 @@ -37,6 +37,7 @@ import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.IToken; +import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.core.parser.NullSourceElementRequestor; import org.eclipse.cdt.core.parser.OffsetLimitReachedException; import org.eclipse.cdt.core.parser.ParserFactory; @@ -1794,80 +1795,80 @@ public class Scanner implements IScanner { static { - cppKeywords.put("and", new Integer(IToken.t_and)); - cppKeywords.put("and_eq", new Integer(IToken.t_and_eq)); - cppKeywords.put("asm", new Integer(IToken.t_asm)); - cppKeywords.put("auto", new Integer(IToken.t_auto)); - cppKeywords.put("bitand", new Integer(IToken.t_bitand)); - cppKeywords.put("bitor", new Integer(IToken.t_bitor)); - cppKeywords.put("bool", new Integer(IToken.t_bool)); - cppKeywords.put("break", new Integer(IToken.t_break)); - cppKeywords.put("case", new Integer(IToken.t_case)); - cppKeywords.put("catch", new Integer(IToken.t_catch)); - cppKeywords.put("char", new Integer(IToken.t_char)); - cppKeywords.put("class", new Integer(IToken.t_class)); - cppKeywords.put("compl", new Integer(IToken.t_compl)); - cppKeywords.put("const", new Integer(IToken.t_const)); - cppKeywords.put("const_cast", new Integer(IToken.t_const_cast)); - cppKeywords.put("continue", new Integer(IToken.t_continue)); - cppKeywords.put("default", new Integer(IToken.t_default)); - cppKeywords.put("delete", new Integer(IToken.t_delete)); - cppKeywords.put("do", new Integer(IToken.t_do)); - cppKeywords.put("double", new Integer(IToken.t_double)); - cppKeywords.put("dynamic_cast", new Integer(IToken.t_dynamic_cast)); - cppKeywords.put("else", new Integer(IToken.t_else)); - cppKeywords.put("enum", new Integer(IToken.t_enum)); - cppKeywords.put("explicit", new Integer(IToken.t_explicit)); - cppKeywords.put("export", new Integer(IToken.t_export)); - cppKeywords.put("extern", new Integer(IToken.t_extern)); - cppKeywords.put("false", new Integer(IToken.t_false)); - cppKeywords.put("float", new Integer(IToken.t_float)); - cppKeywords.put("for", new Integer(IToken.t_for)); - cppKeywords.put("friend", new Integer(IToken.t_friend)); - cppKeywords.put("goto", new Integer(IToken.t_goto)); - cppKeywords.put("if", new Integer(IToken.t_if)); - cppKeywords.put("inline", new Integer(IToken.t_inline)); - cppKeywords.put("int", new Integer(IToken.t_int)); - cppKeywords.put("long", new Integer(IToken.t_long)); - cppKeywords.put("mutable", new Integer(IToken.t_mutable)); - cppKeywords.put("namespace", new Integer(IToken.t_namespace)); - cppKeywords.put("new", new Integer(IToken.t_new)); - cppKeywords.put("not", new Integer(IToken.t_not)); - cppKeywords.put("not_eq", new Integer(IToken.t_not_eq)); - cppKeywords.put("operator", new Integer(IToken.t_operator)); - cppKeywords.put("or", new Integer(IToken.t_or)); - cppKeywords.put("or_eq", new Integer(IToken.t_or_eq)); - cppKeywords.put("private", new Integer(IToken.t_private)); - cppKeywords.put("protected", new Integer(IToken.t_protected)); - cppKeywords.put("public", new Integer(IToken.t_public)); - cppKeywords.put("register", new Integer(IToken.t_register)); - cppKeywords.put("reinterpret_cast", new Integer(IToken.t_reinterpret_cast)); - cppKeywords.put("return", new Integer(IToken.t_return)); - cppKeywords.put("short", new Integer(IToken.t_short)); - cppKeywords.put("signed", new Integer(IToken.t_signed)); - cppKeywords.put("sizeof", new Integer(IToken.t_sizeof)); - cppKeywords.put("static", new Integer(IToken.t_static)); - cppKeywords.put("static_cast", new Integer(IToken.t_static_cast)); - cppKeywords.put("struct", new Integer(IToken.t_struct)); - cppKeywords.put("switch", new Integer(IToken.t_switch)); - cppKeywords.put("template", new Integer(IToken.t_template)); - cppKeywords.put("this", new Integer(IToken.t_this)); - cppKeywords.put("throw", new Integer(IToken.t_throw)); - cppKeywords.put("true", new Integer(IToken.t_true)); - cppKeywords.put("try", new Integer(IToken.t_try)); - cppKeywords.put("typedef", new Integer(IToken.t_typedef)); - cppKeywords.put("typeid", new Integer(IToken.t_typeid)); - cppKeywords.put("typename", new Integer(IToken.t_typename)); - cppKeywords.put("union", new Integer(IToken.t_union)); - cppKeywords.put("unsigned", new Integer(IToken.t_unsigned)); - cppKeywords.put("using", new Integer(IToken.t_using)); - cppKeywords.put("virtual", new Integer(IToken.t_virtual)); - cppKeywords.put("void", new Integer(IToken.t_void)); - cppKeywords.put("volatile", new Integer(IToken.t_volatile)); - cppKeywords.put("wchar_t", new Integer(IToken.t_wchar_t)); - cppKeywords.put("while", new Integer(IToken.t_while)); - cppKeywords.put("xor", new Integer(IToken.t_xor)); - cppKeywords.put("xor_eq", new Integer(IToken.t_xor_eq)); + cppKeywords.put( Keywords.AND, new Integer(IToken.t_and)); + cppKeywords.put( Keywords.AND_EQ, new Integer(IToken.t_and_eq)); + cppKeywords.put( Keywords.ASM, new Integer(IToken.t_asm)); + cppKeywords.put( Keywords.AUTO, new Integer(IToken.t_auto)); + cppKeywords.put( Keywords.BITAND, new Integer(IToken.t_bitand)); + cppKeywords.put( Keywords.BITOR, new Integer(IToken.t_bitor)); + cppKeywords.put( Keywords.BOOL, new Integer(IToken.t_bool)); + cppKeywords.put( Keywords.BREAK, new Integer(IToken.t_break)); + cppKeywords.put( Keywords.CASE, new Integer(IToken.t_case)); + cppKeywords.put( Keywords.CATCH, new Integer(IToken.t_catch)); + cppKeywords.put( Keywords.CHAR, new Integer(IToken.t_char)); + cppKeywords.put( Keywords.CLASS, new Integer(IToken.t_class)); + cppKeywords.put( Keywords.COMPL, new Integer(IToken.t_compl)); + cppKeywords.put( Keywords.CONST, new Integer(IToken.t_const)); + cppKeywords.put( Keywords.CONST_CAST, new Integer(IToken.t_const_cast)); + cppKeywords.put( Keywords.CONTINUE, new Integer(IToken.t_continue)); + cppKeywords.put( Keywords.DEFAULT, new Integer(IToken.t_default)); + cppKeywords.put( Keywords.DELETE, new Integer(IToken.t_delete)); + cppKeywords.put( Keywords.DO, new Integer(IToken.t_do)); + cppKeywords.put( Keywords.DOUBLE, new Integer(IToken.t_double)); + cppKeywords.put( Keywords.DYNAMIC_CAST, new Integer(IToken.t_dynamic_cast)); + cppKeywords.put( Keywords.ELSE, new Integer(IToken.t_else)); + cppKeywords.put( Keywords.ENUM, new Integer(IToken.t_enum)); + cppKeywords.put( Keywords.EXPLICIT, new Integer(IToken.t_explicit)); + cppKeywords.put( Keywords.EXPORT, new Integer(IToken.t_export)); + cppKeywords.put( Keywords.EXTERN, new Integer(IToken.t_extern)); + cppKeywords.put( Keywords.FALSE, new Integer(IToken.t_false)); + cppKeywords.put( Keywords.FLOAT, new Integer(IToken.t_float)); + cppKeywords.put( Keywords.FOR, new Integer(IToken.t_for)); + cppKeywords.put( Keywords.FRIEND, new Integer(IToken.t_friend)); + cppKeywords.put( Keywords.GOTO, new Integer(IToken.t_goto)); + cppKeywords.put( Keywords.IF, new Integer(IToken.t_if)); + cppKeywords.put( Keywords.INLINE, new Integer(IToken.t_inline)); + cppKeywords.put( Keywords.INT, new Integer(IToken.t_int)); + cppKeywords.put( Keywords.LONG, new Integer(IToken.t_long)); + cppKeywords.put( Keywords.MUTABLE, new Integer(IToken.t_mutable)); + cppKeywords.put( Keywords.NAMESPACE, new Integer(IToken.t_namespace)); + cppKeywords.put( Keywords.NEW, new Integer(IToken.t_new)); + cppKeywords.put( Keywords.NOT, new Integer(IToken.t_not)); + cppKeywords.put( Keywords.NOT_EQ, new Integer(IToken.t_not_eq)); + cppKeywords.put( Keywords.OPERATOR, new Integer(IToken.t_operator)); + cppKeywords.put( Keywords.OR, new Integer(IToken.t_or)); + cppKeywords.put( Keywords.OR_EQ, new Integer(IToken.t_or_eq)); + cppKeywords.put( Keywords.PRIVATE, new Integer(IToken.t_private)); + cppKeywords.put( Keywords.PROTECTED, new Integer(IToken.t_protected)); + cppKeywords.put( Keywords.PUBLIC, new Integer(IToken.t_public)); + cppKeywords.put( Keywords.REGISTER, new Integer(IToken.t_register)); + cppKeywords.put( Keywords.REINTERPRET_CAST, new Integer(IToken.t_reinterpret_cast)); + cppKeywords.put( Keywords.RETURN, new Integer(IToken.t_return)); + cppKeywords.put( Keywords.SHORT, new Integer(IToken.t_short)); + cppKeywords.put( Keywords.SIGNED, new Integer(IToken.t_signed)); + cppKeywords.put( Keywords.SIZEOF, new Integer(IToken.t_sizeof)); + cppKeywords.put( Keywords.STATIC, new Integer(IToken.t_static)); + cppKeywords.put( Keywords.STATIC_CAST, new Integer(IToken.t_static_cast)); + cppKeywords.put( Keywords.STRUCT, new Integer(IToken.t_struct)); + cppKeywords.put( Keywords.SWITCH, new Integer(IToken.t_switch)); + cppKeywords.put( Keywords.TEMPLATE, new Integer(IToken.t_template)); + cppKeywords.put( Keywords.THIS, new Integer(IToken.t_this)); + cppKeywords.put( Keywords.THROW, new Integer(IToken.t_throw)); + cppKeywords.put( Keywords.TRUE, new Integer(IToken.t_true)); + cppKeywords.put( Keywords.TRY, new Integer(IToken.t_try)); + cppKeywords.put( Keywords.TYPEDEF, new Integer(IToken.t_typedef)); + cppKeywords.put( Keywords.TYPEID, new Integer(IToken.t_typeid)); + cppKeywords.put( Keywords.TYPENAME, new Integer(IToken.t_typename)); + cppKeywords.put( Keywords.UNION, new Integer(IToken.t_union)); + cppKeywords.put( Keywords.UNSIGNED, new Integer(IToken.t_unsigned)); + cppKeywords.put( Keywords.USING, new Integer(IToken.t_using)); + cppKeywords.put( Keywords.VIRTUAL, new Integer(IToken.t_virtual)); + cppKeywords.put( Keywords.VOID, new Integer(IToken.t_void)); + cppKeywords.put( Keywords.VOLATILE, new Integer(IToken.t_volatile)); + cppKeywords.put( Keywords.WCHAR_T, new Integer(IToken.t_wchar_t)); + cppKeywords.put( Keywords.WHILE, new Integer(IToken.t_while)); + cppKeywords.put( Keywords.XOR, new Integer(IToken.t_xor)); + cppKeywords.put( Keywords.XOR_EQ, new Integer(IToken.t_xor_eq)); ppDirectives.put("#define", new Integer(PreprocessorDirectives.DEFINE)); ppDirectives.put("#undef",new Integer(PreprocessorDirectives.UNDEFINE)); @@ -1885,44 +1886,44 @@ public class Scanner implements IScanner { ppDirectives.put("#elif", new Integer(PreprocessorDirectives.ELIF)); ppDirectives.put("#", new Integer(PreprocessorDirectives.BLANK)); - cKeywords.put("auto", new Integer(IToken.t_auto)); - cKeywords.put("break", new Integer(IToken.t_break)); - cKeywords.put("case", new Integer(IToken.t_case)); - cKeywords.put("char", new Integer(IToken.t_char)); - cKeywords.put("const", new Integer(IToken.t_const)); - cKeywords.put("continue", new Integer(IToken.t_continue)); - cKeywords.put("default", new Integer(IToken.t_default)); - cKeywords.put("delete", new Integer(IToken.t_delete)); - cKeywords.put("do", new Integer(IToken.t_do)); - cKeywords.put("double", new Integer(IToken.t_double)); - cKeywords.put("else", new Integer(IToken.t_else)); - cKeywords.put("enum", new Integer(IToken.t_enum)); - cKeywords.put("extern", new Integer(IToken.t_extern)); - cKeywords.put("float", new Integer(IToken.t_float)); - cKeywords.put("for", new Integer(IToken.t_for)); - cKeywords.put("goto", new Integer(IToken.t_goto)); - cKeywords.put("if", new Integer(IToken.t_if)); - cKeywords.put("inline", new Integer(IToken.t_inline)); - cKeywords.put("int", new Integer(IToken.t_int)); - cKeywords.put("long", new Integer(IToken.t_long)); - cKeywords.put("register", new Integer(IToken.t_register)); - cKeywords.put("restrict", new Integer(IToken.t_restrict)); - cKeywords.put("return", new Integer(IToken.t_return)); - cKeywords.put("short", new Integer(IToken.t_short)); - cKeywords.put("signed", new Integer(IToken.t_signed)); - cKeywords.put("sizeof", new Integer(IToken.t_sizeof)); - cKeywords.put("static", new Integer(IToken.t_static)); - cKeywords.put("struct", new Integer(IToken.t_struct)); - cKeywords.put("switch", new Integer(IToken.t_switch)); - cKeywords.put("typedef", new Integer(IToken.t_typedef)); - cKeywords.put("union", new Integer(IToken.t_union)); - cKeywords.put("unsigned", new Integer(IToken.t_unsigned)); - cKeywords.put("void", new Integer(IToken.t_void)); - cKeywords.put("volatile", new Integer(IToken.t_volatile)); - cKeywords.put("while", new Integer(IToken.t_while)); - cKeywords.put("_Bool", new Integer(IToken.t__Bool)); - cKeywords.put("_Complex", new Integer(IToken.t__Complex)); - cKeywords.put("_Imaginary", new Integer(IToken.t__Imaginary)); + cKeywords.put( Keywords.AUTO, new Integer(IToken.t_auto)); + cKeywords.put( Keywords.BREAK, new Integer(IToken.t_break)); + cKeywords.put( Keywords.CASE, new Integer(IToken.t_case)); + cKeywords.put( Keywords.CHAR, new Integer(IToken.t_char)); + cKeywords.put( Keywords.CONST, new Integer(IToken.t_const)); + cKeywords.put( Keywords.CONTINUE, new Integer(IToken.t_continue)); + cKeywords.put( Keywords.DEFAULT, new Integer(IToken.t_default)); + cKeywords.put( Keywords.DELETE, new Integer(IToken.t_delete)); + cKeywords.put( Keywords.DO, new Integer(IToken.t_do)); + cKeywords.put( Keywords.DOUBLE, new Integer(IToken.t_double)); + cKeywords.put( Keywords.ELSE, new Integer(IToken.t_else)); + cKeywords.put( Keywords.ENUM, new Integer(IToken.t_enum)); + cKeywords.put( Keywords.EXTERN, new Integer(IToken.t_extern)); + cKeywords.put( Keywords.FLOAT, new Integer(IToken.t_float)); + cKeywords.put( Keywords.FOR, new Integer(IToken.t_for)); + cKeywords.put( Keywords.GOTO, new Integer(IToken.t_goto)); + cKeywords.put( Keywords.IF, new Integer(IToken.t_if)); + cKeywords.put( Keywords.INLINE, new Integer(IToken.t_inline)); + cKeywords.put( Keywords.INT, new Integer(IToken.t_int)); + cKeywords.put( Keywords.LONG, new Integer(IToken.t_long)); + cKeywords.put( Keywords.REGISTER, new Integer(IToken.t_register)); + cKeywords.put( Keywords.RESTRICT, new Integer(IToken.t_restrict)); + cKeywords.put( Keywords.RETURN, new Integer(IToken.t_return)); + cKeywords.put( Keywords.SHORT, new Integer(IToken.t_short)); + cKeywords.put( Keywords.SIGNED, new Integer(IToken.t_signed)); + cKeywords.put( Keywords.SIZEOF, new Integer(IToken.t_sizeof)); + cKeywords.put( Keywords.STATIC, new Integer(IToken.t_static)); + cKeywords.put( Keywords.STRUCT, new Integer(IToken.t_struct)); + cKeywords.put( Keywords.SWITCH, new Integer(IToken.t_switch)); + cKeywords.put( Keywords.TYPEDEF, new Integer(IToken.t_typedef)); + cKeywords.put( Keywords.UNION, new Integer(IToken.t_union)); + cKeywords.put( Keywords.UNSIGNED, new Integer(IToken.t_unsigned)); + cKeywords.put( Keywords.VOID, new Integer(IToken.t_void)); + cKeywords.put( Keywords.VOLATILE, new Integer(IToken.t_volatile)); + cKeywords.put( Keywords.WHILE, new Integer(IToken.t_while)); + cKeywords.put( Keywords._BOOL, new Integer(IToken.t__Bool)); + cKeywords.put( Keywords._COMPLEX, new Integer(IToken.t__Complex)); + cKeywords.put( Keywords._IMAGINARY, new Integer(IToken.t__Imaginary)); }