1 package net.sf.saxon.expr; 2 3 import java.util.HashMap ; 4 5 9 10 public abstract class Token { 11 12 17 18 21 public static final int EOF = 0; 22 25 public static final int UNION = 1; 26 29 public static final int SLASH = 2; 30 33 public static final int AT = 3; 34 37 public static final int LSQB = 4; 38 41 public static final int LPAR = 5; 42 45 public static final int EQUALS = 6; 46 49 public static final int COMMA = 7; 50 53 public static final int SLSL = 8; 54 57 public static final int OR = 9; 58 61 public static final int AND = 10; 62 65 public static final int GT = 11; 66 69 public static final int LT = 12; 70 73 public static final int GE = 13; 74 77 public static final int LE = 14; 78 81 public static final int PLUS = 15; 82 85 public static final int MINUS = 16; 86 89 public static final int MULT = 17; 90 93 public static final int DIV = 18; 94 97 public static final int MOD = 19; 98 101 public static final int IS = 20; 102 105 public static final int DOLLAR = 21; 106 109 public static final int NE = 22; 110 113 public static final int INTERSECT = 23; 114 117 public static final int EXCEPT = 24; 118 121 public static final int RETURN = 25; 122 125 public static final int THEN = 26; 126 129 public static final int ELSE = 27; 130 133 public static final int WHERE = 28; 134 137 public static final int TO = 29; 138 141 public static final int IN = 30; 142 145 public static final int SOME = 31; 146 149 public static final int EVERY = 32; 150 153 public static final int SATISFIES = 33; 154 157 public static final int FUNCTION = 34; 158 161 public static final int AXIS = 35; 162 165 public static final int IF = 36; 166 169 public static final int PRECEDES = 37; 170 173 public static final int FOLLOWS = 38; 174 177 public static final int COLONCOLON = 39; 178 181 public static final int COLONSTAR = 40; 182 185 public static final int INSTANCE_OF = 41; 186 189 public static final int CAST_AS = 42; 190 193 public static final int TREAT_AS = 43; 194 197 public static final int FEQ = 44; 201 public static final int FNE = 45; 202 205 public static final int FGT = 46; 206 209 public static final int FLT = 47; 210 213 public static final int FGE = 48; 214 217 public static final int FLE = 49; 218 221 public static final int IDIV = 50; 222 225 public static final int CASTABLE_AS = 51; 226 229 public static final int ASSIGN = 52; 230 233 public static final int LCURLY = 53; 234 237 public static final int KEYWORD_CURLY = 54; 238 241 public static final int ELEMENT_QNAME = 55; 242 245 public static final int ATTRIBUTE_QNAME = 56; 246 249 public static final int PI_QNAME = 57; 250 253 public static final int TYPESWITCH = 58; 254 257 public static final int CASE = 59; 258 261 public static final int DEFAULT = 60; 262 265 public static final int NODEKIND = 61; 266 267 268 272 273 276 public static final int XQUERY_VERSION = 70; 277 280 public static final int DECLARE_NAMESPACE = 71; 281 284 public static final int DECLARE_DEFAULT = 72; 285 288 public static final int DECLARE_CONSTRUCTION = 73; 289 292 public static final int DECLARE_BASEURI = 74; 293 296 public static final int DECLARE_BOUNDARY_SPACE = 75; 297 300 public static final int IMPORT_SCHEMA = 76; 301 304 public static final int IMPORT_MODULE = 77; 305 308 public static final int DECLARE_VARIABLE = 78; 309 312 public static final int DECLARE_FUNCTION = 79; 313 316 public static final int MODULE_NAMESPACE = 80; 317 320 public static final int VALIDATE = 81; 321 public static final int VALIDATE_STRICT = 82; 322 public static final int VALIDATE_LAX = 83; 323 324 327 public static final int DECLARE_ORDERING = 84; 328 329 332 public static final int DECLARE_COPY_NAMESPACES = 85; 333 336 public static final int DECLARE_OPTION = 86; 337 340 public static final int SEMICOLON = 90; 341 342 343 346 static int LAST_OPERATOR = 100; 347 348 351 354 public static final int NAME = 101; 355 358 public static final int STRING_LITERAL = 102; 359 362 public static final int RSQB = 103; 363 366 public static final int RPAR = 104; 367 370 public static final int DOT = 105; 371 374 public static final int DOTDOT = 106; 375 378 public static final int STAR = 107; 379 382 public static final int PREFIX = 108; 386 public static final int NUMBER = 109; 387 388 391 public static final int FOR = 111; 392 395 public static final int SUFFIX = 112; 399 public static final int QMARK = 113; 400 403 public static final int RCURLY = 115; 404 407 public static final int LET = 116; 408 412 public static final int TAG = 117; 413 417 public static final int PRAGMA = 118; 418 419 420 423 public static final int NEGATE = 199; 426 427 430 431 public static String [] tokens = new String [200]; 432 static { 433 tokens [ EOF ] = "<eof>"; 434 tokens [ UNION ] = "|"; 435 tokens [ SLASH ] = "/"; 436 tokens [ AT ] = "@"; 437 tokens [ LSQB ] = "["; 438 tokens [ LPAR ] = "("; 439 tokens [ EQUALS ] = "="; 440 tokens [ COMMA ] = ","; 441 tokens [ SLSL ] = "//"; 442 tokens [ OR ] = "or"; 443 tokens [ AND ] = "and"; 444 tokens [ GT ] = ">"; 445 tokens [ LT ] = "<"; 446 tokens [ GE ] = ">="; 447 tokens [ LE ] = "<="; 448 tokens [ PLUS ] = "+"; 449 tokens [ MINUS ] = "-"; 450 tokens [ MULT ] = "*"; 451 tokens [ DIV ] = "div"; 452 tokens [ MOD ] = "mod"; 453 tokens [ IS ] = "is"; 454 tokens [ DOLLAR ] = "$"; 455 tokens [ NE ] = "!="; 456 tokens [ INTERSECT ] = "intersect"; 457 tokens [ EXCEPT ] = "except"; 458 tokens [ RETURN ] = "return"; 459 tokens [ THEN ] = "then"; 460 tokens [ ELSE ] = "else"; 461 tokens [ TO ] = "to"; 463 tokens [ IN ] = "in"; 464 tokens [ SOME ] = "some"; 465 tokens [ EVERY ] = "every"; 466 tokens [ SATISFIES ] = "satisfies"; 467 tokens [ FUNCTION ] = "<function>("; 468 tokens [ AXIS ] = "<axis>"; 469 tokens [ IF ] = "if("; 470 tokens [ PRECEDES ] = "<<"; 471 tokens [ FOLLOWS ] = ">>"; 472 tokens [ COLONCOLON ] = "::"; 473 tokens [ COLONSTAR ] = ":*"; 474 tokens [ INSTANCE_OF ] = "instance of"; 475 tokens [ CAST_AS ] = "cast as"; 476 tokens [ TREAT_AS ] = "treat as"; 477 tokens [ FEQ ] = "eq"; 478 tokens [ FNE ] = "ne"; 479 tokens [ FGT ] = "gt"; 480 tokens [ FGE ] = "ge"; 481 tokens [ FLT ] = "lt"; 482 tokens [ FLE ] = "le"; 483 tokens [ IDIV ] = "idiv"; 484 tokens [ CASTABLE_AS ] = "castable as"; 485 tokens [ ASSIGN ] = ":="; 486 tokens [ TYPESWITCH ] = "typeswitch"; 487 tokens [ CASE ] = "case"; 488 tokens [ DEFAULT ] = "default"; 489 490 491 tokens [ NAME ] = "<name>"; 492 tokens [ STRING_LITERAL ] = "<string-literal>"; 493 tokens [ RSQB ] = "]"; 494 tokens [ RPAR ] = ")"; 495 tokens [ DOT ] = "."; 496 tokens [ DOTDOT ] = ".."; 497 tokens [ STAR ] = "*"; 498 tokens [ PREFIX ] = "<prefix:*>"; 499 tokens [ NUMBER ] = "<numeric-literal>"; 500 tokens [ NODEKIND ] = "<node-type>()"; 501 tokens [ FOR ] = "for"; 502 tokens [ SUFFIX ] = "<*:local-name>"; 503 tokens [ QMARK ] = "?"; 504 tokens [ LCURLY ] = "{"; 505 tokens [ KEYWORD_CURLY ] = "<keyword> {"; 506 tokens [ RCURLY ] = "}"; 507 tokens [ LET ] = "let"; 508 tokens [ VALIDATE ] = "validate {"; 509 tokens [ TAG ] = "<element>"; 510 tokens [ PRAGMA ] = "(# ... #)"; 511 tokens [ SEMICOLON ] = ";"; 512 tokens [ NEGATE ] = "-"; 513 } 514 515 518 public static HashMap doubleKeywords = new HashMap (30); 519 522 public static final int UNKNOWN = -1; 523 524 private Token() { 525 } 526 527 static { 528 mapDouble("instance of", INSTANCE_OF); 529 mapDouble("cast as", CAST_AS); 530 mapDouble("treat as", TREAT_AS); 531 mapDouble("castable as", CASTABLE_AS); 532 mapDouble("xquery version", XQUERY_VERSION); 533 mapDouble("declare namespace", DECLARE_NAMESPACE); 534 mapDouble("declare default", DECLARE_DEFAULT); 535 mapDouble("declare construction", DECLARE_CONSTRUCTION); 536 mapDouble("declare base-uri", DECLARE_BASEURI); 537 mapDouble("declare boundary-space", DECLARE_BOUNDARY_SPACE); 538 mapDouble("declare ordering", DECLARE_ORDERING); 539 mapDouble("declare copy-namespaces", DECLARE_COPY_NAMESPACES); 540 mapDouble("declare option", DECLARE_OPTION); 541 mapDouble("import schema", IMPORT_SCHEMA); 542 mapDouble("import module", IMPORT_MODULE); 543 mapDouble("declare variable", DECLARE_VARIABLE); 544 mapDouble("declare function", DECLARE_FUNCTION); 545 mapDouble("module namespace", MODULE_NAMESPACE); 546 mapDouble("validate strict", VALIDATE_STRICT); 547 mapDouble("validate lax", VALIDATE_LAX); 548 549 } 550 551 private static void mapDouble(String doubleKeyword, int token) { 552 doubleKeywords.put(doubleKeyword, new Integer (token)); 553 tokens[token] = doubleKeyword; 554 } 555 556 560 561 public static final int inverse(int operator) { 562 switch(operator) { 563 case LT: 564 return GT; 565 case LE: 566 return GE; 567 case GT: 568 return LT; 569 case GE: 570 return LE; 571 case FLT: 572 return FGT; 573 case FLE: 574 return FGE; 575 case FGT: 576 return FLT; 577 case FGE: 578 return FLE; 579 default: 580 return operator; 581 } 582 } 583 } 584 585 | Popular Tags |