1 (* 2 * The contents of this file are subject to the Mozilla Public License 3 * Version 1.1 (the "License"); you may not use this file except in 4 * compliance with the License. You may obtain a copy of the License at 5 * http://www.mozilla.org/MPL/ 6 * 7 * Software distributed under the License is distributed on an "AS IS" 8 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 9 * License for the specific language governing rights and limitations 10 * under the License. 11 * 12 * The Initial Developer of this code is John Hansen. 13 * Portions created by John Hansen are Copyright (C) 2009 John Hansen. 14 * All Rights Reserved. 15 * 16 *) 17 unit uNXCLexer; 18 19 interface 20 21 uses 22 Classes, uGenLexer; 23 24 type 25 TNXCLexer = class(TGenLexer) 26 protected 27 procedure InitForLanguage(Lex: TGenLexer); override; 28 end; 29 30 implementation 31 32 uses 33 SysUtils, mwGenericLex; 34 35 { TNXCLexer } 36 37 procedure TNXCLexer.InitForLanguage(Lex: TGenLexer); 38 var 39 Pat, OptPat, Temp: TAny; 40 begin 41 { Space} 42 Pat := TAny.Create(nil); 43 Pat.CharClass := [#1..#9, #11, #12, #14..#32]; 44 Pat.Id := piSpace; 45 Lex.Add(Pat); 46 47 { LineEnd} 48 Pat := TAny.Create(nil); 49 Pat.Kind := pkLineEnd; 50 Pat.Id := piLineEnd; 51 Pat.Max := 1; 52 Lex.Add(Pat); 53 54 { Identifier} 55 Pat := TIdentifier.Create(nil); 56 Lex.Add(Pat); 57 58 // TODO: need to try to add support for \" 59 { String } 60 Pat := TAny.Create(nil); 61 Pat.Key := '"'; 62 Lex.Add(Pat); 63 Pat := TAny.Create(Pat); 64 Pat.Key := '"'; 65 Pat.Min := 1; 66 Pat.Max := 1; 67 Pat.Id := piString; 68 Pat.Kind := pkTillKey; 69 Temp:= Pat; 70 Pat := TAny.Create(Pat); 71 Pat.Key := '"'; 72 Pat.Id := piBadString; 73 Pat.Min := 1; 74 Pat.Max := 1; 75 Pat.Regress := True; 76 Pat.ToRegress := Temp; 77 78 // TODO: need to try to add support for \' 79 { String } 80 Pat := TAny.Create(nil); 81 Pat.Key := ''''; 82 Lex.Add(Pat); 83 Pat := TAny.Create(Pat); 84 Pat.Key := ''''; 85 Pat.Min := 1; 86 Pat.Max := 1; 87 Pat.Id := piChar; 88 Pat.Kind := pkTillKey; 89 Temp:= Pat; 90 Pat := TAny.Create(Pat); 91 Pat.Key := ''''; 92 Pat.Id := piBadString; 93 Pat.Min := 1; 94 Pat.Max := 1; 95 Pat.Regress := True; 96 Pat.ToRegress := Temp; 97 98 { Symbol, Comment } 99 Pat := TAny.Create(nil); 100 Pat.Key := '/*'; 101 Pat.Min := 1; 102 Lex.Add(Pat); 103 OptPat := TAny.Create(nil); 104 OptPat.Key := '//'; 105 OptPat.Id := piComment; 106 OptPat.Min := 1; 107 Pat.AddOption(OptPat); 108 OptPat := TTillLineEnd.Create(OptPat); 109 OptPat.Id := piComment; 110 OptPat := TAny.Create(nil); // divided-by-equals symbol 111 OptPat.Key := '/='; 112 OptPat.Min := 1; 113 OptPat.Id := piSymbol; 114 Pat.AddOption(OptPat); 115 OptPat := TAny.Create(nil); 116 OptPat.Key := '/'; 117 OptPat.Min := 1; 118 OptPat.Id := piSymbol; 119 Pat.AddOption(OptPat); 120 Pat := TAny.Create(Pat); 121 Pat.Key := '*/'; 122 Pat.Id := piComment; 123 Pat.Kind := pkTillKey; 124 Pat.MultiLine := True; 125 126 { Number } 127 Pat := TAny.Create(nil); 128 Pat.CharClass := ['1'..'9']; 129 Pat.Min := 1; 130 Pat.Id := piNumber; 131 Lex.Add(Pat); 132 Pat := TAny.Create(Pat); 133 Pat.CharClass := ['0'..'9']; 134 Pat.Id := piNumber; 135 136 { Number } 137 Pat := TAny.Create(nil); 138 Pat.Key := '0x'; 139 Pat.Id := piNumber; 140 Pat.Min := 1; 141 Pat.Max := 2; 142 Lex.Add(Pat); 143 OptPat := TAny.Create(nil); 144 OptPat.Key := '0'; 145 OptPat.Min := 1; 146 OptPat.Id := piNumber; 147 Pat.AddOption(OptPat); 148 Pat := TAny.Create(Pat); 149 Pat.CharClass := ['0'..'9', 'A'..'F', 'a'..'f']; 150 Pat.Id := piNumber; 151 152 { Symbol } 153 Pat := TAny.Create(nil); 154 Pat.Key := '||='; 155 Pat.Min := 1; 156 Lex.Add(Pat); 157 OptPat := TAny.Create(nil); 158 OptPat.Key := '||'; 159 OptPat.Min := 1; 160 Pat.AddOption(OptPat); 161 OptPat := TAny.Create(nil); 162 OptPat.Key := '|='; 163 OptPat.Min := 1; 164 Pat.AddOption(OptPat); 165 OptPat := TAny.Create(nil); 166 OptPat.Key := '|'; 167 OptPat.Min := 1; 168 Pat.AddOption(OptPat); 169 170 171 { Symbol } 172 Pat := TAny.Create(nil); 173 Pat.Key := '&&'; 174 Pat.Min := 1; 175 Lex.Add(Pat); 176 OptPat := TAny.Create(nil); 177 OptPat.Key := '&='; 178 OptPat.Min := 1; 179 Pat.AddOption(OptPat); 180 OptPat := TAny.Create(nil); 181 OptPat.Key := '&'; 182 OptPat.Min := 1; 183 Pat.AddOption(OptPat); 184 185 { Symbol } 186 Pat := TAny.Create(nil); 187 Pat.Key := '!='; 188 Pat.Min := 1; 189 Lex.Add(Pat); 190 OptPat := TAny.Create(nil); 191 OptPat.Key := '!'; 192 OptPat.Min := 1; 193 Pat.AddOption(OptPat); 194 195 { Symbol } 196 Pat := TAny.Create(nil); 197 Pat.Key := '*='; 198 Pat.Min := 1; 199 Lex.Add(Pat); 200 OptPat := TAny.Create(nil); 201 OptPat.Key := '*'; 202 OptPat.Min := 1; 203 Pat.AddOption(OptPat); 204 205 { Symbol } 206 Pat := TAny.Create(nil); 207 Pat.Key := '<='; 208 Pat.Min := 1; 209 Lex.Add(Pat); 210 OptPat := TAny.Create(nil); 211 OptPat.Key := '<<'; 212 OptPat.Min := 1; 213 Pat.AddOption(OptPat); 214 OptPat := TAny.Create(nil); 215 OptPat.Key := '<'; 216 OptPat.Min := 1; 217 Pat.AddOption(OptPat); 218 219 { Symbol } 220 Pat := TAny.Create(nil); 221 Pat.Key := '>='; 222 Pat.Min := 1; 223 Lex.Add(Pat); 224 OptPat := TAny.Create(nil); 225 OptPat.Key := '>>'; 226 OptPat.Min := 1; 227 Pat.AddOption(OptPat); 228 OptPat := TAny.Create(nil); 229 OptPat.Key := '>'; 230 OptPat.Min := 1; 231 Pat.AddOption(OptPat); 232 233 { Symbol } 234 Pat := TAny.Create(nil); 235 Pat.Key := '=='; 236 Pat.Min := 1; 237 Lex.Add(Pat); 238 OptPat := TAny.Create(nil); 239 OptPat.Key := '='; 240 OptPat.Min := 1; 241 Pat.AddOption(OptPat); 242 243 { Symbol } 244 Pat := TAny.Create(nil); 245 Pat.Key := '+-='; 246 Pat.Min := 1; 247 Lex.Add(Pat); 248 OptPat := TAny.Create(nil); 249 OptPat.Key := '+='; 250 OptPat.Min := 1; 251 Pat.AddOption(OptPat); 252 OptPat := TAny.Create(nil); 253 OptPat.Key := '++'; 254 OptPat.Min := 1; 255 Pat.AddOption(OptPat); 256 OptPat := TAny.Create(nil); 257 OptPat.Key := '+'; 258 OptPat.Min := 1; 259 Pat.AddOption(OptPat); 260 261 { Symbol } 262 Pat := TAny.Create(nil); 263 Pat.Key := '-='; 264 Pat.Min := 1; 265 Lex.Add(Pat); 266 OptPat := TAny.Create(nil); 267 OptPat.Key := '--'; 268 OptPat.Min := 1; 269 Pat.AddOption(OptPat); 270 OptPat := TAny.Create(nil); 271 OptPat.Key := '-'; 272 OptPat.Min := 1; 273 Pat.AddOption(OptPat); 274 275 { Symbol (VA_ARGS), Symbol (period)} 276 Pat := TAny.Create(nil); 277 Pat.Key:= '...'; 278 Pat.Id:= piSymbol; 279 Pat.Min:= 1; 280 TAlphaNumeric.Create(Pat); 281 Lex.Add(Pat); 282 OptPat := TAny.Create(nil); 283 OptPat.Key := '.'; 284 OptPat.Id:= piSymbol; 285 OptPat.Min:= 1; 286 Pat.AddOption(OptPat); 287 TAlphaNumeric.Create(OptPat); 288 Pat.AddOption(TIdentifier.Create(nil)); 289 290 { Directive, Identifier} 291 Pat := TAny.Create(nil); 292 Pat.Key:= '#download'; 293 Pat.Id:= piDirective; 294 Pat.Min:= 1; 295 TAlphaNumeric.Create(Pat); 296 Lex.Add(Pat); 297 OptPat := TAny.Create(nil); 298 OptPat.Key := '#include'; 299 OptPat.Id:= piDirective; 300 OptPat.Min:= 1; 301 Pat.AddOption(OptPat); 302 TAlphaNumeric.Create(OptPat); 303 OptPat := TAny.Create(nil); 304 OptPat.Key := '#define'; 305 OptPat.Id:= piDirective; 306 OptPat.Min:= 1; 307 Pat.AddOption(OptPat); 308 TAlphaNumeric.Create(OptPat); 309 OptPat := TAny.Create(nil); 310 OptPat.Key := '#ifndef'; 311 OptPat.Id:= piDirective; 312 OptPat.Min:= 1; 313 Pat.AddOption(OptPat); 314 TAlphaNumeric.Create(OptPat); 315 OptPat := TAny.Create(nil); 316 OptPat.Key := '#import'; 317 OptPat.Id:= piDirective; 318 OptPat.Min:= 1; 319 Pat.AddOption(OptPat); 320 TAlphaNumeric.Create(OptPat); 321 OptPat := TAny.Create(nil); 322 OptPat.Key := '#pragma'; 323 OptPat.Id:= piDirective; 324 OptPat.Min:= 1; 325 Pat.AddOption(OptPat); 326 TAlphaNumeric.Create(OptPat); 327 OptPat := TAny.Create(nil); 328 OptPat.Key := '#endif'; 329 OptPat.Id:= piDirective; 330 OptPat.Min:= 1; 331 Pat.AddOption(OptPat); 332 TAlphaNumeric.Create(OptPat); 333 OptPat := TAny.Create(nil); 334 OptPat.Key := '#error'; 335 OptPat.Id:= piDirective; 336 OptPat.Min:= 1; 337 Pat.AddOption(OptPat); 338 TAlphaNumeric.Create(OptPat); 339 OptPat := TAny.Create(nil); 340 OptPat.Key := '#ifdef'; 341 OptPat.Id:= piDirective; 342 OptPat.Min:= 1; 343 Pat.AddOption(OptPat); 344 TAlphaNumeric.Create(OptPat); 345 OptPat := TAny.Create(nil); 346 OptPat.Key := '#reset'; 347 OptPat.Id:= piDirective; 348 OptPat.Min:= 1; 349 Pat.AddOption(OptPat); 350 TAlphaNumeric.Create(OptPat); 351 OptPat := TAny.Create(nil); 352 OptPat.Key := '#undef'; 353 OptPat.Id:= piDirective; 354 OptPat.Min:= 1; 355 Pat.AddOption(OptPat); 356 TAlphaNumeric.Create(OptPat); 357 OptPat := TAny.Create(nil); 358 OptPat.Key := '#elif'; 359 OptPat.Id:= piDirective; 360 OptPat.Min:= 1; 361 Pat.AddOption(OptPat); 362 TAlphaNumeric.Create(OptPat); 363 OptPat := TAny.Create(nil); 364 OptPat.Key := '#else'; 365 OptPat.Id:= piDirective; 366 OptPat.Min:= 1; 367 Pat.AddOption(OptPat); 368 TAlphaNumeric.Create(OptPat); 369 OptPat := TAny.Create(nil); 370 OptPat.Key := '#line'; 371 OptPat.Id:= piDirective; 372 OptPat.Min:= 1; 373 Pat.AddOption(OptPat); 374 TAlphaNumeric.Create(OptPat); 375 OptPat := TAny.Create(nil); 376 OptPat.Key := '#if'; 377 OptPat.Id:= piDirective; 378 OptPat.Min:= 1; 379 Pat.AddOption(OptPat); 380 TAlphaNumeric.Create(OptPat); 381 OptPat := TAny.Create(nil); 382 OptPat.Key := '#'; 383 OptPat.Min := 1; 384 OptPat.Id := piSymbol; 385 Pat.AddOption(OptPat); 386 Pat.AddOption(TIdentifier.Create(nil)); 387 388 { KeyWord, Identifier} 389 Pat := TAny.Create(nil); 390 Pat.Key:= '__TMPBYTE__'; 391 Pat.Id:= piKeyWord; 392 Pat.Min:= 1; 393 TAlphaNumeric.Create(Pat); 394 Lex.Add(Pat); 395 OptPat := TAny.Create(nil); 396 OptPat.Key := '__TMPLONG__'; 397 OptPat.Id:= piKeyWord; 398 OptPat.Min:= 1; 399 Pat.AddOption(OptPat); 400 TAlphaNumeric.Create(OptPat); 401 OptPat := TAny.Create(nil); 402 OptPat.Key := '__TMPWORD__'; 403 OptPat.Id:= piKeyWord; 404 OptPat.Min:= 1; 405 Pat.AddOption(OptPat); 406 TAlphaNumeric.Create(OptPat); 407 OptPat := TAny.Create(nil); 408 OptPat.Key := '__RETURN__'; 409 OptPat.Id:= piKeyWord; 410 OptPat.Min:= 1; 411 Pat.AddOption(OptPat); 412 TAlphaNumeric.Create(OptPat); 413 OptPat := TAny.Create(nil); 414 OptPat.Key := '__RETVAL__'; 415 OptPat.Id:= piKeyWord; 416 OptPat.Min:= 1; 417 Pat.AddOption(OptPat); 418 TAlphaNumeric.Create(OptPat); 419 Pat.AddOption(TIdentifier.Create(nil)); 420 421 { KeyWord, Identifier} 422 Pat := TAny.Create(nil); 423 Pat.Key:= 'abs'; 424 Pat.Id:= piKeyWord; 425 Pat.Min:= 1; 426 TAlphaNumeric.Create(Pat); 427 Lex.Add(Pat); 428 OptPat := TAny.Create(nil); 429 OptPat.Key := 'asm'; 430 OptPat.Id:= piKeyWord; 431 OptPat.Min:= 1; 432 Pat.AddOption(OptPat); 433 TAlphaNumeric.Create(OptPat); 434 Pat.AddOption(TIdentifier.Create(nil)); 435 436 { KeyWord, Identifier} 437 Pat := TAny.Create(nil); 438 Pat.Key:= 'break'; 439 Pat.Id:= piKeyWord; 440 Pat.Min:= 1; 441 TAlphaNumeric.Create(Pat); 442 Lex.Add(Pat); 443 OptPat := TAny.Create(nil); 444 OptPat.Key := 'bool'; 445 OptPat.Id:= piKeyWord; 446 OptPat.Min:= 1; 447 Pat.AddOption(OptPat); 448 TAlphaNumeric.Create(OptPat); 449 OptPat := TAny.Create(nil); 450 OptPat.Key := 'byte'; 451 OptPat.Id:= piKeyWord; 452 OptPat.Min:= 1; 453 Pat.AddOption(OptPat); 454 TAlphaNumeric.Create(OptPat); 455 Pat.AddOption(TIdentifier.Create(nil)); 456 457 { KeyWord, Identifier} 458 Pat := TAny.Create(nil); 459 Pat.Key:= 'continue'; 460 Pat.Id:= piKeyWord; 461 Pat.Min:= 1; 462 TAlphaNumeric.Create(Pat); 463 Lex.Add(Pat); 464 OptPat := TAny.Create(nil); 465 OptPat.Key := 'const'; 466 OptPat.Id:= piKeyWord; 467 OptPat.Min:= 1; 468 Pat.AddOption(OptPat); 469 TAlphaNumeric.Create(OptPat); 470 OptPat := TAny.Create(nil); 471 OptPat.Key := 'case'; 472 OptPat.Id:= piKeyWord; 473 OptPat.Min:= 1; 474 Pat.AddOption(OptPat); 475 TAlphaNumeric.Create(OptPat); 476 OptPat := TAny.Create(nil); 477 OptPat.Key := 'char'; 478 OptPat.Id:= piKeyWord; 479 OptPat.Min:= 1; 480 Pat.AddOption(OptPat); 481 TAlphaNumeric.Create(OptPat); 482 Pat.AddOption(TIdentifier.Create(nil)); 483 484 { KeyWord, Identifier} 485 Pat := TAny.Create(nil); 486 Pat.Key:= 'default'; 487 Pat.Id:= piKeyWord; 488 Pat.Min:= 1; 489 TAlphaNumeric.Create(Pat); 490 Lex.Add(Pat); 491 OptPat := TAny.Create(nil); 492 OptPat.Key := 'do'; 493 OptPat.Id:= piKeyWord; 494 OptPat.Min:= 1; 495 Pat.AddOption(OptPat); 496 TAlphaNumeric.Create(OptPat); 497 Pat.AddOption(TIdentifier.Create(nil)); 498 499 { KeyWord, Identifier} 500 Pat := TAny.Create(nil); 501 Pat.Key:= 'else'; 502 Pat.Id:= piKeyWord; 503 Pat.Min:= 1; 504 TAlphaNumeric.Create(Pat); 505 Lex.Add(Pat); 506 Pat.AddOption(TIdentifier.Create(nil)); 507 508 { KeyWord, Identifier} 509 Pat := TAny.Create(nil); 510 Pat.Key:= 'false'; 511 Pat.Id:= piKeyWord; 512 Pat.Min:= 1; 513 TAlphaNumeric.Create(Pat); 514 Lex.Add(Pat); 515 OptPat := TAny.Create(nil); 516 OptPat.Key := 'for'; 517 OptPat.Id:= piKeyWord; 518 OptPat.Min:= 1; 519 Pat.AddOption(OptPat); 520 TAlphaNumeric.Create(OptPat); 521 Pat.AddOption(TIdentifier.Create(nil)); 522 523 { KeyWord, Identifier} 524 Pat := TAny.Create(nil); 525 Pat.Key:= 'goto'; 526 Pat.Id:= piKeyWord; 527 Pat.Min:= 1; 528 TAlphaNumeric.Create(Pat); 529 Lex.Add(Pat); 530 Pat.AddOption(TIdentifier.Create(nil)); 531 532 { KeyWord, Identifier} 533 Pat := TAny.Create(nil); 534 Pat.Key:= 'inline'; 535 Pat.Id:= piKeyWord; 536 Pat.Min:= 1; 537 TAlphaNumeric.Create(Pat); 538 Lex.Add(Pat); 539 OptPat := TAny.Create(nil); 540 OptPat.Key := 'int'; 541 OptPat.Id:= piKeyWord; 542 OptPat.Min:= 1; 543 Pat.AddOption(OptPat); 544 TAlphaNumeric.Create(OptPat); 545 OptPat := TAny.Create(nil); 546 OptPat.Key := 'if'; 547 OptPat.Id:= piKeyWord; 548 OptPat.Min:= 1; 549 Pat.AddOption(OptPat); 550 TAlphaNumeric.Create(OptPat); 551 Pat.AddOption(TIdentifier.Create(nil)); 552 553 { KeyWord, Identifier} 554 Pat := TAny.Create(nil); 555 Pat.Key:= 'long'; 556 Pat.Id:= piKeyWord; 557 Pat.Min:= 1; 558 TAlphaNumeric.Create(Pat); 559 Lex.Add(Pat); 560 Pat.AddOption(TIdentifier.Create(nil)); 561 562 { KeyWord, Identifier} 563 Pat := TAny.Create(nil); 564 Pat.Key:= 'mutex'; 565 Pat.Id:= piKeyWord; 566 Pat.Min:= 1; 567 TAlphaNumeric.Create(Pat); 568 Lex.Add(Pat); 569 Pat.AddOption(TIdentifier.Create(nil)); 570 571 { KeyWord, Identifier} 572 Pat := TAny.Create(nil); 573 Pat.Key:= 'priority'; 574 Pat.Id:= piKeyWord; 575 Pat.Min:= 1; 576 TAlphaNumeric.Create(Pat); 577 Lex.Add(Pat); 578 Pat.AddOption(TIdentifier.Create(nil)); 579 580 { KeyWord, Identifier} 581 Pat := TAny.Create(nil); 582 Pat.Key:= 'repeat'; 583 Pat.Id:= piKeyWord; 584 Pat.Min:= 1; 585 TAlphaNumeric.Create(Pat); 586 Lex.Add(Pat); 587 OptPat := TAny.Create(nil); 588 OptPat.Key := 'return'; 589 OptPat.Id:= piKeyWord; 590 OptPat.Min:= 1; 591 Pat.AddOption(OptPat); 592 TAlphaNumeric.Create(OptPat); 593 Pat.AddOption(TIdentifier.Create(nil)); 594 595 { KeyWord, Identifier} 596 Pat := TAny.Create(nil); 597 Pat.Key:= 'safecall'; 598 Pat.Id:= piKeyWord; 599 Pat.Min:= 1; 600 TAlphaNumeric.Create(Pat); 601 Lex.Add(Pat); 602 OptPat := TAny.Create(nil); 603 OptPat.Key := 'string'; 604 OptPat.Id:= piKeyWord; 605 OptPat.Min:= 1; 606 Pat.AddOption(OptPat); 607 TAlphaNumeric.Create(OptPat); 608 OptPat := TAny.Create(nil); 609 OptPat.Key := 'struct'; 610 OptPat.Id:= piKeyWord; 611 OptPat.Min:= 1; 612 Pat.AddOption(OptPat); 613 TAlphaNumeric.Create(OptPat); 614 OptPat := TAny.Create(nil); 615 OptPat.Key := 'switch'; 616 OptPat.Id:= piKeyWord; 617 OptPat.Min:= 1; 618 Pat.AddOption(OptPat); 619 TAlphaNumeric.Create(OptPat); 620 OptPat := TAny.Create(nil); 621 OptPat.Key := 'short'; 622 OptPat.Id:= piKeyWord; 623 OptPat.Min:= 1; 624 Pat.AddOption(OptPat); 625 TAlphaNumeric.Create(OptPat); 626 OptPat := TAny.Create(nil); 627 OptPat.Key := 'start'; 628 OptPat.Id:= piKeyWord; 629 OptPat.Min:= 1; 630 Pat.AddOption(OptPat); 631 TAlphaNumeric.Create(OptPat); 632 OptPat := TAny.Create(nil); 633 OptPat.Key := 'sign'; 634 OptPat.Id:= piKeyWord; 635 OptPat.Min:= 1; 636 Pat.AddOption(OptPat); 637 TAlphaNumeric.Create(OptPat); 638 OptPat := TAny.Create(nil); 639 OptPat.Key := 'stop'; 640 OptPat.Id:= piKeyWord; 641 OptPat.Min:= 1; 642 Pat.AddOption(OptPat); 643 TAlphaNumeric.Create(OptPat); 644 OptPat := TAny.Create(nil); 645 OptPat.Key := 'sub'; 646 OptPat.Id:= piKeyWord; 647 OptPat.Min:= 1; 648 Pat.AddOption(OptPat); 649 TAlphaNumeric.Create(OptPat); 650 Pat.AddOption(TIdentifier.Create(nil)); 651 652 { KeyWord, Identifier} 653 Pat := TAny.Create(nil); 654 Pat.Key:= 'typedef'; 655 Pat.Id:= piKeyWord; 656 Pat.Min:= 1; 657 TAlphaNumeric.Create(Pat); 658 Lex.Add(Pat); 659 OptPat := TAny.Create(nil); 660 OptPat.Key := 'task'; 661 OptPat.Id:= piKeyWord; 662 OptPat.Min:= 1; 663 Pat.AddOption(OptPat); 664 TAlphaNumeric.Create(OptPat); 665 OptPat := TAny.Create(nil); 666 OptPat.Key := 'true'; 667 OptPat.Id:= piKeyWord; 668 OptPat.Min:= 1; 669 Pat.AddOption(OptPat); 670 TAlphaNumeric.Create(OptPat); 671 Pat.AddOption(TIdentifier.Create(nil)); 672 673 { KeyWord, Identifier} 674 Pat := TAny.Create(nil); 675 Pat.Key:= 'unsigned'; 676 Pat.Id:= piKeyWord; 677 Pat.Min:= 1; 678 TAlphaNumeric.Create(Pat); 679 Lex.Add(Pat); 680 Pat.AddOption(TIdentifier.Create(nil)); 681 682 { KeyWord, Identifier} 683 Pat := TAny.Create(nil); 684 Pat.Key:= 'void'; 685 Pat.Id:= piKeyWord; 686 Pat.Min:= 1; 687 TAlphaNumeric.Create(Pat); 688 Lex.Add(Pat); 689 Pat.AddOption(TIdentifier.Create(nil)); 690 691 { KeyWord, Identifier} 692 Pat := TAny.Create(nil); 693 Pat.Key:= 'while'; 694 Pat.Id:= piKeyWord; 695 Pat.Min:= 1; 696 TAlphaNumeric.Create(Pat); 697 Lex.Add(Pat); 698 Pat.AddOption(TIdentifier.Create(nil)); 699 end; 700 701 end. 702