1
/*******************************************************************************
2
* Copyright (c) 2004, 2010, 2013 IBM Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* IBM Corporation - initial implementation
10
* Anton Leherbauer - adding tokens for preprocessing directives
11
* Markus Schorn - classification of preprocessing directives.
12
* Red Hat Inc. - used in SystemTap editor
13
*******************************************************************************/
14
package org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp;
21
public Token(int t, String i) {
26
public Token(int t, String i, ScannerContext context) {
30
public void set(int t, String i, ScannerContext context) {
33
offset = context.getOffset() - text.length() - context.undoStackSize();
37
public String toString() {
38
return "Token type=" + type + " image =" + text + " offset=" + offset; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
41
public int getType() {
45
public String getText() {
49
public int getOffset() {
53
public int getLength() {
57
public int getDelta(Token other) {
58
return other.getOffset() + other.getLength() - getOffset();
61
public boolean looksLikeExpressionStart() {
80
public boolean looksLikeExpressionEnd() {
96
public boolean isPointer() {
97
return (type == tAMPER || type == tSTAR);
100
public boolean isOperator() {
148
public boolean isInfixOperator() {
187
public boolean isPrefixOperator() {
203
public boolean isPostfixOperator() {
213
public boolean isAssignmentOperator() {
214
return isAssignmentOperator(type);
217
public static boolean isAssignmentOperator(int type) {
236
public boolean isControlStmt() {
253
public boolean isWhiteSpace() {
254
return type == tWHITESPACE;
257
public boolean isComment() {
258
return isLineComment() || isBlockComment();
261
public boolean isLineComment() {
262
return type == tLINECOMMENT;
265
public boolean isBlockComment() {
266
return type == tBLOCKCOMMENT;
269
public boolean isCaseLabel() {
270
return type == t_case || type == t_default;
273
public boolean isStructType() {
274
return isStructType(type);
277
public static boolean isStructType(int type) {
278
return type == t_struct || type == t_union || type == t_class;
281
public boolean isVisibilityModifier() {
282
return isVisibilityModifier(type);
285
public static boolean isVisibilityModifier(int type) {
286
return type == t_public || type == t_protected || type == t_private;
289
public boolean isEndOfStatement() {
290
return type == tSEMI || type == tRBRACE;
293
public boolean isCPPToken() {
310
case t_reinterpret_cast:
321
public boolean isStringLiteral() {
322
return type == tSTRING || type == tLSTRING;
326
public boolean isCharacterLiteral() {
327
return type == tCHAR;
331
public boolean isPreprocessor() {
334
case tPREPROCESSOR_DEFINE:
335
case tPREPROCESSOR_INCLUDE:
342
public boolean isIncludeDirective() {
343
return type == tPREPROCESSOR_INCLUDE;
346
public boolean isMacroDefinition() {
347
return type == tPREPROCESSOR_DEFINE;
350
// Special Token types (non-grammar tokens)
351
public static final int tWHITESPACE = 1000;
352
public static final int tLINECOMMENT = 1001;
353
public static final int tBLOCKCOMMENT = 1002;
354
public static final int tPREPROCESSOR = 1003;
355
public static final int tPREPROCESSOR_INCLUDE = 1004;
356
public static final int tPREPROCESSOR_DEFINE = 1005;
357
public static final int tBADCHAR = 1006;
360
static public final int tIDENTIFIER = 1;
361
static public final int tINTEGER = 2;
362
static public final int tCOLONCOLON = 3;
363
static public final int tCOLON = 4;
364
static public final int tSEMI = 5;
365
static public final int tCOMMA = 6;
366
static public final int tQUESTION = 7;
367
static public final int tLPAREN = 8;
368
static public final int tRPAREN = 9;
369
static public final int tLBRACKET = 10;
370
static public final int tRBRACKET = 11;
371
static public final int tLBRACE = 12;
372
static public final int tRBRACE = 13;
373
static public final int tPLUSASSIGN = 14;
374
static public final int tINCR = 15;
375
static public final int tPLUS = 16;
376
static public final int tMINUSASSIGN = 17;
377
static public final int tDECR = 18;
378
static public final int tARROWSTAR = 19;
379
static public final int tARROW = 20;
380
static public final int tMINUS = 21;
381
static public final int tSTARASSIGN = 22;
382
static public final int tSTAR = 23;
383
static public final int tMODASSIGN = 24;
384
static public final int tMOD = 25;
385
static public final int tXORASSIGN = 26;
386
static public final int tXOR = 27;
387
static public final int tAMPERASSIGN = 28;
388
static public final int tAND = 29;
389
static public final int tAMPER = 30;
390
static public final int tBITORASSIGN = 31;
391
static public final int tOR = 32;
392
static public final int tBITOR = 33;
393
static public final int tCOMPL = 34;
394
static public final int tNOTEQUAL = 35;
395
static public final int tNOT = 36;
396
static public final int tEQUAL = 37;
397
static public final int tASSIGN = 38;
398
static public final int tSHIFTL = 40;
399
static public final int tLTEQUAL = 41;
400
static public final int tLT = 42;
401
static public final int tSHIFTRASSIGN = 43;
402
static public final int tSHIFTR = 44;
403
static public final int tGTEQUAL = 45;
404
static public final int tGT = 46;
405
static public final int tSHIFTLASSIGN = 47;
406
static public final int tELIPSE = 48;
407
static public final int tDOTSTAR = 49;
408
static public final int tDOT = 50;
409
static public final int tDIVASSIGN = 51;
410
static public final int tDIV = 52;
411
static public final int tCLASSNAME = 53;
412
static public final int t_and = 54;
413
static public final int t_and_eq = 55;
414
static public final int t_asm = 56;
415
static public final int t_auto = 57;
416
static public final int t_bitand = 58;
417
static public final int t_bitor = 59;
418
static public final int t_bool = 60;
419
static public final int t_break = 61;
420
static public final int t_case = 62;
421
static public final int t_catch = 63;
422
static public final int t_char = 64;
423
static public final int t_class = 65;
424
static public final int t_compl = 66;
425
static public final int t_const = 67;
426
static public final int t_const_cast = 69;
427
static public final int t_continue = 70;
428
static public final int t_default = 71;
429
static public final int t_delete = 72;
430
static public final int t_do = 73;
431
static public final int t_double = 74;
432
static public final int t_dynamic_cast = 75;
433
static public final int t_else = 76;
434
static public final int t_enum = 77;
435
static public final int t_explicit = 78;
436
static public final int t_export = 79;
437
static public final int t_extern = 80;
438
static public final int t_false = 81;
439
static public final int t_float = 82;
440
static public final int t_for = 83;
441
static public final int t_friend = 84;
442
static public final int t_goto = 85;
443
static public final int t_if = 86;
444
static public final int t_inline = 87;
445
static public final int t_int = 88;
446
static public final int t_long = 89;
447
static public final int t_mutable = 90;
448
static public final int t_namespace = 91;
449
static public final int t_new = 92;
450
static public final int t_not = 93;
451
static public final int t_not_eq = 94;
452
static public final int t_operator = 95;
453
static public final int t_or = 96;
454
static public final int t_or_eq = 97;
455
static public final int t_private = 98;
456
static public final int t_protected = 99;
457
static public final int t_public = 100;
458
static public final int t_register = 101;
459
static public final int t_reinterpret_cast = 102;
460
static public final int t_return = 103;
461
static public final int t_short = 104;
462
static public final int t_sizeof = 105;
463
static public final int t_static = 106;
464
static public final int t_static_cast = 107;
465
static public final int t_signed = 108;
466
static public final int t_struct = 109;
467
static public final int t_switch = 110;
468
static public final int t_template = 111;
469
static public final int t_this = 112;
470
static public final int t_throw = 113;
471
static public final int t_true = 114;
472
static public final int t_try = 115;
473
static public final int t_typedef = 116;
474
static public final int t_typeid = 117;
475
static public final int t_typename = 118;
476
static public final int t_union = 119;
477
static public final int t_unsigned = 120;
478
static public final int t_using = 121;
479
static public final int t_virtual = 122;
480
static public final int t_void = 123;
481
static public final int t_volatile = 124;
482
static public final int t_wchar_t = 125;
483
static public final int t_while = 126;
484
static public final int t_xor = 127;
485
static public final int t_xor_eq = 128;
486
static public final int tSTRING = 129;
487
static public final int tFLOATINGPT = 130;
488
static public final int tLSTRING = 131;
489
static public final int tCHAR = 132;
490
static public final int tRSTRING = 133;
491
static public final int t_restrict = 136;
492
static public final int t_interface = 200;
493
static public final int t_import = 201;
494
static public final int t_instanceof = 202;
495
static public final int t_extends = 203;
496
static public final int t_implements = 204;
497
static public final int t_final = 205;
498
static public final int t_super = 206;
499
static public final int t_package = 207;
500
static public final int t_boolean = 208;
501
static public final int t_abstract = 209;
502
static public final int t_finally = 210;
503
static public final int t_null = 211;
504
static public final int t_synchronized = 212;
505
static public final int t_throws = 213;
506
static public final int t_byte = 214;
507
static public final int t_transient = 215;
508
static public final int t_native = 216;