001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.cnd.apt.impl.support;
043:
044: import org.netbeans.modules.cnd.apt.support.APTTokenTypes;
045: import org.netbeans.modules.cnd.apt.support.APTTokenAbstact;
046:
047: /**
048: *
049: * @author gorrus
050: */
051: public class APTConstTextToken extends APTTokenAbstact implements
052: APTTokenTypes {
053: private final static String[] constText = new String[300];
054:
055: protected int type = INVALID_TYPE;
056: protected int offset;
057: //protected int endOffset;
058: protected int line;
059: protected int column;
060:
061: /**
062: * Creates a new instance of APTConstTextToken
063: */
064: public APTConstTextToken() {
065: }
066:
067: static {
068: //setup const text values
069: constText[EOF] = ""; // NOI18N
070:
071: // 1 symbol:
072: constText[FUN_LIKE_MACRO_LPAREN] = "("; // NOI18N
073: constText[ASSIGNEQUAL] = "="; // NOI18N
074: constText[DIVIDE] = "/"; // NOI18N
075: constText[STAR] = "*"; // NOI18N
076: constText[MOD] = "%"; // NOI18N
077: constText[NOT] = "!"; // NOI18N
078: constText[AMPERSAND] = "&"; // NOI18N
079: constText[BITWISEOR] = "|"; // NOI18N
080: constText[BITWISEXOR] = "^"; // NOI18N
081: constText[COLON] = ":"; // NOI18N
082: constText[LESSTHAN] = "<"; // NOI18N
083: constText[GREATERTHAN] = ">"; // NOI18N
084: constText[MINUS] = "-"; // NOI18N
085: constText[PLUS] = "+"; // NOI18N
086: constText[SHARP] = "#"; // NOI18N
087: constText[SEMICOLON] = ";"; // NOI18N
088: constText[RPAREN] = ")"; // NOI18N
089: constText[DOLLAR] = "$"; // NOI18N
090: constText[RCURLY] = "}"; // NOI18N
091: constText[AT] = "@"; // NOI18N
092: constText[LPAREN] = "("; // NOI18N
093: constText[QUESTIONMARK] = "?"; // NOI18N
094: constText[LCURLY] = "{"; // NOI18N
095: constText[COMMA] = ","; // NOI18N
096: constText[LSQUARE] = "["; // NOI18N
097: constText[RSQUARE] = "]"; // NOI18N
098: constText[TILDE] = "~"; // NOI18N
099: constText[DOT] = "."; // NOI18N
100: constText[BACK_SLASH] = "\\"; // NOI18N
101:
102: // 2 symbol:
103: constText[BITWISEANDEQUAL] = "&="; // NOI18N
104: constText[AND] = "&&"; // NOI18N
105: constText[NOTEQUAL] = "!="; // NOI18N
106: constText[MODEQUAL] = "%="; // NOI18N
107: constText[TIMESEQUAL] = "*="; // NOI18N
108: constText[DIVIDEEQUAL] = "/="; // NOI18N
109: constText[EQUAL] = "=="; // NOI18N
110: constText[BITWISEOREQUAL] = "|="; // NOI18N
111: constText[OR] = "||"; // NOI18N
112: constText[BITWISEXOREQUAL] = "^="; // NOI18N
113: constText[SCOPE] = "::"; // NOI18N
114: constText[LESSTHANOREQUALTO] = "<="; // NOI18N
115: constText[SHIFTLEFT] = "<<"; // NOI18N
116: constText[GREATERTHANOREQUALTO] = ">="; // NOI18N
117: constText[SHIFTRIGHT] = ">>"; // NOI18N
118: constText[MINUSEQUAL] = "-="; // NOI18N
119: constText[MINUSMINUS] = "--"; // NOI18N
120: constText[POINTERTO] = "->"; // NOI18N
121: constText[PLUSEQUAL] = "+="; // NOI18N
122: constText[PLUSPLUS] = "++"; // NOI18N
123: constText[DBL_SHARP] = "##"; // NOI18N
124: constText[DOTMBR] = ".*"; // NOI18N
125:
126: // 3 symbol:
127: constText[SHIFTLEFTEQUAL] = "<<="; // NOI18N
128: constText[SHIFTRIGHTEQUAL] = ">>="; // NOI18N
129: constText[POINTERTOMBR] = "->*"; // NOI18N
130: constText[ELLIPSIS] = "..."; // NOI18N
131:
132: // more
133: constText[DEFINED] = "defined"; // NOI18N
134: }
135:
136: public String getText() {
137: //assert(constText[getType()] != null) : "Not initialized ConstText for type " + getType(); // NOI18N
138: return constText[getType()];
139: }
140:
141: public void setText(String t) {
142: //assert(true) : "setText should not be called for ConstText token"; // NOI18N
143: /*String existingText = getText();
144: if (existingText != null) {
145: /*if (!existingText.equals(t)) {
146: System.out.println(getType() + ", Old=" + existingText + ", New=" + t); // NOI18N
147: }*/
148: //assert(existingText.equals(t));
149: /*} else {
150: constText[getType()] = t;
151: }*/
152: }
153:
154: public int getEndOffset() {
155: return getOffset() + getText().length();
156: //return endOffset;
157: }
158:
159: public int getEndLine() {
160: return getLine();
161: }
162:
163: public int getEndColumn() {
164: return getColumn() + getText().length();
165: }
166:
167: public int getColumn() {
168: return column;
169: }
170:
171: public void setLine(int l) {
172: line = l;
173: }
174:
175: public void setOffset(int o) {
176: offset = o;
177: }
178:
179: public int getOffset() {
180: return offset;
181: }
182:
183: public void setType(int t) {
184: type = t;
185: }
186:
187: public int getType() {
188: return type;
189: }
190:
191: public int getLine() {
192: return line;
193: }
194:
195: public void setColumn(int c) {
196: column = c;
197: }
198: }
|