1## -*- tcl -*- 2## 3## Critcl-based C/PARAM implementation of the parsing 4## expression grammar 5## 6## PEG 7## 8## Generated from file 3_peg_itself 9## for user aku 10## 11# # ## ### ##### ######## ############# ##################### 12## Requirements 13 14package require Tcl 8.4 15package require critcl 16# @sak notprovided pt_parse_peg_c 17package provide pt_parse_peg_c 1.0.1 18 19# Note: The implementation of the PARAM virtual machine 20# underlying the C/PARAM code used below is inlined 21# into the generated parser, allowing for direct access 22# and manipulation of the RDE state, instead of having 23# to dispatch through the Tcl interpreter. 24 25# # ## ### ##### ######## ############# ##################### 26## 27 28namespace eval ::pt::parse { 29 # # ## ### ##### ######## ############# ##################### 30 ## Supporting code for the main command. 31 32 catch { 33 #critcl::cflags -g 34 #critcl::debug memory symbols 35 } 36 37 # # ## ### ###### ######## ############# 38 ## RDE runtime, inlined, and made static. 39 40 # This is the C code for the RDE, i.e. the implementation 41 # of pt::rde. Only the low-level engine is imported, the 42 # Tcl interface layer is ignored. This generated parser 43 # provides its own layer for that. 44 45 critcl::ccode { 46 /* -*- c -*- */ 47 48 #include <string.h> 49 #define SCOPE static 50 51#line 1 "rde_critcl/util.h" 52 53 #ifndef _RDE_UTIL_H 54 #define _RDE_UTIL_H 1 55 #ifndef SCOPE 56 #define SCOPE 57 #endif 58 #define ALLOC(type) (type *) ckalloc (sizeof (type)) 59 #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) 60 #undef RDE_DEBUG 61 #define RDE_DEBUG 1 62 #undef RDE_TRACE 63 #ifdef RDE_DEBUG 64 #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } 65 #define XSTR(x) #x 66 #define STR(x) XSTR(x) 67 #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) 68 #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} 69 #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) 70 #else 71 #define STOPAFTER(x) 72 #define ASSERT(x,msg) 73 #define ASSERT_BOUNDS(i,n) 74 #endif 75 #ifdef RDE_TRACE 76 SCOPE void trace_enter (const char* fun); 77 SCOPE void trace_return (const char *pat, ...); 78 SCOPE void trace_printf (const char *pat, ...); 79 #define ENTER(fun) trace_enter (fun) 80 #define RETURN(format,x) trace_return (format,x) ; return x 81 #define RETURNVOID trace_return ("%s","(void)") ; return 82 #define TRACE0(x) trace_printf0 x 83 #define TRACE(x) trace_printf x 84 #else 85 #define ENTER(fun) 86 #define RETURN(f,x) return x 87 #define RETURNVOID return 88 #define TRACE0(x) 89 #define TRACE(x) 90 #endif 91 #endif 92 93 94#line 1 "rde_critcl/stack.h" 95 96 #ifndef _RDE_DS_STACK_H 97 #define _RDE_DS_STACK_H 1 98 typedef void (*RDE_STACK_CELL_FREE) (void* cell); 99 typedef struct RDE_STACK_* RDE_STACK; 100 static const int RDE_STACK_INITIAL_SIZE = 256; 101 #endif 102 103 104#line 1 "rde_critcl/tc.h" 105 106 #ifndef _RDE_DS_TC_H 107 #define _RDE_DS_TC_H 1 108 typedef struct RDE_TC_* RDE_TC; 109 #endif 110 111 112#line 1 "rde_critcl/param.h" 113 114 #ifndef _RDE_DS_PARAM_H 115 #define _RDE_DS_PARAM_H 1 116 typedef struct RDE_PARAM_* RDE_PARAM; 117 typedef struct ERROR_STATE { 118 int refCount; 119 long int loc; 120 RDE_STACK msg; 121 } ERROR_STATE; 122 typedef struct NC_STATE { 123 long int CL; 124 long int ST; 125 Tcl_Obj* SV; 126 ERROR_STATE* ER; 127 } NC_STATE; 128 #endif 129 130 131#line 1 "rde_critcl/util.c" 132 133 #ifdef RDE_TRACE 134 typedef struct F_STACK { 135 const char* str; 136 struct F_STACK* down; 137 } F_STACK; 138 static F_STACK* top = 0; 139 static int level = 0; 140 static void 141 push (const char* str) 142 { 143 F_STACK* new = ALLOC (F_STACK); 144 new->str = str; 145 new->down = top; 146 top = new; 147 level += 4; 148 } 149 static void 150 pop (void) 151 { 152 F_STACK* next = top->down; 153 level -= 4; 154 ckfree ((char*)top); 155 top = next; 156 } 157 static void 158 indent (void) 159 { 160 int i; 161 for (i = 0; i < level; i++) { 162 fwrite(" ", 1, 1, stdout); 163 fflush (stdout); 164 } 165 if (top) { 166 fwrite(top->str, 1, strlen(top->str), stdout); 167 fflush (stdout); 168 } 169 fwrite(" ", 1, 1, stdout); 170 fflush (stdout); 171 } 172 SCOPE void 173 trace_enter (const char* fun) 174 { 175 push (fun); 176 indent(); 177 fwrite("ENTER\n", 1, 6, stdout); 178 fflush (stdout); 179 } 180 static char msg [1024*1024]; 181 SCOPE void 182 trace_return (const char *pat, ...) 183 { 184 int len; 185 va_list args; 186 indent(); 187 fwrite("RETURN = ", 1, 9, stdout); 188 fflush (stdout); 189 va_start(args, pat); 190 len = vsprintf(msg, pat, args); 191 va_end(args); 192 msg[len++] = '\n'; 193 msg[len] = '\0'; 194 fwrite(msg, 1, len, stdout); 195 fflush (stdout); 196 pop(); 197 } 198 SCOPE void 199 trace_printf (const char *pat, ...) 200 { 201 int len; 202 va_list args; 203 indent(); 204 va_start(args, pat); 205 len = vsprintf(msg, pat, args); 206 va_end(args); 207 msg[len++] = '\n'; 208 msg[len] = '\0'; 209 fwrite(msg, 1, len, stdout); 210 fflush (stdout); 211 } 212 SCOPE void 213 trace_printf0 (const char *pat, ...) 214 { 215 int len; 216 va_list args; 217 va_start(args, pat); 218 len = vsprintf(msg, pat, args); 219 va_end(args); 220 msg[len++] = '\n'; 221 msg[len] = '\0'; 222 fwrite(msg, 1, len, stdout); 223 fflush (stdout); 224 } 225 #endif 226 227 228#line 1 "rde_critcl/stack.c" 229 230 typedef struct RDE_STACK_ { 231 long int max; 232 long int top; 233 RDE_STACK_CELL_FREE freeCellProc; 234 void** cell; 235 } RDE_STACK_; 236 237 SCOPE RDE_STACK 238 rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) 239 { 240 RDE_STACK s = ALLOC (RDE_STACK_); 241 s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); 242 s->max = RDE_STACK_INITIAL_SIZE; 243 s->top = 0; 244 s->freeCellProc = freeCellProc; 245 return s; 246 } 247 SCOPE void 248 rde_stack_del (RDE_STACK s) 249 { 250 if (s->freeCellProc && s->top) { 251 long int i; 252 for (i=0; i < s->top; i++) { 253 ASSERT_BOUNDS(i,s->max); 254 s->freeCellProc ( s->cell [i] ); 255 } 256 } 257 ckfree ((char*) s->cell); 258 ckfree ((char*) s); 259 } 260 SCOPE void 261 rde_stack_push (RDE_STACK s, void* item) 262 { 263 if (s->top >= s->max) { 264 long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; 265 void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); 266 ASSERT (cell,"Memory allocation failure for RDE stack"); 267 s->max = new; 268 s->cell = cell; 269 } 270 ASSERT_BOUNDS(s->top,s->max); 271 s->cell [s->top] = item; 272 s->top ++; 273 } 274 SCOPE void* 275 rde_stack_top (RDE_STACK s) 276 { 277 ASSERT_BOUNDS(s->top-1,s->max); 278 return s->cell [s->top - 1]; 279 } 280 SCOPE void 281 rde_stack_pop (RDE_STACK s, long int n) 282 { 283 ASSERT (n >= 0, "Bad pop count"); 284 if (n == 0) return; 285 if (s->freeCellProc) { 286 while (n) { 287 s->top --; 288 ASSERT_BOUNDS(s->top,s->max); 289 s->freeCellProc ( s->cell [s->top] ); 290 n --; 291 } 292 } else { 293 s->top -= n; 294 } 295 } 296 SCOPE void 297 rde_stack_trim (RDE_STACK s, long int n) 298 { 299 ASSERT (n >= 0, "Bad trimsize"); 300 if (s->freeCellProc) { 301 while (s->top > n) { 302 s->top --; 303 ASSERT_BOUNDS(s->top,s->max); 304 s->freeCellProc ( s->cell [s->top] ); 305 } 306 } else { 307 s->top = n; 308 } 309 } 310 SCOPE void 311 rde_stack_drop (RDE_STACK s, long int n) 312 { 313 ASSERT (n >= 0, "Bad pop count"); 314 if (n == 0) return; 315 s->top -= n; 316 } 317 SCOPE void 318 rde_stack_move (RDE_STACK dst, RDE_STACK src) 319 { 320 ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); 321 322 while (src->top > 0) { 323 src->top --; 324 ASSERT_BOUNDS(src->top,src->max); 325 rde_stack_push (dst, src->cell [src->top] ); 326 } 327 } 328 SCOPE void 329 rde_stack_get (RDE_STACK s, long int* cn, void*** cc) 330 { 331 *cn = s->top; 332 *cc = s->cell; 333 } 334 SCOPE long int 335 rde_stack_size (RDE_STACK s) 336 { 337 return s->top; 338 } 339 340 341#line 1 "rde_critcl/tc.c" 342 343 typedef struct RDE_TC_ { 344 int max; 345 int num; 346 char* str; 347 RDE_STACK off; 348 } RDE_TC_; 349 350 SCOPE RDE_TC 351 rde_tc_new (void) 352 { 353 RDE_TC tc = ALLOC (RDE_TC_); 354 tc->max = RDE_STACK_INITIAL_SIZE; 355 tc->num = 0; 356 tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); 357 tc->off = rde_stack_new (NULL); 358 return tc; 359 } 360 SCOPE void 361 rde_tc_del (RDE_TC tc) 362 { 363 rde_stack_del (tc->off); 364 ckfree (tc->str); 365 ckfree ((char*) tc); 366 } 367 SCOPE long int 368 rde_tc_size (RDE_TC tc) 369 { 370 return rde_stack_size (tc->off); 371 } 372 SCOPE void 373 rde_tc_clear (RDE_TC tc) 374 { 375 tc->num = 0; 376 rde_stack_trim (tc->off, 0); 377 } 378 SCOPE char* 379 rde_tc_append (RDE_TC tc, char* string, long int len) 380 { 381 long int base = tc->num; 382 long int off = tc->num; 383 char* ch; 384 int clen; 385 Tcl_UniChar uni; 386 if (len < 0) { 387 len = strlen (string); 388 } 389 390 if (!len) { 391 return tc->str + base; 392 } 393 394 if ((tc->num + len) >= tc->max) { 395 int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); 396 char* str = ckrealloc (tc->str, new * sizeof(char)); 397 ASSERT (str,"Memory allocation failure for token character array"); 398 tc->max = new; 399 tc->str = str; 400 } 401 tc->num += len; 402 ASSERT_BOUNDS(tc->num,tc->max); 403 ASSERT_BOUNDS(off,tc->max); 404 ASSERT_BOUNDS(off+len-1,tc->max); 405 ASSERT_BOUNDS(off+len-1,tc->num); 406 memcpy (tc->str + off, string, len); 407 408 ch = string; 409 while (ch < (string + len)) { 410 ASSERT_BOUNDS(off,tc->num); 411 rde_stack_push (tc->off, (void*) off); 412 clen = Tcl_UtfToUniChar (ch, &uni); 413 off += clen; 414 ch += clen; 415 } 416 return tc->str + base; 417 } 418 SCOPE void 419 rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) 420 { 421 long int oc, off, top, end; 422 void** ov; 423 rde_stack_get (tc->off, &oc, &ov); 424 ASSERT_BOUNDS(at,oc); 425 off = (long int) ov [at]; 426 if ((at+1) == oc) { 427 end = tc->num; 428 } else { 429 end = (long int) ov [at+1]; 430 } 431 TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); 432 ASSERT_BOUNDS(off,tc->num); 433 ASSERT_BOUNDS(end-1,tc->num); 434 *ch = tc->str + off; 435 *len = end - off; 436 } 437 SCOPE void 438 rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) 439 { 440 long int oc, off, top, end; 441 void** ov; 442 rde_stack_get (tc->off, &oc, &ov); 443 ASSERT_BOUNDS(at,oc); 444 ASSERT_BOUNDS(last,oc); 445 off = (long int) ov [at]; 446 if ((last+1) == oc) { 447 end = tc->num; 448 } else { 449 end = (long int) ov [last+1]; 450 } 451 TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); 452 ASSERT_BOUNDS(off,tc->num); 453 ASSERT_BOUNDS(end-1,tc->num); 454 *ch = tc->str + off; 455 *len = end - off; 456 } 457 458 459#line 1 "rde_critcl/param.c" 460 461 typedef struct RDE_PARAM_ { 462 Tcl_Channel IN; 463 Tcl_Obj* readbuf; 464 char* CC; 465 long int CC_len; 466 RDE_TC TC; 467 long int CL; 468 RDE_STACK LS; 469 ERROR_STATE* ER; 470 RDE_STACK ES; 471 long int ST; 472 Tcl_Obj* SV; 473 Tcl_HashTable NC; 474 475 RDE_STACK ast ; 476 RDE_STACK mark ; 477 478 long int numstr; 479 char** string; 480 481 ClientData clientData; 482 } RDE_PARAM_; 483 typedef int (*UniCharClass) (int); 484 typedef enum test_class_id { 485 tc_alnum, 486 tc_alpha, 487 tc_ascii, 488 tc_control, 489 tc_ddigit, 490 tc_digit, 491 tc_graph, 492 tc_lower, 493 tc_printable, 494 tc_punct, 495 tc_space, 496 tc_upper, 497 tc_wordchar, 498 tc_xdigit 499 } test_class_id; 500 static void ast_node_free (void* n); 501 static void error_state_free (void* es); 502 static void error_set (RDE_PARAM p, long int s); 503 static void nc_clear (RDE_PARAM p); 504 static int UniCharIsAscii (int character); 505 static int UniCharIsHexDigit (int character); 506 static int UniCharIsDecDigit (int character); 507 static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); 508 static int er_int_compare (const void* a, const void* b); 509 #define SV_INIT(p) \ 510 p->SV = NULL; \ 511 TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) 512 #define SV_SET(p,newsv) \ 513 if (((p)->SV) != (newsv)) { \ 514 TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ 515 if ((p)->SV) { \ 516 Tcl_DecrRefCount ((p)->SV); \ 517 } \ 518 (p)->SV = (newsv); \ 519 TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ 520 if ((p)->SV) { \ 521 Tcl_IncrRefCount ((p)->SV); \ 522 } \ 523 } 524 #define SV_CLEAR(p) \ 525 TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ 526 if ((p)->SV) { \ 527 Tcl_DecrRefCount ((p)->SV); \ 528 } \ 529 (p)->SV = NULL 530 #define ER_INIT(p) \ 531 p->ER = NULL; \ 532 TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) 533 #define ER_CLEAR(p) \ 534 error_state_free ((p)->ER); \ 535 (p)->ER = NULL 536 SCOPE RDE_PARAM 537 rde_param_new (long int nstr, char** strings) 538 { 539 RDE_PARAM p; 540 ENTER ("rde_param_new"); 541 TRACE (("\tINT %d strings @ %p", nstr, strings)); 542 p = ALLOC (RDE_PARAM_); 543 p->numstr = nstr; 544 p->string = strings; 545 p->readbuf = Tcl_NewObj (); 546 Tcl_IncrRefCount (p->readbuf); 547 TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); 548 Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); 549 p->IN = NULL; 550 p->CL = -1; 551 p->ST = 0; 552 ER_INIT (p); 553 SV_INIT (p); 554 p->CC = NULL; 555 p->CC_len = 0; 556 p->TC = rde_tc_new (); 557 p->ES = rde_stack_new (error_state_free); 558 p->LS = rde_stack_new (NULL); 559 p->ast = rde_stack_new (ast_node_free); 560 p->mark = rde_stack_new (NULL); 561 RETURN ("%p", p); 562 } 563 SCOPE void 564 rde_param_del (RDE_PARAM p) 565 { 566 ENTER ("rde_param_del"); 567 TRACE (("RDE_PARAM %p",p)); 568 ER_CLEAR (p); TRACE (("\ter_clear")); 569 SV_CLEAR (p); TRACE (("\tsv_clear")); 570 nc_clear (p); TRACE (("\tnc_clear")); 571 Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); 572 rde_tc_del (p->TC); TRACE (("\ttc clear")); 573 rde_stack_del (p->ES); TRACE (("\tes clear")); 574 rde_stack_del (p->LS); TRACE (("\tls clear")); 575 rde_stack_del (p->ast); TRACE (("\tast clear")); 576 rde_stack_del (p->mark); TRACE (("\tmark clear")); 577 TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); 578 Tcl_DecrRefCount (p->readbuf); 579 ckfree ((char*) p); 580 RETURNVOID; 581 } 582 SCOPE void 583 rde_param_reset (RDE_PARAM p, Tcl_Channel chan) 584 { 585 ENTER ("rde_param_reset"); 586 TRACE (("RDE_PARAM %p",p)); 587 TRACE (("Tcl_Channel %p",chan)); 588 p->IN = chan; 589 p->CL = -1; 590 p->ST = 0; 591 p->CC = NULL; 592 p->CC_len = 0; 593 ER_CLEAR (p); 594 SV_CLEAR (p); 595 nc_clear (p); 596 rde_tc_clear (p->TC); 597 rde_stack_trim (p->ES, 0); 598 rde_stack_trim (p->LS, 0); 599 rde_stack_trim (p->ast, 0); 600 rde_stack_trim (p->mark, 0); 601 TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); 602 RETURNVOID; 603 } 604 SCOPE void 605 rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) 606 { 607 ENTER ("rde_param_update_strings"); 608 TRACE (("RDE_PARAM %p", p)); 609 TRACE (("INT %d strings", nstr)); 610 p->numstr = nstr; 611 p->string = strings; 612 RETURNVOID; 613 } 614 SCOPE void 615 rde_param_data (RDE_PARAM p, char* buf, long int len) 616 { 617 (void) rde_tc_append (p->TC, buf, len); 618 } 619 SCOPE void 620 rde_param_clientdata (RDE_PARAM p, ClientData clientData) 621 { 622 p->clientData = clientData; 623 } 624 static void 625 nc_clear (RDE_PARAM p) 626 { 627 Tcl_HashSearch hs; 628 Tcl_HashEntry* he; 629 Tcl_HashTable* tablePtr; 630 for(he = Tcl_FirstHashEntry(&p->NC, &hs); 631 he != NULL; 632 he = Tcl_FirstHashEntry(&p->NC, &hs)) { 633 Tcl_HashSearch hsc; 634 Tcl_HashEntry* hec; 635 tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); 636 for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); 637 hec != NULL; 638 hec = Tcl_NextHashEntry(&hsc)) { 639 NC_STATE* scs = Tcl_GetHashValue (hec); 640 error_state_free (scs->ER); 641 if (scs->SV) { Tcl_DecrRefCount (scs->SV); } 642 ckfree ((char*) scs); 643 } 644 Tcl_DeleteHashTable (tablePtr); 645 ckfree ((char*) tablePtr); 646 Tcl_DeleteHashEntry (he); 647 } 648 } 649 SCOPE ClientData 650 rde_param_query_clientdata (RDE_PARAM p) 651 { 652 return p->clientData; 653 } 654 SCOPE void 655 rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) 656 { 657 rde_stack_get (p->mark, mc, mv); 658 } 659 SCOPE void 660 rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) 661 { 662 rde_stack_get (p->ast, ac, (void***) av); 663 } 664 SCOPE const char* 665 rde_param_query_in (RDE_PARAM p) 666 { 667 return p->IN 668 ? Tcl_GetChannelName (p->IN) 669 : ""; 670 } 671 SCOPE const char* 672 rde_param_query_cc (RDE_PARAM p, long int* len) 673 { 674 *len = p->CC_len; 675 return p->CC; 676 } 677 SCOPE int 678 rde_param_query_cl (RDE_PARAM p) 679 { 680 return p->CL; 681 } 682 SCOPE const ERROR_STATE* 683 rde_param_query_er (RDE_PARAM p) 684 { 685 return p->ER; 686 } 687 SCOPE Tcl_Obj* 688 rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) 689 { 690 Tcl_Obj* res; 691 if (!er) { 692 693 res = Tcl_NewStringObj ("", 0); 694 } else { 695 Tcl_Obj* ov [2]; 696 Tcl_Obj** mov; 697 long int mc, i, j; 698 void** mv; 699 int lastid; 700 const char* msg; 701 rde_stack_get (er->msg, &mc, &mv); 702 703 qsort (mv, mc, sizeof (void*), er_int_compare); 704 705 mov = NALLOC (mc, Tcl_Obj*); 706 lastid = -1; 707 for (i=0, j=0; i < mc; i++) { 708 ASSERT_BOUNDS (i,mc); 709 if (((long int) mv [i]) == lastid) continue; 710 lastid = (long int) mv [i]; 711 ASSERT_BOUNDS((long int) mv[i],p->numstr); 712 msg = p->string [(long int) mv[i]]; 713 ASSERT_BOUNDS (j,mc); 714 mov [j] = Tcl_NewStringObj (msg, -1); 715 j++; 716 } 717 718 ov [0] = Tcl_NewIntObj (er->loc); 719 ov [1] = Tcl_NewListObj (j, mov); 720 res = Tcl_NewListObj (2, ov); 721 ckfree ((char*) mov); 722 } 723 return res; 724 } 725 SCOPE void 726 rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) 727 { 728 rde_stack_get (p->ES, ec, (void***) ev); 729 } 730 SCOPE void 731 rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) 732 { 733 rde_stack_get (p->LS, lc, lv); 734 } 735 SCOPE long int 736 rde_param_query_lstop (RDE_PARAM p) 737 { 738 return (long int) rde_stack_top (p->LS); 739 } 740 SCOPE Tcl_HashTable* 741 rde_param_query_nc (RDE_PARAM p) 742 { 743 return &p->NC; 744 } 745 SCOPE int 746 rde_param_query_st (RDE_PARAM p) 747 { 748 return p->ST; 749 } 750 SCOPE Tcl_Obj* 751 rde_param_query_sv (RDE_PARAM p) 752 { 753 TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ 754 return p->SV; 755 } 756 SCOPE long int 757 rde_param_query_tc_size (RDE_PARAM p) 758 { 759 return rde_tc_size (p->TC); 760 } 761 SCOPE void 762 rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) 763 { 764 rde_tc_get_s (p->TC, at, last, ch, len); 765 } 766 SCOPE const char* 767 rde_param_query_string (RDE_PARAM p, long int id) 768 { 769 TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); 770 ASSERT_BOUNDS(id,p->numstr); 771 return p->string [id]; 772 } 773 SCOPE void 774 rde_param_i_ast_pop_discard (RDE_PARAM p) 775 { 776 rde_stack_pop (p->mark, 1); 777 } 778 SCOPE void 779 rde_param_i_ast_pop_rewind (RDE_PARAM p) 780 { 781 long int trim = (long int) rde_stack_top (p->mark); 782 ENTER ("rde_param_i_ast_pop_rewind"); 783 TRACE (("RDE_PARAM %p",p)); 784 rde_stack_pop (p->mark, 1); 785 rde_stack_trim (p->ast, trim); 786 TRACE (("SV = (%p rc%d '%s')", 787 p->SV, 788 p->SV ? p->SV->refCount : -1, 789 p->SV ? Tcl_GetString (p->SV) : "")); 790 RETURNVOID; 791 } 792 SCOPE void 793 rde_param_i_ast_rewind (RDE_PARAM p) 794 { 795 long int trim = (long int) rde_stack_top (p->mark); 796 ENTER ("rde_param_i_ast_rewind"); 797 TRACE (("RDE_PARAM %p",p)); 798 rde_stack_trim (p->ast, trim); 799 TRACE (("SV = (%p rc%d '%s')", 800 p->SV, 801 p->SV ? p->SV->refCount : -1, 802 p->SV ? Tcl_GetString (p->SV) : "")); 803 RETURNVOID; 804 } 805 SCOPE void 806 rde_param_i_ast_push (RDE_PARAM p) 807 { 808 rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); 809 } 810 SCOPE void 811 rde_param_i_ast_value_push (RDE_PARAM p) 812 { 813 ENTER ("rde_param_i_ast_value_push"); 814 TRACE (("RDE_PARAM %p",p)); 815 ASSERT(p->SV,"Unable to push undefined semantic value"); 816 TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); 817 TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); 818 rde_stack_push (p->ast, p->SV); 819 Tcl_IncrRefCount (p->SV); 820 RETURNVOID; 821 } 822 static void 823 ast_node_free (void* n) 824 { 825 Tcl_DecrRefCount ((Tcl_Obj*) n); 826 } 827 SCOPE void 828 rde_param_i_error_clear (RDE_PARAM p) 829 { 830 ER_CLEAR (p); 831 } 832 SCOPE void 833 rde_param_i_error_nonterminal (RDE_PARAM p, long int s) 834 { 835 836 return; 837#if 0 838 long int pos; 839 if (!p->ER) return; 840 pos = 1 + (long int) rde_stack_top (p->LS); 841 if (p->ER->loc != pos) return; 842 error_set (p, s); 843 p->ER->loc = pos; 844#endif 845 } 846 SCOPE void 847 rde_param_i_error_pop_merge (RDE_PARAM p) 848 { 849 ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); 850 851 if (top == p->ER) { 852 rde_stack_pop (p->ES, 1); 853 return; 854 } 855 856 if (!top) { 857 rde_stack_pop (p->ES, 1); 858 return; 859 } 860 861 if (!p->ER) { 862 rde_stack_drop (p->ES, 1); 863 p->ER = top; 864 865 return; 866 } 867 868 if (top->loc < p->ER->loc) { 869 rde_stack_pop (p->ES, 1); 870 return; 871 } 872 873 if (top->loc > p->ER->loc) { 874 rde_stack_drop (p->ES, 1); 875 error_state_free (p->ER); 876 p->ER = top; 877 878 return; 879 } 880 881 rde_stack_move (p->ER->msg, top->msg); 882 rde_stack_pop (p->ES, 1); 883 } 884 SCOPE void 885 rde_param_i_error_push (RDE_PARAM p) 886 { 887 rde_stack_push (p->ES, p->ER); 888 if (p->ER) { p->ER->refCount ++; } 889 } 890 static void 891 error_set (RDE_PARAM p, long int s) 892 { 893 error_state_free (p->ER); 894 p->ER = ALLOC (ERROR_STATE); 895 p->ER->refCount = 1; 896 p->ER->loc = p->CL; 897 p->ER->msg = rde_stack_new (NULL); 898 ASSERT_BOUNDS(s,p->numstr); 899 rde_stack_push (p->ER->msg, (void*) s); 900 } 901 static void 902 error_state_free (void* esx) 903 { 904 ERROR_STATE* es = esx; 905 if (!es) return; 906 es->refCount --; 907 if (es->refCount > 0) return; 908 rde_stack_del (es->msg); 909 ckfree ((char*) es); 910 } 911 SCOPE void 912 rde_param_i_loc_pop_discard (RDE_PARAM p) 913 { 914 rde_stack_pop (p->LS, 1); 915 } 916 SCOPE void 917 rde_param_i_loc_pop_rewind (RDE_PARAM p) 918 { 919 p->CL = (long int) rde_stack_top (p->LS); 920 rde_stack_pop (p->LS, 1); 921 } 922 SCOPE void 923 rde_param_i_loc_push (RDE_PARAM p) 924 { 925 rde_stack_push (p->LS, (void*) p->CL); 926 } 927 SCOPE void 928 rde_param_i_loc_rewind (RDE_PARAM p) 929 { 930 p->CL = (long int) rde_stack_top (p->LS); 931 } 932 SCOPE void 933 rde_param_i_input_next (RDE_PARAM p, long int m) 934 { 935 int leni; 936 char* ch; 937 ASSERT_BOUNDS(m,p->numstr); 938 p->CL ++; 939 if (p->CL < rde_tc_size (p->TC)) { 940 941 rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); 942 943 ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); 944 p->ST = 1; 945 ER_CLEAR (p); 946 return; 947 } 948 if (!p->IN || 949 Tcl_Eof (p->IN) || 950 (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { 951 952 p->ST = 0; 953 error_set (p, m); 954 return; 955 } 956 957 ch = Tcl_GetStringFromObj (p->readbuf, &leni); 958 ASSERT_BOUNDS (leni, TCL_UTF_MAX); 959 p->CC = rde_tc_append (p->TC, ch, leni); 960 p->CC_len = leni; 961 p->ST = 1; 962 ER_CLEAR (p); 963 } 964 SCOPE void 965 rde_param_i_status_fail (RDE_PARAM p) 966 { 967 p->ST = 0; 968 } 969 SCOPE void 970 rde_param_i_status_ok (RDE_PARAM p) 971 { 972 p->ST = 1; 973 } 974 SCOPE void 975 rde_param_i_status_negate (RDE_PARAM p) 976 { 977 p->ST = !p->ST; 978 } 979 SCOPE int 980 rde_param_i_symbol_restore (RDE_PARAM p, long int s) 981 { 982 NC_STATE* scs; 983 Tcl_HashEntry* hPtr; 984 Tcl_HashTable* tablePtr; 985 986 hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); 987 if (!hPtr) { return 0; } 988 tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); 989 hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); 990 if (!hPtr) { return 0; } 991 992 scs = Tcl_GetHashValue (hPtr); 993 p->CL = scs->CL; 994 p->ST = scs->ST; 995 error_state_free (p->ER); 996 p->ER = scs->ER; 997 if (p->ER) { p->ER->refCount ++; } 998 TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); 999 SV_SET (p, scs->SV); 1000 return 1; 1001 } 1002 SCOPE void 1003 rde_param_i_symbol_save (RDE_PARAM p, long int s) 1004 { 1005 long int at = (long int) rde_stack_top (p->LS); 1006 NC_STATE* scs; 1007 Tcl_HashEntry* hPtr; 1008 Tcl_HashTable* tablePtr; 1009 int isnew; 1010 ENTER ("rde_param_i_symbol_save"); 1011 TRACE (("RDE_PARAM %p",p)); 1012 TRACE (("INT %d",s)); 1013 1014 hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); 1015 if (isnew) { 1016 tablePtr = ALLOC (Tcl_HashTable); 1017 Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); 1018 Tcl_SetHashValue (hPtr, tablePtr); 1019 } else { 1020 tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); 1021 } 1022 hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); 1023 if (isnew) { 1024 1025 scs = ALLOC (NC_STATE); 1026 scs->CL = p->CL; 1027 scs->ST = p->ST; 1028 TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); 1029 scs->SV = p->SV; 1030 if (scs->SV) { Tcl_IncrRefCount (scs->SV); } 1031 scs->ER = p->ER; 1032 if (scs->ER) { scs->ER->refCount ++; } 1033 Tcl_SetHashValue (hPtr, scs); 1034 } else { 1035 1036 scs = (NC_STATE*) Tcl_GetHashValue (hPtr); 1037 scs->CL = p->CL; 1038 scs->ST = p->ST; 1039 TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); 1040 if (scs->SV) { Tcl_DecrRefCount (scs->SV); } 1041 scs->SV = p->SV; 1042 if (scs->SV) { Tcl_IncrRefCount (scs->SV); } 1043 error_state_free (scs->ER); 1044 scs->ER = p->ER; 1045 if (scs->ER) { scs->ER->refCount ++; } 1046 } 1047 TRACE (("SV = (%p rc%d '%s')", 1048 p->SV, 1049 p->SV ? p->SV->refCount : -1, 1050 p->SV ? Tcl_GetString (p->SV) : "")); 1051 RETURNVOID; 1052 } 1053 SCOPE void 1054 rde_param_i_test_alnum (RDE_PARAM p) 1055 { 1056 test_class (p, Tcl_UniCharIsAlnum, tc_alnum); 1057 } 1058 SCOPE void 1059 rde_param_i_test_alpha (RDE_PARAM p) 1060 { 1061 test_class (p, Tcl_UniCharIsAlpha, tc_alpha); 1062 } 1063 SCOPE void 1064 rde_param_i_test_ascii (RDE_PARAM p) 1065 { 1066 test_class (p, UniCharIsAscii, tc_ascii); 1067 } 1068 SCOPE void 1069 rde_param_i_test_control (RDE_PARAM p) 1070 { 1071 test_class (p, Tcl_UniCharIsControl, tc_control); 1072 } 1073 SCOPE void 1074 rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) 1075 { 1076 ASSERT_BOUNDS(msg,p->numstr); 1077 p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; 1078 if (p->ST) { 1079 ER_CLEAR (p); 1080 } else { 1081 error_set (p, msg); 1082 p->CL --; 1083 } 1084 } 1085 SCOPE void 1086 rde_param_i_test_ddigit (RDE_PARAM p) 1087 { 1088 test_class (p, UniCharIsDecDigit, tc_ddigit); 1089 } 1090 SCOPE void 1091 rde_param_i_test_digit (RDE_PARAM p) 1092 { 1093 test_class (p, Tcl_UniCharIsDigit, tc_digit); 1094 } 1095 SCOPE void 1096 rde_param_i_test_graph (RDE_PARAM p) 1097 { 1098 test_class (p, Tcl_UniCharIsGraph, tc_graph); 1099 } 1100 SCOPE void 1101 rde_param_i_test_lower (RDE_PARAM p) 1102 { 1103 test_class (p, Tcl_UniCharIsLower, tc_lower); 1104 } 1105 SCOPE void 1106 rde_param_i_test_print (RDE_PARAM p) 1107 { 1108 test_class (p, Tcl_UniCharIsPrint, tc_printable); 1109 } 1110 SCOPE void 1111 rde_param_i_test_punct (RDE_PARAM p) 1112 { 1113 test_class (p, Tcl_UniCharIsPunct, tc_punct); 1114 } 1115 SCOPE void 1116 rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) 1117 { 1118 ASSERT_BOUNDS(msg,p->numstr); 1119 p->ST = 1120 (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && 1121 (Tcl_UtfNcmp (p->CC, e, 1) <= 0); 1122 if (p->ST) { 1123 ER_CLEAR (p); 1124 } else { 1125 error_set (p, msg); 1126 p->CL --; 1127 } 1128 } 1129 SCOPE void 1130 rde_param_i_test_space (RDE_PARAM p) 1131 { 1132 test_class (p, Tcl_UniCharIsSpace, tc_space); 1133 } 1134 SCOPE void 1135 rde_param_i_test_upper (RDE_PARAM p) 1136 { 1137 test_class (p, Tcl_UniCharIsUpper, tc_upper); 1138 } 1139 SCOPE void 1140 rde_param_i_test_wordchar (RDE_PARAM p) 1141 { 1142 test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); 1143 } 1144 SCOPE void 1145 rde_param_i_test_xdigit (RDE_PARAM p) 1146 { 1147 test_class (p, UniCharIsHexDigit, tc_xdigit); 1148 } 1149 static void 1150 test_class (RDE_PARAM p, UniCharClass class, test_class_id id) 1151 { 1152 Tcl_UniChar ch; 1153 Tcl_UtfToUniChar(p->CC, &ch); 1154 ASSERT_BOUNDS(id,p->numstr); 1155 p->ST = !!class (ch); 1156 1157 if (p->ST) { 1158 ER_CLEAR (p); 1159 } else { 1160 error_set (p, id); 1161 p->CL --; 1162 } 1163 } 1164 static int 1165 UniCharIsAscii (int character) 1166 { 1167 return (character >= 0) && (character < 0x80); 1168 } 1169 static int 1170 UniCharIsHexDigit (int character) 1171 { 1172 return (character >= 0) && (character < 0x80) && isxdigit(character); 1173 } 1174 static int 1175 UniCharIsDecDigit (int character) 1176 { 1177 return (character >= 0) && (character < 0x80) && isdigit(character); 1178 } 1179 SCOPE void 1180 rde_param_i_value_clear (RDE_PARAM p) 1181 { 1182 SV_CLEAR (p); 1183 } 1184 SCOPE void 1185 rde_param_i_value_leaf (RDE_PARAM p, long int s) 1186 { 1187 Tcl_Obj* newsv; 1188 Tcl_Obj* ov [3]; 1189 long int pos = 1 + (long int) rde_stack_top (p->LS); 1190 ASSERT_BOUNDS(s,p->numstr); 1191 ov [0] = Tcl_NewStringObj (p->string[s], -1); 1192 ov [1] = Tcl_NewIntObj (pos); 1193 ov [2] = Tcl_NewIntObj (p->CL); 1194 newsv = Tcl_NewListObj (3, ov); 1195 TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); 1196 SV_SET (p, newsv); 1197 } 1198 SCOPE void 1199 rde_param_i_value_reduce (RDE_PARAM p, long int s) 1200 { 1201 Tcl_Obj* newsv; 1202 int oc, i, j; 1203 Tcl_Obj** ov; 1204 long int ac; 1205 Tcl_Obj** av; 1206 long int pos = 1 + (long int) rde_stack_top (p->LS); 1207 long int mark = (long int) rde_stack_top (p->mark); 1208 long int asize = rde_stack_size (p->ast); 1209 long int new = asize - mark; 1210 ASSERT (new >= 0, "Bad number of elements to reduce"); 1211 ov = NALLOC (3+new, Tcl_Obj*); 1212 ASSERT_BOUNDS(s,p->numstr); 1213 ov [0] = Tcl_NewStringObj (p->string[s], -1); 1214 ov [1] = Tcl_NewIntObj (pos); 1215 ov [2] = Tcl_NewIntObj (p->CL); 1216 rde_stack_get (p->ast, &ac, (void***) &av); 1217 for (i = 3, j = mark; j < asize; i++, j++) { 1218 ASSERT_BOUNDS (i, 3+new); 1219 ASSERT_BOUNDS (j, ac); 1220 ov [i] = av [j]; 1221 } 1222 ASSERT (i == 3+new, "Reduction result incomplete"); 1223 newsv = Tcl_NewListObj (3+new, ov); 1224 TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); 1225 SV_SET (p, newsv); 1226 ckfree ((char*) ov); 1227 } 1228 static int 1229 er_int_compare (const void* a, const void* b) 1230 { 1231 1232 const void** ael = (const void**) a; 1233 const void** bel = (const void**) b; 1234 long int avalue = (long int) *ael; 1235 long int bvalue = (long int) *bel; 1236 if (avalue < bvalue) { return -1; } 1237 if (avalue > bvalue) { return 1; } 1238 return 0; 1239 } 1240 SCOPE int 1241 rde_param_i_symbol_start (RDE_PARAM p, long int s) 1242 { 1243 if (rde_param_i_symbol_restore (p, s)) { 1244 if (p->ST) { 1245 rde_stack_push (p->ast, p->SV); 1246 Tcl_IncrRefCount (p->SV); 1247 } 1248 return 1; 1249 } 1250 rde_stack_push (p->LS, (void*) p->CL); 1251 return 0; 1252 } 1253 SCOPE int 1254 rde_param_i_symbol_start_d (RDE_PARAM p, long int s) 1255 { 1256 if (rde_param_i_symbol_restore (p, s)) { 1257 if (p->ST) { 1258 rde_stack_push (p->ast, p->SV); 1259 Tcl_IncrRefCount (p->SV); 1260 } 1261 return 1; 1262 } 1263 rde_stack_push (p->LS, (void*) p->CL); 1264 rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); 1265 return 0; 1266 } 1267 SCOPE int 1268 rde_param_i_symbol_void_start (RDE_PARAM p, long int s) 1269 { 1270 if (rde_param_i_symbol_restore (p, s)) return 1; 1271 rde_stack_push (p->LS, (void*) p->CL); 1272 return 0; 1273 } 1274 SCOPE int 1275 rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) 1276 { 1277 if (rde_param_i_symbol_restore (p, s)) return 1; 1278 rde_stack_push (p->LS, (void*) p->CL); 1279 rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); 1280 return 0; 1281 } 1282 SCOPE void 1283 rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) 1284 { 1285 if (p->ST) { 1286 rde_param_i_value_reduce (p, s); 1287 } else { 1288 SV_CLEAR (p); 1289 } 1290 rde_param_i_symbol_save (p, s); 1291 rde_param_i_error_nonterminal (p, m); 1292 rde_param_i_ast_pop_rewind (p); 1293 rde_stack_pop (p->LS, 1); 1294 if (p->ST) { 1295 rde_stack_push (p->ast, p->SV); 1296 Tcl_IncrRefCount (p->SV); 1297 } 1298 } 1299 SCOPE void 1300 rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) 1301 { 1302 if (p->ST) { 1303 rde_param_i_value_leaf (p, s); 1304 } else { 1305 SV_CLEAR (p); 1306 } 1307 rde_param_i_symbol_save (p, s); 1308 rde_param_i_error_nonterminal (p, m); 1309 rde_stack_pop (p->LS, 1); 1310 if (p->ST) { 1311 rde_stack_push (p->ast, p->SV); 1312 Tcl_IncrRefCount (p->SV); 1313 } 1314 } 1315 SCOPE void 1316 rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) 1317 { 1318 if (p->ST) { 1319 rde_param_i_value_leaf (p, s); 1320 } else { 1321 SV_CLEAR (p); 1322 } 1323 rde_param_i_symbol_save (p, s); 1324 rde_param_i_error_nonterminal (p, m); 1325 rde_param_i_ast_pop_rewind (p); 1326 rde_stack_pop (p->LS, 1); 1327 if (p->ST) { 1328 rde_stack_push (p->ast, p->SV); 1329 Tcl_IncrRefCount (p->SV); 1330 } 1331 } 1332 SCOPE void 1333 rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) 1334 { 1335 SV_CLEAR (p); 1336 rde_param_i_symbol_save (p, s); 1337 rde_param_i_error_nonterminal (p, m); 1338 rde_stack_pop (p->LS, 1); 1339 } 1340 SCOPE void 1341 rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) 1342 { 1343 SV_CLEAR (p); 1344 rde_param_i_symbol_save (p, s); 1345 rde_param_i_error_nonterminal (p, m); 1346 rde_param_i_ast_pop_rewind (p); 1347 rde_stack_pop (p->LS, 1); 1348 } 1349 SCOPE void 1350 rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) 1351 { 1352 rde_param_i_input_next (p, m); 1353 if (!p->ST) return; 1354 rde_param_i_test_char (p, c, m); 1355 } 1356 SCOPE void 1357 rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) 1358 { 1359 rde_param_i_input_next (p, m); 1360 if (!p->ST) return; 1361 rde_param_i_test_range (p, s, e, m); 1362 } 1363 SCOPE void 1364 rde_param_i_next_alnum (RDE_PARAM p, long int m) 1365 { 1366 rde_param_i_input_next (p, m); 1367 if (!p->ST) return; 1368 rde_param_i_test_alnum (p); 1369 } 1370 SCOPE void 1371 rde_param_i_next_alpha (RDE_PARAM p, long int m) 1372 { 1373 rde_param_i_input_next (p, m); 1374 if (!p->ST) return; 1375 rde_param_i_test_alpha (p); 1376 } 1377 SCOPE void 1378 rde_param_i_next_ascii (RDE_PARAM p, long int m) 1379 { 1380 rde_param_i_input_next (p, m); 1381 if (!p->ST) return; 1382 rde_param_i_test_ascii (p); 1383 } 1384 SCOPE void 1385 rde_param_i_next_control (RDE_PARAM p, long int m) 1386 { 1387 rde_param_i_input_next (p, m); 1388 if (!p->ST) return; 1389 rde_param_i_test_control (p); 1390 } 1391 SCOPE void 1392 rde_param_i_next_ddigit (RDE_PARAM p, long int m) 1393 { 1394 rde_param_i_input_next (p, m); 1395 if (!p->ST) return; 1396 rde_param_i_test_ddigit (p); 1397 } 1398 SCOPE void 1399 rde_param_i_next_digit (RDE_PARAM p, long int m) 1400 { 1401 rde_param_i_input_next (p, m); 1402 if (!p->ST) return; 1403 rde_param_i_test_digit (p); 1404 } 1405 SCOPE void 1406 rde_param_i_next_graph (RDE_PARAM p, long int m) 1407 { 1408 rde_param_i_input_next (p, m); 1409 if (!p->ST) return; 1410 rde_param_i_test_graph (p); 1411 } 1412 SCOPE void 1413 rde_param_i_next_lower (RDE_PARAM p, long int m) 1414 { 1415 rde_param_i_input_next (p, m); 1416 if (!p->ST) return; 1417 rde_param_i_test_lower (p); 1418 } 1419 SCOPE void 1420 rde_param_i_next_print (RDE_PARAM p, long int m) 1421 { 1422 rde_param_i_input_next (p, m); 1423 if (!p->ST) return; 1424 rde_param_i_test_print (p); 1425 } 1426 SCOPE void 1427 rde_param_i_next_punct (RDE_PARAM p, long int m) 1428 { 1429 rde_param_i_input_next (p, m); 1430 if (!p->ST) return; 1431 rde_param_i_test_punct (p); 1432 } 1433 SCOPE void 1434 rde_param_i_next_space (RDE_PARAM p, long int m) 1435 { 1436 rde_param_i_input_next (p, m); 1437 if (!p->ST) return; 1438 rde_param_i_test_space (p); 1439 } 1440 SCOPE void 1441 rde_param_i_next_upper (RDE_PARAM p, long int m) 1442 { 1443 rde_param_i_input_next (p, m); 1444 if (!p->ST) return; 1445 rde_param_i_test_upper (p); 1446 } 1447 SCOPE void 1448 rde_param_i_next_wordchar (RDE_PARAM p, long int m) 1449 { 1450 rde_param_i_input_next (p, m); 1451 if (!p->ST) return; 1452 rde_param_i_test_wordchar (p); 1453 } 1454 SCOPE void 1455 rde_param_i_next_xdigit (RDE_PARAM p, long int m) 1456 { 1457 rde_param_i_input_next (p, m); 1458 if (!p->ST) return; 1459 rde_param_i_test_xdigit (p); 1460 } 1461 SCOPE void 1462 rde_param_i_notahead_start_d (RDE_PARAM p) 1463 { 1464 rde_stack_push (p->LS, (void*) p->CL); 1465 rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); 1466 } 1467 SCOPE void 1468 rde_param_i_notahead_exit_d (RDE_PARAM p) 1469 { 1470 if (p->ST) { 1471 rde_param_i_ast_pop_rewind (p); 1472 } else { 1473 rde_stack_pop (p->mark, 1); 1474 } 1475 p->CL = (long int) rde_stack_top (p->LS); 1476 rde_stack_pop (p->LS, 1); 1477 p->ST = !p->ST; 1478 } 1479 SCOPE void 1480 rde_param_i_notahead_exit (RDE_PARAM p) 1481 { 1482 p->CL = (long int) rde_stack_top (p->LS); 1483 rde_stack_pop (p->LS, 1); 1484 p->ST = !p->ST; 1485 } 1486 SCOPE void 1487 rde_param_i_state_push_2 (RDE_PARAM p) 1488 { 1489 1490 rde_stack_push (p->LS, (void*) p->CL); 1491 rde_stack_push (p->ES, p->ER); 1492 if (p->ER) { p->ER->refCount ++; } 1493 } 1494 SCOPE void 1495 rde_param_i_state_push_void (RDE_PARAM p) 1496 { 1497 rde_stack_push (p->LS, (void*) p->CL); 1498 ER_CLEAR (p); 1499 rde_stack_push (p->ES, p->ER); 1500 1501 } 1502 SCOPE void 1503 rde_param_i_state_push_value (RDE_PARAM p) 1504 { 1505 rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); 1506 rde_stack_push (p->LS, (void*) p->CL); 1507 ER_CLEAR (p); 1508 rde_stack_push (p->ES, p->ER); 1509 1510 } 1511 SCOPE void 1512 rde_param_i_state_merge_ok (RDE_PARAM p) 1513 { 1514 rde_param_i_error_pop_merge (p); 1515 if (!p->ST) { 1516 p->ST = 1; 1517 p->CL = (long int) rde_stack_top (p->LS); 1518 } 1519 rde_stack_pop (p->LS, 1); 1520 } 1521 SCOPE void 1522 rde_param_i_state_merge_void (RDE_PARAM p) 1523 { 1524 rde_param_i_error_pop_merge (p); 1525 if (!p->ST) { 1526 p->CL = (long int) rde_stack_top (p->LS); 1527 } 1528 rde_stack_pop (p->LS, 1); 1529 } 1530 SCOPE void 1531 rde_param_i_state_merge_value (RDE_PARAM p) 1532 { 1533 rde_param_i_error_pop_merge (p); 1534 if (!p->ST) { 1535 long int trim = (long int) rde_stack_top (p->mark); 1536 rde_stack_trim (p->ast, trim); 1537 p->CL = (long int) rde_stack_top (p->LS); 1538 } 1539 rde_stack_pop (p->mark, 1); 1540 rde_stack_pop (p->LS, 1); 1541 } 1542 SCOPE int 1543 rde_param_i_kleene_close (RDE_PARAM p) 1544 { 1545 int stop = !p->ST; 1546 rde_param_i_error_pop_merge (p); 1547 if (stop) { 1548 p->ST = 1; 1549 p->CL = (long int) rde_stack_top (p->LS); 1550 } 1551 rde_stack_pop (p->LS, 1); 1552 return stop; 1553 } 1554 SCOPE int 1555 rde_param_i_kleene_abort (RDE_PARAM p) 1556 { 1557 int stop = !p->ST; 1558 if (stop) { 1559 p->CL = (long int) rde_stack_top (p->LS); 1560 } 1561 rde_stack_pop (p->LS, 1); 1562 return stop; 1563 } 1564 SCOPE int 1565 rde_param_i_seq_void2void (RDE_PARAM p) 1566 { 1567 rde_param_i_error_pop_merge (p); 1568 if (p->ST) { 1569 rde_stack_push (p->ES, p->ER); 1570 if (p->ER) { p->ER->refCount ++; } 1571 return 0; 1572 } else { 1573 p->CL = (long int) rde_stack_top (p->LS); 1574 rde_stack_pop (p->LS, 1); 1575 return 1; 1576 } 1577 } 1578 SCOPE int 1579 rde_param_i_seq_void2value (RDE_PARAM p) 1580 { 1581 rde_param_i_error_pop_merge (p); 1582 if (p->ST) { 1583 rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); 1584 rde_stack_push (p->ES, p->ER); 1585 if (p->ER) { p->ER->refCount ++; } 1586 return 0; 1587 } else { 1588 p->CL = (long int) rde_stack_top (p->LS); 1589 rde_stack_pop (p->LS, 1); 1590 return 1; 1591 } 1592 } 1593 SCOPE int 1594 rde_param_i_seq_value2value (RDE_PARAM p) 1595 { 1596 rde_param_i_error_pop_merge (p); 1597 if (p->ST) { 1598 rde_stack_push (p->ES, p->ER); 1599 if (p->ER) { p->ER->refCount ++; } 1600 return 0; 1601 } else { 1602 long int trim = (long int) rde_stack_top (p->mark); 1603 rde_stack_pop (p->mark, 1); 1604 rde_stack_trim (p->ast, trim); 1605 p->CL = (long int) rde_stack_top (p->LS); 1606 rde_stack_pop (p->LS, 1); 1607 return 1; 1608 } 1609 } 1610 SCOPE int 1611 rde_param_i_bra_void2void (RDE_PARAM p) 1612 { 1613 rde_param_i_error_pop_merge (p); 1614 if (p->ST) { 1615 rde_stack_pop (p->LS, 1); 1616 } else { 1617 p->CL = (long int) rde_stack_top (p->LS); 1618 rde_stack_push (p->ES, p->ER); 1619 if (p->ER) { p->ER->refCount ++; } 1620 } 1621 return p->ST; 1622 } 1623 SCOPE int 1624 rde_param_i_bra_void2value (RDE_PARAM p) 1625 { 1626 rde_param_i_error_pop_merge (p); 1627 if (p->ST) { 1628 rde_stack_pop (p->LS, 1); 1629 } else { 1630 rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); 1631 p->CL = (long int) rde_stack_top (p->LS); 1632 rde_stack_push (p->ES, p->ER); 1633 if (p->ER) { p->ER->refCount ++; } 1634 } 1635 return p->ST; 1636 } 1637 SCOPE int 1638 rde_param_i_bra_value2void (RDE_PARAM p) 1639 { 1640 rde_param_i_error_pop_merge (p); 1641 if (p->ST) { 1642 rde_stack_pop (p->mark, 1); 1643 rde_stack_pop (p->LS, 1); 1644 } else { 1645 long int trim = (long int) rde_stack_top (p->mark); 1646 rde_stack_pop (p->mark, 1); 1647 rde_stack_trim (p->ast, trim); 1648 p->CL = (long int) rde_stack_top (p->LS); 1649 rde_stack_push (p->ES, p->ER); 1650 if (p->ER) { p->ER->refCount ++; } 1651 } 1652 return p->ST; 1653 } 1654 SCOPE int 1655 rde_param_i_bra_value2value (RDE_PARAM p) 1656 { 1657 rde_param_i_error_pop_merge (p); 1658 if (p->ST) { 1659 rde_stack_pop (p->mark, 1); 1660 rde_stack_pop (p->LS, 1); 1661 } else { 1662 long int trim = (long int) rde_stack_top (p->mark); 1663 rde_stack_trim (p->ast, trim); 1664 p->CL = (long int) rde_stack_top (p->LS); 1665 rde_stack_push (p->ES, p->ER); 1666 if (p->ER) { p->ER->refCount ++; } 1667 } 1668 return p->ST; 1669 } 1670 SCOPE void 1671 rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) 1672 { 1673 int at = p->CL; 1674 1675 while (*str) { 1676 rde_param_i_input_next (p, m); 1677 if (!p->ST) { 1678 p->ER->loc = at+1; 1679 p->CL = at; 1680 return; 1681 } 1682 rde_param_i_test_char (p, str, m); 1683 if (!p->ST) { 1684 p->ER->loc = at+1; 1685 p->CL = at; 1686 return; 1687 } 1688 str = Tcl_UtfNext (str); 1689 } 1690 } 1691 SCOPE void 1692 rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) 1693 { 1694 rde_param_i_input_next (p, m); 1695 if (!p->ST) return; 1696 while (*class) { 1697 p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; 1698 if (p->ST) { 1699 ER_CLEAR (p); 1700 return; 1701 } 1702 class = Tcl_UtfNext (class); 1703 } 1704 error_set (p, m); 1705 p->CL --; 1706 } 1707 1708 1709 } 1710 1711 # # ## ### ###### ######## ############# 1712 ## BEGIN of GENERATED CODE. DO NOT EDIT. 1713 1714 critcl::ccode { 1715 /* -*- c -*- */ 1716 1717 /* 1718 * Declaring the parse functions 1719 */ 1720 1721 static void sequence_4 (RDE_PARAM p); 1722 static void sym_ALNUM (RDE_PARAM p); 1723 static void sequence_9 (RDE_PARAM p); 1724 static void sym_ALPHA (RDE_PARAM p); 1725 static void sequence_14 (RDE_PARAM p); 1726 static void sym_AND (RDE_PARAM p); 1727 static void sym_APOSTROPH (RDE_PARAM p); 1728 static void sequence_21 (RDE_PARAM p); 1729 static void sym_ASCII (RDE_PARAM p); 1730 static void choice_26 (RDE_PARAM p); 1731 static void sequence_29 (RDE_PARAM p); 1732 static void sym_Attribute (RDE_PARAM p); 1733 static void choice_37 (RDE_PARAM p); 1734 static void sym_Char (RDE_PARAM p); 1735 static void sequence_44 (RDE_PARAM p); 1736 static void sym_CharOctalFull (RDE_PARAM p); 1737 static void optional_50 (RDE_PARAM p); 1738 static void sequence_52 (RDE_PARAM p); 1739 static void sym_CharOctalPart (RDE_PARAM p); 1740 static void sequence_57 (RDE_PARAM p); 1741 static void sym_CharSpecial (RDE_PARAM p); 1742 static void notahead_61 (RDE_PARAM p); 1743 static void sequence_64 (RDE_PARAM p); 1744 static void sym_CharUnescaped (RDE_PARAM p); 1745 static void optional_72 (RDE_PARAM p); 1746 static void sequence_74 (RDE_PARAM p); 1747 static void optional_76 (RDE_PARAM p); 1748 static void sequence_78 (RDE_PARAM p); 1749 static void optional_80 (RDE_PARAM p); 1750 static void sequence_82 (RDE_PARAM p); 1751 static void sym_CharUnicode (RDE_PARAM p); 1752 static void notahead_87 (RDE_PARAM p); 1753 static void sequence_90 (RDE_PARAM p); 1754 static void kleene_92 (RDE_PARAM p); 1755 static void sequence_96 (RDE_PARAM p); 1756 static void sym_Class (RDE_PARAM p); 1757 static void sequence_101 (RDE_PARAM p); 1758 static void sym_CLOSE (RDE_PARAM p); 1759 static void sym_CLOSEB (RDE_PARAM p); 1760 static void sequence_108 (RDE_PARAM p); 1761 static void sym_COLON (RDE_PARAM p); 1762 static void notahead_113 (RDE_PARAM p); 1763 static void sequence_116 (RDE_PARAM p); 1764 static void kleene_118 (RDE_PARAM p); 1765 static void sequence_121 (RDE_PARAM p); 1766 static void sym_COMMENT (RDE_PARAM p); 1767 static void sequence_126 (RDE_PARAM p); 1768 static void sym_CONTROL (RDE_PARAM p); 1769 static void sym_DAPOSTROPH (RDE_PARAM p); 1770 static void sequence_133 (RDE_PARAM p); 1771 static void sym_DDIGIT (RDE_PARAM p); 1772 static void optional_137 (RDE_PARAM p); 1773 static void sequence_143 (RDE_PARAM p); 1774 static void sym_Definition (RDE_PARAM p); 1775 static void sequence_148 (RDE_PARAM p); 1776 static void sym_DIGIT (RDE_PARAM p); 1777 static void sequence_153 (RDE_PARAM p); 1778 static void sym_DOT (RDE_PARAM p); 1779 static void notahead_157 (RDE_PARAM p); 1780 static void sym_EOF (RDE_PARAM p); 1781 static void sym_EOL (RDE_PARAM p); 1782 static void sequence_165 (RDE_PARAM p); 1783 static void kleene_167 (RDE_PARAM p); 1784 static void sequence_169 (RDE_PARAM p); 1785 static void sym_Expression (RDE_PARAM p); 1786 static void sequence_176 (RDE_PARAM p); 1787 static void sym_Final (RDE_PARAM p); 1788 static void kleene_182 (RDE_PARAM p); 1789 static void sequence_186 (RDE_PARAM p); 1790 static void sym_Grammar (RDE_PARAM p); 1791 static void sequence_191 (RDE_PARAM p); 1792 static void sym_GRAPH (RDE_PARAM p); 1793 static void sequence_197 (RDE_PARAM p); 1794 static void sym_Header (RDE_PARAM p); 1795 static void choice_202 (RDE_PARAM p); 1796 static void choice_206 (RDE_PARAM p); 1797 static void kleene_208 (RDE_PARAM p); 1798 static void sequence_210 (RDE_PARAM p); 1799 static void sym_Ident (RDE_PARAM p); 1800 static void sequence_215 (RDE_PARAM p); 1801 static void sym_Identifier (RDE_PARAM p); 1802 static void sequence_220 (RDE_PARAM p); 1803 static void sym_IS (RDE_PARAM p); 1804 static void sequence_225 (RDE_PARAM p); 1805 static void sym_LEAF (RDE_PARAM p); 1806 static void notahead_230 (RDE_PARAM p); 1807 static void sequence_233 (RDE_PARAM p); 1808 static void kleene_235 (RDE_PARAM p); 1809 static void sequence_239 (RDE_PARAM p); 1810 static void notahead_243 (RDE_PARAM p); 1811 static void sequence_246 (RDE_PARAM p); 1812 static void kleene_248 (RDE_PARAM p); 1813 static void sequence_252 (RDE_PARAM p); 1814 static void choice_254 (RDE_PARAM p); 1815 static void sym_Literal (RDE_PARAM p); 1816 static void sequence_259 (RDE_PARAM p); 1817 static void sym_LOWER (RDE_PARAM p); 1818 static void sequence_264 (RDE_PARAM p); 1819 static void sym_NOT (RDE_PARAM p); 1820 static void sequence_269 (RDE_PARAM p); 1821 static void sym_OPEN (RDE_PARAM p); 1822 static void sym_OPENB (RDE_PARAM p); 1823 static void notahead_278 (RDE_PARAM p); 1824 static void sequence_281 (RDE_PARAM p); 1825 static void sym_PEG (RDE_PARAM p); 1826 static void sequence_286 (RDE_PARAM p); 1827 static void sym_PLUS (RDE_PARAM p); 1828 static void choice_291 (RDE_PARAM p); 1829 static void optional_293 (RDE_PARAM p); 1830 static void sequence_296 (RDE_PARAM p); 1831 static void sym_Prefix (RDE_PARAM p); 1832 static void sequence_317 (RDE_PARAM p); 1833 static void choice_322 (RDE_PARAM p); 1834 static void sym_Primary (RDE_PARAM p); 1835 static void sequence_327 (RDE_PARAM p); 1836 static void sym_PRINTABLE (RDE_PARAM p); 1837 static void sequence_332 (RDE_PARAM p); 1838 static void sym_PUNCT (RDE_PARAM p); 1839 static void sequence_337 (RDE_PARAM p); 1840 static void sym_QUESTION (RDE_PARAM p); 1841 static void sequence_343 (RDE_PARAM p); 1842 static void choice_346 (RDE_PARAM p); 1843 static void sym_Range (RDE_PARAM p); 1844 static void sequence_351 (RDE_PARAM p); 1845 static void sym_SEMICOLON (RDE_PARAM p); 1846 static void poskleene_355 (RDE_PARAM p); 1847 static void sym_Sequence (RDE_PARAM p); 1848 static void sequence_360 (RDE_PARAM p); 1849 static void sym_SLASH (RDE_PARAM p); 1850 static void sequence_365 (RDE_PARAM p); 1851 static void sym_SPACE (RDE_PARAM p); 1852 static void sequence_370 (RDE_PARAM p); 1853 static void sym_STAR (RDE_PARAM p); 1854 static void sym_StartExpr (RDE_PARAM p); 1855 static void choice_382 (RDE_PARAM p); 1856 static void optional_384 (RDE_PARAM p); 1857 static void sequence_386 (RDE_PARAM p); 1858 static void sym_Suffix (RDE_PARAM p); 1859 static void sym_TO (RDE_PARAM p); 1860 static void sequence_393 (RDE_PARAM p); 1861 static void sym_UPPER (RDE_PARAM p); 1862 static void sequence_398 (RDE_PARAM p); 1863 static void sym_VOID (RDE_PARAM p); 1864 static void choice_403 (RDE_PARAM p); 1865 static void kleene_405 (RDE_PARAM p); 1866 static void sym_WHITESPACE (RDE_PARAM p); 1867 static void sequence_410 (RDE_PARAM p); 1868 static void sym_WORDCHAR (RDE_PARAM p); 1869 static void sequence_415 (RDE_PARAM p); 1870 static void sym_XDIGIT (RDE_PARAM p); 1871 1872 /* 1873 * Precomputed table of strings (symbols, error messages, etc.). 1874 */ 1875 1876 static char const* p_string [178] = { 1877 /* 0 = */ "alnum", 1878 /* 1 = */ "alpha", 1879 /* 2 = */ "ascii", 1880 /* 3 = */ "control", 1881 /* 4 = */ "ddigit", 1882 /* 5 = */ "digit", 1883 /* 6 = */ "graph", 1884 /* 7 = */ "lower", 1885 /* 8 = */ "print", 1886 /* 9 = */ "punct", 1887 /* 10 = */ "space", 1888 /* 11 = */ "upper", 1889 /* 12 = */ "wordchar", 1890 /* 13 = */ "xdigit", 1891 /* 14 = */ "str <alnum>", 1892 /* 15 = */ "n ALNUM", 1893 /* 16 = */ "ALNUM", 1894 /* 17 = */ "str <alpha>", 1895 /* 18 = */ "n ALPHA", 1896 /* 19 = */ "ALPHA", 1897 /* 20 = */ "t &", 1898 /* 21 = */ "n AND", 1899 /* 22 = */ "AND", 1900 /* 23 = */ "t '", 1901 /* 24 = */ "n APOSTROPH", 1902 /* 25 = */ "APOSTROPH", 1903 /* 26 = */ "str <ascii>", 1904 /* 27 = */ "n ASCII", 1905 /* 28 = */ "ASCII", 1906 /* 29 = */ "n Attribute", 1907 /* 30 = */ "Attribute", 1908 /* 31 = */ "n Char", 1909 /* 32 = */ "Char", 1910 /* 33 = */ "t \\\\", 1911 /* 34 = */ ".. 0 2", 1912 /* 35 = */ ".. 0 7", 1913 /* 36 = */ "n CharOctalFull", 1914 /* 37 = */ "CharOctalFull", 1915 /* 38 = */ "n CharOctalPart", 1916 /* 39 = */ "CharOctalPart", 1917 /* 40 = */ "cl nrt'\\\"\\[\\]\\\\", 1918 /* 41 = */ "n CharSpecial", 1919 /* 42 = */ "CharSpecial", 1920 /* 43 = */ "dot", 1921 /* 44 = */ "n CharUnescaped", 1922 /* 45 = */ "CharUnescaped", 1923 /* 46 = */ "str \173\\u\175", 1924 /* 47 = */ "n CharUnicode", 1925 /* 48 = */ "CharUnicode", 1926 /* 49 = */ "n Class", 1927 /* 50 = */ "Class", 1928 /* 51 = */ "t )", 1929 /* 52 = */ "n CLOSE", 1930 /* 53 = */ "CLOSE", 1931 /* 54 = */ "t \\]", 1932 /* 55 = */ "n CLOSEB", 1933 /* 56 = */ "CLOSEB", 1934 /* 57 = */ "t :", 1935 /* 58 = */ "n COLON", 1936 /* 59 = */ "COLON", 1937 /* 60 = */ "t #", 1938 /* 61 = */ "n COMMENT", 1939 /* 62 = */ "COMMENT", 1940 /* 63 = */ "str <control>", 1941 /* 64 = */ "n CONTROL", 1942 /* 65 = */ "CONTROL", 1943 /* 66 = */ "t \173\"\175", 1944 /* 67 = */ "n DAPOSTROPH", 1945 /* 68 = */ "DAPOSTROPH", 1946 /* 69 = */ "str <ddigit>", 1947 /* 70 = */ "n DDIGIT", 1948 /* 71 = */ "DDIGIT", 1949 /* 72 = */ "n Definition", 1950 /* 73 = */ "Definition", 1951 /* 74 = */ "str <digit>", 1952 /* 75 = */ "n DIGIT", 1953 /* 76 = */ "DIGIT", 1954 /* 77 = */ "t .", 1955 /* 78 = */ "n DOT", 1956 /* 79 = */ "DOT", 1957 /* 80 = */ "n EOF", 1958 /* 81 = */ "EOF", 1959 /* 82 = */ "cl \173\n\r\175", 1960 /* 83 = */ "n EOL", 1961 /* 84 = */ "EOL", 1962 /* 85 = */ "n Expression", 1963 /* 86 = */ "Expression", 1964 /* 87 = */ "str END", 1965 /* 88 = */ "n Final", 1966 /* 89 = */ "Final", 1967 /* 90 = */ "n Grammar", 1968 /* 91 = */ "Grammar", 1969 /* 92 = */ "str <graph>", 1970 /* 93 = */ "n GRAPH", 1971 /* 94 = */ "GRAPH", 1972 /* 95 = */ "n Header", 1973 /* 96 = */ "Header", 1974 /* 97 = */ "cl _:", 1975 /* 98 = */ "n Ident", 1976 /* 99 = */ "Ident", 1977 /* 100 = */ "n Identifier", 1978 /* 101 = */ "Identifier", 1979 /* 102 = */ "str <-", 1980 /* 103 = */ "n IS", 1981 /* 104 = */ "IS", 1982 /* 105 = */ "str leaf", 1983 /* 106 = */ "n LEAF", 1984 /* 107 = */ "LEAF", 1985 /* 108 = */ "n Literal", 1986 /* 109 = */ "Literal", 1987 /* 110 = */ "str <lower>", 1988 /* 111 = */ "n LOWER", 1989 /* 112 = */ "LOWER", 1990 /* 113 = */ "t !", 1991 /* 114 = */ "n NOT", 1992 /* 115 = */ "NOT", 1993 /* 116 = */ "t (", 1994 /* 117 = */ "n OPEN", 1995 /* 118 = */ "OPEN", 1996 /* 119 = */ "t \173[\175", 1997 /* 120 = */ "n OPENB", 1998 /* 121 = */ "OPENB", 1999 /* 122 = */ "str PEG", 2000 /* 123 = */ "n PEG", 2001 /* 124 = */ "PEG", 2002 /* 125 = */ "t +", 2003 /* 126 = */ "n PLUS", 2004 /* 127 = */ "PLUS", 2005 /* 128 = */ "n Prefix", 2006 /* 129 = */ "Prefix", 2007 /* 130 = */ "n Primary", 2008 /* 131 = */ "Primary", 2009 /* 132 = */ "str <print>", 2010 /* 133 = */ "n PRINTABLE", 2011 /* 134 = */ "PRINTABLE", 2012 /* 135 = */ "str <punct>", 2013 /* 136 = */ "n PUNCT", 2014 /* 137 = */ "PUNCT", 2015 /* 138 = */ "t ?", 2016 /* 139 = */ "n QUESTION", 2017 /* 140 = */ "QUESTION", 2018 /* 141 = */ "n Range", 2019 /* 142 = */ "Range", 2020 /* 143 = */ "t \173;\175", 2021 /* 144 = */ "n SEMICOLON", 2022 /* 145 = */ "SEMICOLON", 2023 /* 146 = */ "n Sequence", 2024 /* 147 = */ "Sequence", 2025 /* 148 = */ "t /", 2026 /* 149 = */ "n SLASH", 2027 /* 150 = */ "SLASH", 2028 /* 151 = */ "str <space>", 2029 /* 152 = */ "n SPACE", 2030 /* 153 = */ "SPACE", 2031 /* 154 = */ "t *", 2032 /* 155 = */ "n STAR", 2033 /* 156 = */ "STAR", 2034 /* 157 = */ "n StartExpr", 2035 /* 158 = */ "StartExpr", 2036 /* 159 = */ "n Suffix", 2037 /* 160 = */ "Suffix", 2038 /* 161 = */ "t -", 2039 /* 162 = */ "n TO", 2040 /* 163 = */ "TO", 2041 /* 164 = */ "str <upper>", 2042 /* 165 = */ "n UPPER", 2043 /* 166 = */ "UPPER", 2044 /* 167 = */ "str void", 2045 /* 168 = */ "n VOID", 2046 /* 169 = */ "VOID", 2047 /* 170 = */ "n WHITESPACE", 2048 /* 171 = */ "WHITESPACE", 2049 /* 172 = */ "str <wordchar>", 2050 /* 173 = */ "n WORDCHAR", 2051 /* 174 = */ "WORDCHAR", 2052 /* 175 = */ "str <xdigit>", 2053 /* 176 = */ "n XDIGIT", 2054 /* 177 = */ "XDIGIT" 2055 }; 2056 2057 /* 2058 * Grammar Start Expression 2059 */ 2060 2061 static void MAIN (RDE_PARAM p) { 2062 sym_Grammar (p); 2063 return; 2064 } 2065 2066 /* 2067 * leaf Symbol 'ALNUM' 2068 */ 2069 2070 static void sym_ALNUM (RDE_PARAM p) { 2071 /* 2072 * x 2073 * "<alnum>" 2074 * (WHITESPACE) 2075 */ 2076 2077 if (rde_param_i_symbol_start (p, 16)) return ; 2078 sequence_4 (p); 2079 rde_param_i_symbol_done_leaf (p, 16, 15); 2080 return; 2081 } 2082 2083 static void sequence_4 (RDE_PARAM p) { 2084 /* 2085 * x 2086 * "<alnum>" 2087 * (WHITESPACE) 2088 */ 2089 2090 rde_param_i_state_push_void (p); 2091 rde_param_i_next_str (p, "<alnum>", 14); 2092 if (rde_param_i_seq_void2void(p)) return; 2093 sym_WHITESPACE (p); 2094 rde_param_i_state_merge_void (p); 2095 return; 2096 } 2097 2098 /* 2099 * leaf Symbol 'ALPHA' 2100 */ 2101 2102 static void sym_ALPHA (RDE_PARAM p) { 2103 /* 2104 * x 2105 * "<alpha>" 2106 * (WHITESPACE) 2107 */ 2108 2109 if (rde_param_i_symbol_start (p, 19)) return ; 2110 sequence_9 (p); 2111 rde_param_i_symbol_done_leaf (p, 19, 18); 2112 return; 2113 } 2114 2115 static void sequence_9 (RDE_PARAM p) { 2116 /* 2117 * x 2118 * "<alpha>" 2119 * (WHITESPACE) 2120 */ 2121 2122 rde_param_i_state_push_void (p); 2123 rde_param_i_next_str (p, "<alpha>", 17); 2124 if (rde_param_i_seq_void2void(p)) return; 2125 sym_WHITESPACE (p); 2126 rde_param_i_state_merge_void (p); 2127 return; 2128 } 2129 2130 /* 2131 * leaf Symbol 'AND' 2132 */ 2133 2134 static void sym_AND (RDE_PARAM p) { 2135 /* 2136 * x 2137 * '&' 2138 * (WHITESPACE) 2139 */ 2140 2141 if (rde_param_i_symbol_start (p, 22)) return ; 2142 sequence_14 (p); 2143 rde_param_i_symbol_done_leaf (p, 22, 21); 2144 return; 2145 } 2146 2147 static void sequence_14 (RDE_PARAM p) { 2148 /* 2149 * x 2150 * '&' 2151 * (WHITESPACE) 2152 */ 2153 2154 rde_param_i_state_push_void (p); 2155 rde_param_i_next_char (p, "&", 20); 2156 if (rde_param_i_seq_void2void(p)) return; 2157 sym_WHITESPACE (p); 2158 rde_param_i_state_merge_void (p); 2159 return; 2160 } 2161 2162 /* 2163 * void Symbol 'APOSTROPH' 2164 */ 2165 2166 static void sym_APOSTROPH (RDE_PARAM p) { 2167 /* 2168 * ''' 2169 */ 2170 2171 if (rde_param_i_symbol_void_start (p, 25)) return ; 2172 rde_param_i_next_char (p, "'", 23); 2173 rde_param_i_symbol_done_void (p, 25, 24); 2174 return; 2175 } 2176 2177 /* 2178 * leaf Symbol 'ASCII' 2179 */ 2180 2181 static void sym_ASCII (RDE_PARAM p) { 2182 /* 2183 * x 2184 * "<ascii>" 2185 * (WHITESPACE) 2186 */ 2187 2188 if (rde_param_i_symbol_start (p, 28)) return ; 2189 sequence_21 (p); 2190 rde_param_i_symbol_done_leaf (p, 28, 27); 2191 return; 2192 } 2193 2194 static void sequence_21 (RDE_PARAM p) { 2195 /* 2196 * x 2197 * "<ascii>" 2198 * (WHITESPACE) 2199 */ 2200 2201 rde_param_i_state_push_void (p); 2202 rde_param_i_next_str (p, "<ascii>", 26); 2203 if (rde_param_i_seq_void2void(p)) return; 2204 sym_WHITESPACE (p); 2205 rde_param_i_state_merge_void (p); 2206 return; 2207 } 2208 2209 /* 2210 * value Symbol 'Attribute' 2211 */ 2212 2213 static void sym_Attribute (RDE_PARAM p) { 2214 /* 2215 * x 2216 * / 2217 * (VOID) 2218 * (LEAF) 2219 * (COLON) 2220 */ 2221 2222 if (rde_param_i_symbol_start_d (p, 30)) return ; 2223 sequence_29 (p); 2224 rde_param_i_symbol_done_d_reduce (p, 30, 29); 2225 return; 2226 } 2227 2228 static void sequence_29 (RDE_PARAM p) { 2229 /* 2230 * x 2231 * / 2232 * (VOID) 2233 * (LEAF) 2234 * (COLON) 2235 */ 2236 2237 rde_param_i_state_push_value (p); 2238 choice_26 (p); 2239 if (rde_param_i_seq_value2value(p)) return; 2240 sym_COLON (p); 2241 rde_param_i_state_merge_value (p); 2242 return; 2243 } 2244 2245 static void choice_26 (RDE_PARAM p) { 2246 /* 2247 * / 2248 * (VOID) 2249 * (LEAF) 2250 */ 2251 2252 rde_param_i_state_push_value (p); 2253 sym_VOID (p); 2254 if (rde_param_i_bra_value2value(p)) return; 2255 sym_LEAF (p); 2256 rde_param_i_state_merge_value (p); 2257 return; 2258 } 2259 2260 /* 2261 * value Symbol 'Char' 2262 */ 2263 2264 static void sym_Char (RDE_PARAM p) { 2265 /* 2266 * / 2267 * (CharSpecial) 2268 * (CharOctalFull) 2269 * (CharOctalPart) 2270 * (CharUnicode) 2271 * (CharUnescaped) 2272 */ 2273 2274 if (rde_param_i_symbol_start_d (p, 32)) return ; 2275 choice_37 (p); 2276 rde_param_i_symbol_done_d_reduce (p, 32, 31); 2277 return; 2278 } 2279 2280 static void choice_37 (RDE_PARAM p) { 2281 /* 2282 * / 2283 * (CharSpecial) 2284 * (CharOctalFull) 2285 * (CharOctalPart) 2286 * (CharUnicode) 2287 * (CharUnescaped) 2288 */ 2289 2290 rde_param_i_state_push_value (p); 2291 sym_CharSpecial (p); 2292 if (rde_param_i_bra_value2value(p)) return; 2293 sym_CharOctalFull (p); 2294 if (rde_param_i_bra_value2value(p)) return; 2295 sym_CharOctalPart (p); 2296 if (rde_param_i_bra_value2value(p)) return; 2297 sym_CharUnicode (p); 2298 if (rde_param_i_bra_value2value(p)) return; 2299 sym_CharUnescaped (p); 2300 rde_param_i_state_merge_value (p); 2301 return; 2302 } 2303 2304 /* 2305 * leaf Symbol 'CharOctalFull' 2306 */ 2307 2308 static void sym_CharOctalFull (RDE_PARAM p) { 2309 /* 2310 * x 2311 * '\' 2312 * range (0 .. 2) 2313 * range (0 .. 7) 2314 * range (0 .. 7) 2315 */ 2316 2317 if (rde_param_i_symbol_start (p, 37)) return ; 2318 sequence_44 (p); 2319 rde_param_i_symbol_done_leaf (p, 37, 36); 2320 return; 2321 } 2322 2323 static void sequence_44 (RDE_PARAM p) { 2324 /* 2325 * x 2326 * '\' 2327 * range (0 .. 2) 2328 * range (0 .. 7) 2329 * range (0 .. 7) 2330 */ 2331 2332 rde_param_i_state_push_void (p); 2333 rde_param_i_next_char (p, "\\", 33); 2334 if (rde_param_i_seq_void2void(p)) return; 2335 rde_param_i_next_range (p, "0", "2", 34); 2336 if (rde_param_i_seq_void2void(p)) return; 2337 rde_param_i_next_range (p, "0", "7", 35); 2338 if (rde_param_i_seq_void2void(p)) return; 2339 rde_param_i_next_range (p, "0", "7", 35); 2340 rde_param_i_state_merge_void (p); 2341 return; 2342 } 2343 2344 /* 2345 * leaf Symbol 'CharOctalPart' 2346 */ 2347 2348 static void sym_CharOctalPart (RDE_PARAM p) { 2349 /* 2350 * x 2351 * '\' 2352 * range (0 .. 7) 2353 * ? 2354 * range (0 .. 7) 2355 */ 2356 2357 if (rde_param_i_symbol_start (p, 39)) return ; 2358 sequence_52 (p); 2359 rde_param_i_symbol_done_leaf (p, 39, 38); 2360 return; 2361 } 2362 2363 static void sequence_52 (RDE_PARAM p) { 2364 /* 2365 * x 2366 * '\' 2367 * range (0 .. 7) 2368 * ? 2369 * range (0 .. 7) 2370 */ 2371 2372 rde_param_i_state_push_void (p); 2373 rde_param_i_next_char (p, "\\", 33); 2374 if (rde_param_i_seq_void2void(p)) return; 2375 rde_param_i_next_range (p, "0", "7", 35); 2376 if (rde_param_i_seq_void2void(p)) return; 2377 optional_50 (p); 2378 rde_param_i_state_merge_void (p); 2379 return; 2380 } 2381 2382 static void optional_50 (RDE_PARAM p) { 2383 /* 2384 * ? 2385 * range (0 .. 7) 2386 */ 2387 2388 rde_param_i_state_push_2 (p); 2389 rde_param_i_next_range (p, "0", "7", 35); 2390 rde_param_i_state_merge_ok (p); 2391 return; 2392 } 2393 2394 /* 2395 * leaf Symbol 'CharSpecial' 2396 */ 2397 2398 static void sym_CharSpecial (RDE_PARAM p) { 2399 /* 2400 * x 2401 * '\' 2402 * [nrt'\"[]\] 2403 */ 2404 2405 if (rde_param_i_symbol_start (p, 42)) return ; 2406 sequence_57 (p); 2407 rde_param_i_symbol_done_leaf (p, 42, 41); 2408 return; 2409 } 2410 2411 static void sequence_57 (RDE_PARAM p) { 2412 /* 2413 * x 2414 * '\' 2415 * [nrt'\"[]\] 2416 */ 2417 2418 rde_param_i_state_push_void (p); 2419 rde_param_i_next_char (p, "\\", 33); 2420 if (rde_param_i_seq_void2void(p)) return; 2421 rde_param_i_next_class (p, "nrt'\"[]\\", 40); 2422 rde_param_i_state_merge_void (p); 2423 return; 2424 } 2425 2426 /* 2427 * leaf Symbol 'CharUnescaped' 2428 */ 2429 2430 static void sym_CharUnescaped (RDE_PARAM p) { 2431 /* 2432 * x 2433 * ! 2434 * '\' 2435 * <dot> 2436 */ 2437 2438 if (rde_param_i_symbol_start (p, 45)) return ; 2439 sequence_64 (p); 2440 rde_param_i_symbol_done_leaf (p, 45, 44); 2441 return; 2442 } 2443 2444 static void sequence_64 (RDE_PARAM p) { 2445 /* 2446 * x 2447 * ! 2448 * '\' 2449 * <dot> 2450 */ 2451 2452 rde_param_i_state_push_void (p); 2453 notahead_61 (p); 2454 if (rde_param_i_seq_void2void(p)) return; 2455 rde_param_i_input_next (p, 43); 2456 rde_param_i_state_merge_void (p); 2457 return; 2458 } 2459 2460 static void notahead_61 (RDE_PARAM p) { 2461 /* 2462 * ! 2463 * '\' 2464 */ 2465 2466 rde_param_i_loc_push (p); 2467 rde_param_i_next_char (p, "\\", 33); 2468 rde_param_i_notahead_exit (p); 2469 return; 2470 } 2471 2472 /* 2473 * leaf Symbol 'CharUnicode' 2474 */ 2475 2476 static void sym_CharUnicode (RDE_PARAM p) { 2477 /* 2478 * x 2479 * "\u" 2480 * <xdigit> 2481 * ? 2482 * x 2483 * <xdigit> 2484 * ? 2485 * x 2486 * <xdigit> 2487 * ? 2488 * <xdigit> 2489 */ 2490 2491 if (rde_param_i_symbol_start (p, 48)) return ; 2492 sequence_82 (p); 2493 rde_param_i_symbol_done_leaf (p, 48, 47); 2494 return; 2495 } 2496 2497 static void sequence_82 (RDE_PARAM p) { 2498 /* 2499 * x 2500 * "\u" 2501 * <xdigit> 2502 * ? 2503 * x 2504 * <xdigit> 2505 * ? 2506 * x 2507 * <xdigit> 2508 * ? 2509 * <xdigit> 2510 */ 2511 2512 rde_param_i_state_push_void (p); 2513 rde_param_i_next_str (p, "\\u", 46); 2514 if (rde_param_i_seq_void2void(p)) return; 2515 rde_param_i_next_xdigit (p, 13); 2516 if (rde_param_i_seq_void2void(p)) return; 2517 optional_80 (p); 2518 rde_param_i_state_merge_void (p); 2519 return; 2520 } 2521 2522 static void optional_80 (RDE_PARAM p) { 2523 /* 2524 * ? 2525 * x 2526 * <xdigit> 2527 * ? 2528 * x 2529 * <xdigit> 2530 * ? 2531 * <xdigit> 2532 */ 2533 2534 rde_param_i_state_push_2 (p); 2535 sequence_78 (p); 2536 rde_param_i_state_merge_ok (p); 2537 return; 2538 } 2539 2540 static void sequence_78 (RDE_PARAM p) { 2541 /* 2542 * x 2543 * <xdigit> 2544 * ? 2545 * x 2546 * <xdigit> 2547 * ? 2548 * <xdigit> 2549 */ 2550 2551 rde_param_i_state_push_void (p); 2552 rde_param_i_next_xdigit (p, 13); 2553 if (rde_param_i_seq_void2void(p)) return; 2554 optional_76 (p); 2555 rde_param_i_state_merge_void (p); 2556 return; 2557 } 2558 2559 static void optional_76 (RDE_PARAM p) { 2560 /* 2561 * ? 2562 * x 2563 * <xdigit> 2564 * ? 2565 * <xdigit> 2566 */ 2567 2568 rde_param_i_state_push_2 (p); 2569 sequence_74 (p); 2570 rde_param_i_state_merge_ok (p); 2571 return; 2572 } 2573 2574 static void sequence_74 (RDE_PARAM p) { 2575 /* 2576 * x 2577 * <xdigit> 2578 * ? 2579 * <xdigit> 2580 */ 2581 2582 rde_param_i_state_push_void (p); 2583 rde_param_i_next_xdigit (p, 13); 2584 if (rde_param_i_seq_void2void(p)) return; 2585 optional_72 (p); 2586 rde_param_i_state_merge_void (p); 2587 return; 2588 } 2589 2590 static void optional_72 (RDE_PARAM p) { 2591 /* 2592 * ? 2593 * <xdigit> 2594 */ 2595 2596 rde_param_i_state_push_2 (p); 2597 rde_param_i_next_xdigit (p, 13); 2598 rde_param_i_state_merge_ok (p); 2599 return; 2600 } 2601 2602 /* 2603 * value Symbol 'Class' 2604 */ 2605 2606 static void sym_Class (RDE_PARAM p) { 2607 /* 2608 * x 2609 * (OPENB) 2610 * * 2611 * x 2612 * ! 2613 * (CLOSEB) 2614 * (Range) 2615 * (CLOSEB) 2616 * (WHITESPACE) 2617 */ 2618 2619 if (rde_param_i_symbol_start_d (p, 50)) return ; 2620 sequence_96 (p); 2621 rde_param_i_symbol_done_d_reduce (p, 50, 49); 2622 return; 2623 } 2624 2625 static void sequence_96 (RDE_PARAM p) { 2626 /* 2627 * x 2628 * (OPENB) 2629 * * 2630 * x 2631 * ! 2632 * (CLOSEB) 2633 * (Range) 2634 * (CLOSEB) 2635 * (WHITESPACE) 2636 */ 2637 2638 rde_param_i_state_push_void (p); 2639 sym_OPENB (p); 2640 if (rde_param_i_seq_void2value(p)) return; 2641 kleene_92 (p); 2642 if (rde_param_i_seq_value2value(p)) return; 2643 sym_CLOSEB (p); 2644 if (rde_param_i_seq_value2value(p)) return; 2645 sym_WHITESPACE (p); 2646 rde_param_i_state_merge_value (p); 2647 return; 2648 } 2649 2650 static void kleene_92 (RDE_PARAM p) { 2651 /* 2652 * * 2653 * x 2654 * ! 2655 * (CLOSEB) 2656 * (Range) 2657 */ 2658 2659 while (1) { 2660 rde_param_i_state_push_2 (p); 2661 sequence_90 (p); 2662 if (rde_param_i_kleene_close(p)) return; 2663 } 2664 return; 2665 } 2666 2667 static void sequence_90 (RDE_PARAM p) { 2668 /* 2669 * x 2670 * ! 2671 * (CLOSEB) 2672 * (Range) 2673 */ 2674 2675 rde_param_i_state_push_void (p); 2676 notahead_87 (p); 2677 if (rde_param_i_seq_void2value(p)) return; 2678 sym_Range (p); 2679 rde_param_i_state_merge_value (p); 2680 return; 2681 } 2682 2683 static void notahead_87 (RDE_PARAM p) { 2684 /* 2685 * ! 2686 * (CLOSEB) 2687 */ 2688 2689 rde_param_i_loc_push (p); 2690 sym_CLOSEB (p); 2691 rde_param_i_notahead_exit (p); 2692 return; 2693 } 2694 2695 /* 2696 * void Symbol 'CLOSE' 2697 */ 2698 2699 static void sym_CLOSE (RDE_PARAM p) { 2700 /* 2701 * x 2702 * '\)' 2703 * (WHITESPACE) 2704 */ 2705 2706 if (rde_param_i_symbol_void_start (p, 53)) return ; 2707 sequence_101 (p); 2708 rde_param_i_symbol_done_void (p, 53, 52); 2709 return; 2710 } 2711 2712 static void sequence_101 (RDE_PARAM p) { 2713 /* 2714 * x 2715 * '\)' 2716 * (WHITESPACE) 2717 */ 2718 2719 rde_param_i_state_push_void (p); 2720 rde_param_i_next_char (p, ")", 51); 2721 if (rde_param_i_seq_void2void(p)) return; 2722 sym_WHITESPACE (p); 2723 rde_param_i_state_merge_void (p); 2724 return; 2725 } 2726 2727 /* 2728 * void Symbol 'CLOSEB' 2729 */ 2730 2731 static void sym_CLOSEB (RDE_PARAM p) { 2732 /* 2733 * ']' 2734 */ 2735 2736 if (rde_param_i_symbol_void_start (p, 56)) return ; 2737 rde_param_i_next_char (p, "]", 54); 2738 rde_param_i_symbol_done_void (p, 56, 55); 2739 return; 2740 } 2741 2742 /* 2743 * void Symbol 'COLON' 2744 */ 2745 2746 static void sym_COLON (RDE_PARAM p) { 2747 /* 2748 * x 2749 * ':' 2750 * (WHITESPACE) 2751 */ 2752 2753 if (rde_param_i_symbol_void_start (p, 59)) return ; 2754 sequence_108 (p); 2755 rde_param_i_symbol_done_void (p, 59, 58); 2756 return; 2757 } 2758 2759 static void sequence_108 (RDE_PARAM p) { 2760 /* 2761 * x 2762 * ':' 2763 * (WHITESPACE) 2764 */ 2765 2766 rde_param_i_state_push_void (p); 2767 rde_param_i_next_char (p, ":", 57); 2768 if (rde_param_i_seq_void2void(p)) return; 2769 sym_WHITESPACE (p); 2770 rde_param_i_state_merge_void (p); 2771 return; 2772 } 2773 2774 /* 2775 * void Symbol 'COMMENT' 2776 */ 2777 2778 static void sym_COMMENT (RDE_PARAM p) { 2779 /* 2780 * x 2781 * '#' 2782 * * 2783 * x 2784 * ! 2785 * (EOL) 2786 * <dot> 2787 * (EOL) 2788 */ 2789 2790 if (rde_param_i_symbol_void_start (p, 62)) return ; 2791 sequence_121 (p); 2792 rde_param_i_symbol_done_void (p, 62, 61); 2793 return; 2794 } 2795 2796 static void sequence_121 (RDE_PARAM p) { 2797 /* 2798 * x 2799 * '#' 2800 * * 2801 * x 2802 * ! 2803 * (EOL) 2804 * <dot> 2805 * (EOL) 2806 */ 2807 2808 rde_param_i_state_push_void (p); 2809 rde_param_i_next_char (p, "#", 60); 2810 if (rde_param_i_seq_void2void(p)) return; 2811 kleene_118 (p); 2812 if (rde_param_i_seq_void2void(p)) return; 2813 sym_EOL (p); 2814 rde_param_i_state_merge_void (p); 2815 return; 2816 } 2817 2818 static void kleene_118 (RDE_PARAM p) { 2819 /* 2820 * * 2821 * x 2822 * ! 2823 * (EOL) 2824 * <dot> 2825 */ 2826 2827 while (1) { 2828 rde_param_i_state_push_2 (p); 2829 sequence_116 (p); 2830 if (rde_param_i_kleene_close(p)) return; 2831 } 2832 return; 2833 } 2834 2835 static void sequence_116 (RDE_PARAM p) { 2836 /* 2837 * x 2838 * ! 2839 * (EOL) 2840 * <dot> 2841 */ 2842 2843 rde_param_i_state_push_void (p); 2844 notahead_113 (p); 2845 if (rde_param_i_seq_void2void(p)) return; 2846 rde_param_i_input_next (p, 43); 2847 rde_param_i_state_merge_void (p); 2848 return; 2849 } 2850 2851 static void notahead_113 (RDE_PARAM p) { 2852 /* 2853 * ! 2854 * (EOL) 2855 */ 2856 2857 rde_param_i_loc_push (p); 2858 sym_EOL (p); 2859 rde_param_i_notahead_exit (p); 2860 return; 2861 } 2862 2863 /* 2864 * leaf Symbol 'CONTROL' 2865 */ 2866 2867 static void sym_CONTROL (RDE_PARAM p) { 2868 /* 2869 * x 2870 * "<control>" 2871 * (WHITESPACE) 2872 */ 2873 2874 if (rde_param_i_symbol_start (p, 65)) return ; 2875 sequence_126 (p); 2876 rde_param_i_symbol_done_leaf (p, 65, 64); 2877 return; 2878 } 2879 2880 static void sequence_126 (RDE_PARAM p) { 2881 /* 2882 * x 2883 * "<control>" 2884 * (WHITESPACE) 2885 */ 2886 2887 rde_param_i_state_push_void (p); 2888 rde_param_i_next_str (p, "<control>", 63); 2889 if (rde_param_i_seq_void2void(p)) return; 2890 sym_WHITESPACE (p); 2891 rde_param_i_state_merge_void (p); 2892 return; 2893 } 2894 2895 /* 2896 * void Symbol 'DAPOSTROPH' 2897 */ 2898 2899 static void sym_DAPOSTROPH (RDE_PARAM p) { 2900 /* 2901 * '\"' 2902 */ 2903 2904 if (rde_param_i_symbol_void_start (p, 68)) return ; 2905 rde_param_i_next_char (p, "\"", 66); 2906 rde_param_i_symbol_done_void (p, 68, 67); 2907 return; 2908 } 2909 2910 /* 2911 * leaf Symbol 'DDIGIT' 2912 */ 2913 2914 static void sym_DDIGIT (RDE_PARAM p) { 2915 /* 2916 * x 2917 * "<ddigit>" 2918 * (WHITESPACE) 2919 */ 2920 2921 if (rde_param_i_symbol_start (p, 71)) return ; 2922 sequence_133 (p); 2923 rde_param_i_symbol_done_leaf (p, 71, 70); 2924 return; 2925 } 2926 2927 static void sequence_133 (RDE_PARAM p) { 2928 /* 2929 * x 2930 * "<ddigit>" 2931 * (WHITESPACE) 2932 */ 2933 2934 rde_param_i_state_push_void (p); 2935 rde_param_i_next_str (p, "<ddigit>", 69); 2936 if (rde_param_i_seq_void2void(p)) return; 2937 sym_WHITESPACE (p); 2938 rde_param_i_state_merge_void (p); 2939 return; 2940 } 2941 2942 /* 2943 * value Symbol 'Definition' 2944 */ 2945 2946 static void sym_Definition (RDE_PARAM p) { 2947 /* 2948 * x 2949 * ? 2950 * (Attribute) 2951 * (Identifier) 2952 * (IS) 2953 * (Expression) 2954 * (SEMICOLON) 2955 */ 2956 2957 if (rde_param_i_symbol_start_d (p, 73)) return ; 2958 sequence_143 (p); 2959 rde_param_i_symbol_done_d_reduce (p, 73, 72); 2960 return; 2961 } 2962 2963 static void sequence_143 (RDE_PARAM p) { 2964 /* 2965 * x 2966 * ? 2967 * (Attribute) 2968 * (Identifier) 2969 * (IS) 2970 * (Expression) 2971 * (SEMICOLON) 2972 */ 2973 2974 rde_param_i_state_push_value (p); 2975 optional_137 (p); 2976 if (rde_param_i_seq_value2value(p)) return; 2977 sym_Identifier (p); 2978 if (rde_param_i_seq_value2value(p)) return; 2979 sym_IS (p); 2980 if (rde_param_i_seq_value2value(p)) return; 2981 sym_Expression (p); 2982 if (rde_param_i_seq_value2value(p)) return; 2983 sym_SEMICOLON (p); 2984 rde_param_i_state_merge_value (p); 2985 return; 2986 } 2987 2988 static void optional_137 (RDE_PARAM p) { 2989 /* 2990 * ? 2991 * (Attribute) 2992 */ 2993 2994 rde_param_i_state_push_2 (p); 2995 sym_Attribute (p); 2996 rde_param_i_state_merge_ok (p); 2997 return; 2998 } 2999 3000 /* 3001 * leaf Symbol 'DIGIT' 3002 */ 3003 3004 static void sym_DIGIT (RDE_PARAM p) { 3005 /* 3006 * x 3007 * "<digit>" 3008 * (WHITESPACE) 3009 */ 3010 3011 if (rde_param_i_symbol_start (p, 76)) return ; 3012 sequence_148 (p); 3013 rde_param_i_symbol_done_leaf (p, 76, 75); 3014 return; 3015 } 3016 3017 static void sequence_148 (RDE_PARAM p) { 3018 /* 3019 * x 3020 * "<digit>" 3021 * (WHITESPACE) 3022 */ 3023 3024 rde_param_i_state_push_void (p); 3025 rde_param_i_next_str (p, "<digit>", 74); 3026 if (rde_param_i_seq_void2void(p)) return; 3027 sym_WHITESPACE (p); 3028 rde_param_i_state_merge_void (p); 3029 return; 3030 } 3031 3032 /* 3033 * leaf Symbol 'DOT' 3034 */ 3035 3036 static void sym_DOT (RDE_PARAM p) { 3037 /* 3038 * x 3039 * '.' 3040 * (WHITESPACE) 3041 */ 3042 3043 if (rde_param_i_symbol_start (p, 79)) return ; 3044 sequence_153 (p); 3045 rde_param_i_symbol_done_leaf (p, 79, 78); 3046 return; 3047 } 3048 3049 static void sequence_153 (RDE_PARAM p) { 3050 /* 3051 * x 3052 * '.' 3053 * (WHITESPACE) 3054 */ 3055 3056 rde_param_i_state_push_void (p); 3057 rde_param_i_next_char (p, ".", 77); 3058 if (rde_param_i_seq_void2void(p)) return; 3059 sym_WHITESPACE (p); 3060 rde_param_i_state_merge_void (p); 3061 return; 3062 } 3063 3064 /* 3065 * void Symbol 'EOF' 3066 */ 3067 3068 static void sym_EOF (RDE_PARAM p) { 3069 /* 3070 * ! 3071 * <dot> 3072 */ 3073 3074 if (rde_param_i_symbol_void_start (p, 81)) return ; 3075 notahead_157 (p); 3076 rde_param_i_symbol_done_void (p, 81, 80); 3077 return; 3078 } 3079 3080 static void notahead_157 (RDE_PARAM p) { 3081 /* 3082 * ! 3083 * <dot> 3084 */ 3085 3086 rde_param_i_loc_push (p); 3087 rde_param_i_input_next (p, 43); 3088 rde_param_i_notahead_exit (p); 3089 return; 3090 } 3091 3092 /* 3093 * void Symbol 'EOL' 3094 */ 3095 3096 static void sym_EOL (RDE_PARAM p) { 3097 /* 3098 * [\n\r] 3099 */ 3100 3101 if (rde_param_i_symbol_void_start (p, 84)) return ; 3102 rde_param_i_next_class (p, "\n\r", 82); 3103 rde_param_i_symbol_done_void (p, 84, 83); 3104 return; 3105 } 3106 3107 /* 3108 * value Symbol 'Expression' 3109 */ 3110 3111 static void sym_Expression (RDE_PARAM p) { 3112 /* 3113 * x 3114 * (Sequence) 3115 * * 3116 * x 3117 * (SLASH) 3118 * (Sequence) 3119 */ 3120 3121 if (rde_param_i_symbol_start_d (p, 86)) return ; 3122 sequence_169 (p); 3123 rde_param_i_symbol_done_d_reduce (p, 86, 85); 3124 return; 3125 } 3126 3127 static void sequence_169 (RDE_PARAM p) { 3128 /* 3129 * x 3130 * (Sequence) 3131 * * 3132 * x 3133 * (SLASH) 3134 * (Sequence) 3135 */ 3136 3137 rde_param_i_state_push_value (p); 3138 sym_Sequence (p); 3139 if (rde_param_i_seq_value2value(p)) return; 3140 kleene_167 (p); 3141 rde_param_i_state_merge_value (p); 3142 return; 3143 } 3144 3145 static void kleene_167 (RDE_PARAM p) { 3146 /* 3147 * * 3148 * x 3149 * (SLASH) 3150 * (Sequence) 3151 */ 3152 3153 while (1) { 3154 rde_param_i_state_push_2 (p); 3155 sequence_165 (p); 3156 if (rde_param_i_kleene_close(p)) return; 3157 } 3158 return; 3159 } 3160 3161 static void sequence_165 (RDE_PARAM p) { 3162 /* 3163 * x 3164 * (SLASH) 3165 * (Sequence) 3166 */ 3167 3168 rde_param_i_state_push_void (p); 3169 sym_SLASH (p); 3170 if (rde_param_i_seq_void2value(p)) return; 3171 sym_Sequence (p); 3172 rde_param_i_state_merge_value (p); 3173 return; 3174 } 3175 3176 /* 3177 * void Symbol 'Final' 3178 */ 3179 3180 static void sym_Final (RDE_PARAM p) { 3181 /* 3182 * x 3183 * "END" 3184 * (WHITESPACE) 3185 * (SEMICOLON) 3186 * (WHITESPACE) 3187 */ 3188 3189 if (rde_param_i_symbol_void_start (p, 89)) return ; 3190 sequence_176 (p); 3191 rde_param_i_symbol_done_void (p, 89, 88); 3192 return; 3193 } 3194 3195 static void sequence_176 (RDE_PARAM p) { 3196 /* 3197 * x 3198 * "END" 3199 * (WHITESPACE) 3200 * (SEMICOLON) 3201 * (WHITESPACE) 3202 */ 3203 3204 rde_param_i_state_push_void (p); 3205 rde_param_i_next_str (p, "END", 87); 3206 if (rde_param_i_seq_void2void(p)) return; 3207 sym_WHITESPACE (p); 3208 if (rde_param_i_seq_void2void(p)) return; 3209 sym_SEMICOLON (p); 3210 if (rde_param_i_seq_void2void(p)) return; 3211 sym_WHITESPACE (p); 3212 rde_param_i_state_merge_void (p); 3213 return; 3214 } 3215 3216 /* 3217 * value Symbol 'Grammar' 3218 */ 3219 3220 static void sym_Grammar (RDE_PARAM p) { 3221 /* 3222 * x 3223 * (WHITESPACE) 3224 * (Header) 3225 * * 3226 * (Definition) 3227 * (Final) 3228 * (EOF) 3229 */ 3230 3231 if (rde_param_i_symbol_start_d (p, 91)) return ; 3232 sequence_186 (p); 3233 rde_param_i_symbol_done_d_reduce (p, 91, 90); 3234 return; 3235 } 3236 3237 static void sequence_186 (RDE_PARAM p) { 3238 /* 3239 * x 3240 * (WHITESPACE) 3241 * (Header) 3242 * * 3243 * (Definition) 3244 * (Final) 3245 * (EOF) 3246 */ 3247 3248 rde_param_i_state_push_void (p); 3249 sym_WHITESPACE (p); 3250 if (rde_param_i_seq_void2value(p)) return; 3251 sym_Header (p); 3252 if (rde_param_i_seq_value2value(p)) return; 3253 kleene_182 (p); 3254 if (rde_param_i_seq_value2value(p)) return; 3255 sym_Final (p); 3256 if (rde_param_i_seq_value2value(p)) return; 3257 sym_EOF (p); 3258 rde_param_i_state_merge_value (p); 3259 return; 3260 } 3261 3262 static void kleene_182 (RDE_PARAM p) { 3263 /* 3264 * * 3265 * (Definition) 3266 */ 3267 3268 while (1) { 3269 rde_param_i_state_push_2 (p); 3270 sym_Definition (p); 3271 if (rde_param_i_kleene_close(p)) return; 3272 } 3273 return; 3274 } 3275 3276 /* 3277 * leaf Symbol 'GRAPH' 3278 */ 3279 3280 static void sym_GRAPH (RDE_PARAM p) { 3281 /* 3282 * x 3283 * "<graph>" 3284 * (WHITESPACE) 3285 */ 3286 3287 if (rde_param_i_symbol_start (p, 94)) return ; 3288 sequence_191 (p); 3289 rde_param_i_symbol_done_leaf (p, 94, 93); 3290 return; 3291 } 3292 3293 static void sequence_191 (RDE_PARAM p) { 3294 /* 3295 * x 3296 * "<graph>" 3297 * (WHITESPACE) 3298 */ 3299 3300 rde_param_i_state_push_void (p); 3301 rde_param_i_next_str (p, "<graph>", 92); 3302 if (rde_param_i_seq_void2void(p)) return; 3303 sym_WHITESPACE (p); 3304 rde_param_i_state_merge_void (p); 3305 return; 3306 } 3307 3308 /* 3309 * value Symbol 'Header' 3310 */ 3311 3312 static void sym_Header (RDE_PARAM p) { 3313 /* 3314 * x 3315 * (PEG) 3316 * (Identifier) 3317 * (StartExpr) 3318 */ 3319 3320 if (rde_param_i_symbol_start_d (p, 96)) return ; 3321 sequence_197 (p); 3322 rde_param_i_symbol_done_d_reduce (p, 96, 95); 3323 return; 3324 } 3325 3326 static void sequence_197 (RDE_PARAM p) { 3327 /* 3328 * x 3329 * (PEG) 3330 * (Identifier) 3331 * (StartExpr) 3332 */ 3333 3334 rde_param_i_state_push_void (p); 3335 sym_PEG (p); 3336 if (rde_param_i_seq_void2value(p)) return; 3337 sym_Identifier (p); 3338 if (rde_param_i_seq_value2value(p)) return; 3339 sym_StartExpr (p); 3340 rde_param_i_state_merge_value (p); 3341 return; 3342 } 3343 3344 /* 3345 * leaf Symbol 'Ident' 3346 */ 3347 3348 static void sym_Ident (RDE_PARAM p) { 3349 /* 3350 * x 3351 * / 3352 * [_:] 3353 * <alpha> 3354 * * 3355 * / 3356 * [_:] 3357 * <alnum> 3358 */ 3359 3360 if (rde_param_i_symbol_start (p, 99)) return ; 3361 sequence_210 (p); 3362 rde_param_i_symbol_done_leaf (p, 99, 98); 3363 return; 3364 } 3365 3366 static void sequence_210 (RDE_PARAM p) { 3367 /* 3368 * x 3369 * / 3370 * [_:] 3371 * <alpha> 3372 * * 3373 * / 3374 * [_:] 3375 * <alnum> 3376 */ 3377 3378 rde_param_i_state_push_void (p); 3379 choice_202 (p); 3380 if (rde_param_i_seq_void2void(p)) return; 3381 kleene_208 (p); 3382 rde_param_i_state_merge_void (p); 3383 return; 3384 } 3385 3386 static void choice_202 (RDE_PARAM p) { 3387 /* 3388 * / 3389 * [_:] 3390 * <alpha> 3391 */ 3392 3393 rde_param_i_state_push_void (p); 3394 rde_param_i_next_class (p, "_:", 97); 3395 if (rde_param_i_bra_void2void(p)) return; 3396 rde_param_i_next_alpha (p, 1); 3397 rde_param_i_state_merge_void (p); 3398 return; 3399 } 3400 3401 static void kleene_208 (RDE_PARAM p) { 3402 /* 3403 * * 3404 * / 3405 * [_:] 3406 * <alnum> 3407 */ 3408 3409 while (1) { 3410 rde_param_i_state_push_2 (p); 3411 choice_206 (p); 3412 if (rde_param_i_kleene_close(p)) return; 3413 } 3414 return; 3415 } 3416 3417 static void choice_206 (RDE_PARAM p) { 3418 /* 3419 * / 3420 * [_:] 3421 * <alnum> 3422 */ 3423 3424 rde_param_i_state_push_void (p); 3425 rde_param_i_next_class (p, "_:", 97); 3426 if (rde_param_i_bra_void2void(p)) return; 3427 rde_param_i_next_alnum (p, 0); 3428 rde_param_i_state_merge_void (p); 3429 return; 3430 } 3431 3432 /* 3433 * value Symbol 'Identifier' 3434 */ 3435 3436 static void sym_Identifier (RDE_PARAM p) { 3437 /* 3438 * x 3439 * (Ident) 3440 * (WHITESPACE) 3441 */ 3442 3443 if (rde_param_i_symbol_start_d (p, 101)) return ; 3444 sequence_215 (p); 3445 rde_param_i_symbol_done_d_reduce (p, 101, 100); 3446 return; 3447 } 3448 3449 static void sequence_215 (RDE_PARAM p) { 3450 /* 3451 * x 3452 * (Ident) 3453 * (WHITESPACE) 3454 */ 3455 3456 rde_param_i_state_push_value (p); 3457 sym_Ident (p); 3458 if (rde_param_i_seq_value2value(p)) return; 3459 sym_WHITESPACE (p); 3460 rde_param_i_state_merge_value (p); 3461 return; 3462 } 3463 3464 /* 3465 * void Symbol 'IS' 3466 */ 3467 3468 static void sym_IS (RDE_PARAM p) { 3469 /* 3470 * x 3471 * "<-" 3472 * (WHITESPACE) 3473 */ 3474 3475 if (rde_param_i_symbol_void_start (p, 104)) return ; 3476 sequence_220 (p); 3477 rde_param_i_symbol_done_void (p, 104, 103); 3478 return; 3479 } 3480 3481 static void sequence_220 (RDE_PARAM p) { 3482 /* 3483 * x 3484 * "<-" 3485 * (WHITESPACE) 3486 */ 3487 3488 rde_param_i_state_push_void (p); 3489 rde_param_i_next_str (p, "<-", 102); 3490 if (rde_param_i_seq_void2void(p)) return; 3491 sym_WHITESPACE (p); 3492 rde_param_i_state_merge_void (p); 3493 return; 3494 } 3495 3496 /* 3497 * leaf Symbol 'LEAF' 3498 */ 3499 3500 static void sym_LEAF (RDE_PARAM p) { 3501 /* 3502 * x 3503 * "leaf" 3504 * (WHITESPACE) 3505 */ 3506 3507 if (rde_param_i_symbol_start (p, 107)) return ; 3508 sequence_225 (p); 3509 rde_param_i_symbol_done_leaf (p, 107, 106); 3510 return; 3511 } 3512 3513 static void sequence_225 (RDE_PARAM p) { 3514 /* 3515 * x 3516 * "leaf" 3517 * (WHITESPACE) 3518 */ 3519 3520 rde_param_i_state_push_void (p); 3521 rde_param_i_next_str (p, "leaf", 105); 3522 if (rde_param_i_seq_void2void(p)) return; 3523 sym_WHITESPACE (p); 3524 rde_param_i_state_merge_void (p); 3525 return; 3526 } 3527 3528 /* 3529 * value Symbol 'Literal' 3530 */ 3531 3532 static void sym_Literal (RDE_PARAM p) { 3533 /* 3534 * / 3535 * x 3536 * (APOSTROPH) 3537 * * 3538 * x 3539 * ! 3540 * (APOSTROPH) 3541 * (Char) 3542 * (APOSTROPH) 3543 * (WHITESPACE) 3544 * x 3545 * (DAPOSTROPH) 3546 * * 3547 * x 3548 * ! 3549 * (DAPOSTROPH) 3550 * (Char) 3551 * (DAPOSTROPH) 3552 * (WHITESPACE) 3553 */ 3554 3555 if (rde_param_i_symbol_start_d (p, 109)) return ; 3556 choice_254 (p); 3557 rde_param_i_symbol_done_d_reduce (p, 109, 108); 3558 return; 3559 } 3560 3561 static void choice_254 (RDE_PARAM p) { 3562 /* 3563 * / 3564 * x 3565 * (APOSTROPH) 3566 * * 3567 * x 3568 * ! 3569 * (APOSTROPH) 3570 * (Char) 3571 * (APOSTROPH) 3572 * (WHITESPACE) 3573 * x 3574 * (DAPOSTROPH) 3575 * * 3576 * x 3577 * ! 3578 * (DAPOSTROPH) 3579 * (Char) 3580 * (DAPOSTROPH) 3581 * (WHITESPACE) 3582 */ 3583 3584 rde_param_i_state_push_value (p); 3585 sequence_239 (p); 3586 if (rde_param_i_bra_value2value(p)) return; 3587 sequence_252 (p); 3588 rde_param_i_state_merge_value (p); 3589 return; 3590 } 3591 3592 static void sequence_239 (RDE_PARAM p) { 3593 /* 3594 * x 3595 * (APOSTROPH) 3596 * * 3597 * x 3598 * ! 3599 * (APOSTROPH) 3600 * (Char) 3601 * (APOSTROPH) 3602 * (WHITESPACE) 3603 */ 3604 3605 rde_param_i_state_push_void (p); 3606 sym_APOSTROPH (p); 3607 if (rde_param_i_seq_void2value(p)) return; 3608 kleene_235 (p); 3609 if (rde_param_i_seq_value2value(p)) return; 3610 sym_APOSTROPH (p); 3611 if (rde_param_i_seq_value2value(p)) return; 3612 sym_WHITESPACE (p); 3613 rde_param_i_state_merge_value (p); 3614 return; 3615 } 3616 3617 static void kleene_235 (RDE_PARAM p) { 3618 /* 3619 * * 3620 * x 3621 * ! 3622 * (APOSTROPH) 3623 * (Char) 3624 */ 3625 3626 while (1) { 3627 rde_param_i_state_push_2 (p); 3628 sequence_233 (p); 3629 if (rde_param_i_kleene_close(p)) return; 3630 } 3631 return; 3632 } 3633 3634 static void sequence_233 (RDE_PARAM p) { 3635 /* 3636 * x 3637 * ! 3638 * (APOSTROPH) 3639 * (Char) 3640 */ 3641 3642 rde_param_i_state_push_void (p); 3643 notahead_230 (p); 3644 if (rde_param_i_seq_void2value(p)) return; 3645 sym_Char (p); 3646 rde_param_i_state_merge_value (p); 3647 return; 3648 } 3649 3650 static void notahead_230 (RDE_PARAM p) { 3651 /* 3652 * ! 3653 * (APOSTROPH) 3654 */ 3655 3656 rde_param_i_loc_push (p); 3657 sym_APOSTROPH (p); 3658 rde_param_i_notahead_exit (p); 3659 return; 3660 } 3661 3662 static void sequence_252 (RDE_PARAM p) { 3663 /* 3664 * x 3665 * (DAPOSTROPH) 3666 * * 3667 * x 3668 * ! 3669 * (DAPOSTROPH) 3670 * (Char) 3671 * (DAPOSTROPH) 3672 * (WHITESPACE) 3673 */ 3674 3675 rde_param_i_state_push_void (p); 3676 sym_DAPOSTROPH (p); 3677 if (rde_param_i_seq_void2value(p)) return; 3678 kleene_248 (p); 3679 if (rde_param_i_seq_value2value(p)) return; 3680 sym_DAPOSTROPH (p); 3681 if (rde_param_i_seq_value2value(p)) return; 3682 sym_WHITESPACE (p); 3683 rde_param_i_state_merge_value (p); 3684 return; 3685 } 3686 3687 static void kleene_248 (RDE_PARAM p) { 3688 /* 3689 * * 3690 * x 3691 * ! 3692 * (DAPOSTROPH) 3693 * (Char) 3694 */ 3695 3696 while (1) { 3697 rde_param_i_state_push_2 (p); 3698 sequence_246 (p); 3699 if (rde_param_i_kleene_close(p)) return; 3700 } 3701 return; 3702 } 3703 3704 static void sequence_246 (RDE_PARAM p) { 3705 /* 3706 * x 3707 * ! 3708 * (DAPOSTROPH) 3709 * (Char) 3710 */ 3711 3712 rde_param_i_state_push_void (p); 3713 notahead_243 (p); 3714 if (rde_param_i_seq_void2value(p)) return; 3715 sym_Char (p); 3716 rde_param_i_state_merge_value (p); 3717 return; 3718 } 3719 3720 static void notahead_243 (RDE_PARAM p) { 3721 /* 3722 * ! 3723 * (DAPOSTROPH) 3724 */ 3725 3726 rde_param_i_loc_push (p); 3727 sym_DAPOSTROPH (p); 3728 rde_param_i_notahead_exit (p); 3729 return; 3730 } 3731 3732 /* 3733 * leaf Symbol 'LOWER' 3734 */ 3735 3736 static void sym_LOWER (RDE_PARAM p) { 3737 /* 3738 * x 3739 * "<lower>" 3740 * (WHITESPACE) 3741 */ 3742 3743 if (rde_param_i_symbol_start (p, 112)) return ; 3744 sequence_259 (p); 3745 rde_param_i_symbol_done_leaf (p, 112, 111); 3746 return; 3747 } 3748 3749 static void sequence_259 (RDE_PARAM p) { 3750 /* 3751 * x 3752 * "<lower>" 3753 * (WHITESPACE) 3754 */ 3755 3756 rde_param_i_state_push_void (p); 3757 rde_param_i_next_str (p, "<lower>", 110); 3758 if (rde_param_i_seq_void2void(p)) return; 3759 sym_WHITESPACE (p); 3760 rde_param_i_state_merge_void (p); 3761 return; 3762 } 3763 3764 /* 3765 * leaf Symbol 'NOT' 3766 */ 3767 3768 static void sym_NOT (RDE_PARAM p) { 3769 /* 3770 * x 3771 * '!' 3772 * (WHITESPACE) 3773 */ 3774 3775 if (rde_param_i_symbol_start (p, 115)) return ; 3776 sequence_264 (p); 3777 rde_param_i_symbol_done_leaf (p, 115, 114); 3778 return; 3779 } 3780 3781 static void sequence_264 (RDE_PARAM p) { 3782 /* 3783 * x 3784 * '!' 3785 * (WHITESPACE) 3786 */ 3787 3788 rde_param_i_state_push_void (p); 3789 rde_param_i_next_char (p, "!", 113); 3790 if (rde_param_i_seq_void2void(p)) return; 3791 sym_WHITESPACE (p); 3792 rde_param_i_state_merge_void (p); 3793 return; 3794 } 3795 3796 /* 3797 * void Symbol 'OPEN' 3798 */ 3799 3800 static void sym_OPEN (RDE_PARAM p) { 3801 /* 3802 * x 3803 * '\(' 3804 * (WHITESPACE) 3805 */ 3806 3807 if (rde_param_i_symbol_void_start (p, 118)) return ; 3808 sequence_269 (p); 3809 rde_param_i_symbol_done_void (p, 118, 117); 3810 return; 3811 } 3812 3813 static void sequence_269 (RDE_PARAM p) { 3814 /* 3815 * x 3816 * '\(' 3817 * (WHITESPACE) 3818 */ 3819 3820 rde_param_i_state_push_void (p); 3821 rde_param_i_next_char (p, "(", 116); 3822 if (rde_param_i_seq_void2void(p)) return; 3823 sym_WHITESPACE (p); 3824 rde_param_i_state_merge_void (p); 3825 return; 3826 } 3827 3828 /* 3829 * void Symbol 'OPENB' 3830 */ 3831 3832 static void sym_OPENB (RDE_PARAM p) { 3833 /* 3834 * '[' 3835 */ 3836 3837 if (rde_param_i_symbol_void_start (p, 121)) return ; 3838 rde_param_i_next_char (p, "[", 119); 3839 rde_param_i_symbol_done_void (p, 121, 120); 3840 return; 3841 } 3842 3843 /* 3844 * void Symbol 'PEG' 3845 */ 3846 3847 static void sym_PEG (RDE_PARAM p) { 3848 /* 3849 * x 3850 * "PEG" 3851 * ! 3852 * / 3853 * [_:] 3854 * <alnum> 3855 * (WHITESPACE) 3856 */ 3857 3858 if (rde_param_i_symbol_void_start (p, 124)) return ; 3859 sequence_281 (p); 3860 rde_param_i_symbol_done_void (p, 124, 123); 3861 return; 3862 } 3863 3864 static void sequence_281 (RDE_PARAM p) { 3865 /* 3866 * x 3867 * "PEG" 3868 * ! 3869 * / 3870 * [_:] 3871 * <alnum> 3872 * (WHITESPACE) 3873 */ 3874 3875 rde_param_i_state_push_void (p); 3876 rde_param_i_next_str (p, "PEG", 122); 3877 if (rde_param_i_seq_void2void(p)) return; 3878 notahead_278 (p); 3879 if (rde_param_i_seq_void2void(p)) return; 3880 sym_WHITESPACE (p); 3881 rde_param_i_state_merge_void (p); 3882 return; 3883 } 3884 3885 static void notahead_278 (RDE_PARAM p) { 3886 /* 3887 * ! 3888 * / 3889 * [_:] 3890 * <alnum> 3891 */ 3892 3893 rde_param_i_loc_push (p); 3894 choice_206 (p); 3895 rde_param_i_notahead_exit (p); 3896 return; 3897 } 3898 3899 /* 3900 * leaf Symbol 'PLUS' 3901 */ 3902 3903 static void sym_PLUS (RDE_PARAM p) { 3904 /* 3905 * x 3906 * '+' 3907 * (WHITESPACE) 3908 */ 3909 3910 if (rde_param_i_symbol_start (p, 127)) return ; 3911 sequence_286 (p); 3912 rde_param_i_symbol_done_leaf (p, 127, 126); 3913 return; 3914 } 3915 3916 static void sequence_286 (RDE_PARAM p) { 3917 /* 3918 * x 3919 * '+' 3920 * (WHITESPACE) 3921 */ 3922 3923 rde_param_i_state_push_void (p); 3924 rde_param_i_next_char (p, "+", 125); 3925 if (rde_param_i_seq_void2void(p)) return; 3926 sym_WHITESPACE (p); 3927 rde_param_i_state_merge_void (p); 3928 return; 3929 } 3930 3931 /* 3932 * value Symbol 'Prefix' 3933 */ 3934 3935 static void sym_Prefix (RDE_PARAM p) { 3936 /* 3937 * x 3938 * ? 3939 * / 3940 * (AND) 3941 * (NOT) 3942 * (Suffix) 3943 */ 3944 3945 if (rde_param_i_symbol_start_d (p, 129)) return ; 3946 sequence_296 (p); 3947 rde_param_i_symbol_done_d_reduce (p, 129, 128); 3948 return; 3949 } 3950 3951 static void sequence_296 (RDE_PARAM p) { 3952 /* 3953 * x 3954 * ? 3955 * / 3956 * (AND) 3957 * (NOT) 3958 * (Suffix) 3959 */ 3960 3961 rde_param_i_state_push_value (p); 3962 optional_293 (p); 3963 if (rde_param_i_seq_value2value(p)) return; 3964 sym_Suffix (p); 3965 rde_param_i_state_merge_value (p); 3966 return; 3967 } 3968 3969 static void optional_293 (RDE_PARAM p) { 3970 /* 3971 * ? 3972 * / 3973 * (AND) 3974 * (NOT) 3975 */ 3976 3977 rde_param_i_state_push_2 (p); 3978 choice_291 (p); 3979 rde_param_i_state_merge_ok (p); 3980 return; 3981 } 3982 3983 static void choice_291 (RDE_PARAM p) { 3984 /* 3985 * / 3986 * (AND) 3987 * (NOT) 3988 */ 3989 3990 rde_param_i_state_push_value (p); 3991 sym_AND (p); 3992 if (rde_param_i_bra_value2value(p)) return; 3993 sym_NOT (p); 3994 rde_param_i_state_merge_value (p); 3995 return; 3996 } 3997 3998 /* 3999 * value Symbol 'Primary' 4000 */ 4001 4002 static void sym_Primary (RDE_PARAM p) { 4003 /* 4004 * / 4005 * (ALNUM) 4006 * (ALPHA) 4007 * (ASCII) 4008 * (CONTROL) 4009 * (DDIGIT) 4010 * (DIGIT) 4011 * (GRAPH) 4012 * (LOWER) 4013 * (PRINTABLE) 4014 * (PUNCT) 4015 * (SPACE) 4016 * (UPPER) 4017 * (WORDCHAR) 4018 * (XDIGIT) 4019 * (Identifier) 4020 * x 4021 * (OPEN) 4022 * (Expression) 4023 * (CLOSE) 4024 * (Literal) 4025 * (Class) 4026 * (DOT) 4027 */ 4028 4029 if (rde_param_i_symbol_start_d (p, 131)) return ; 4030 choice_322 (p); 4031 rde_param_i_symbol_done_d_reduce (p, 131, 130); 4032 return; 4033 } 4034 4035 static void choice_322 (RDE_PARAM p) { 4036 /* 4037 * / 4038 * (ALNUM) 4039 * (ALPHA) 4040 * (ASCII) 4041 * (CONTROL) 4042 * (DDIGIT) 4043 * (DIGIT) 4044 * (GRAPH) 4045 * (LOWER) 4046 * (PRINTABLE) 4047 * (PUNCT) 4048 * (SPACE) 4049 * (UPPER) 4050 * (WORDCHAR) 4051 * (XDIGIT) 4052 * (Identifier) 4053 * x 4054 * (OPEN) 4055 * (Expression) 4056 * (CLOSE) 4057 * (Literal) 4058 * (Class) 4059 * (DOT) 4060 */ 4061 4062 rde_param_i_state_push_value (p); 4063 sym_ALNUM (p); 4064 if (rde_param_i_bra_value2value(p)) return; 4065 sym_ALPHA (p); 4066 if (rde_param_i_bra_value2value(p)) return; 4067 sym_ASCII (p); 4068 if (rde_param_i_bra_value2value(p)) return; 4069 sym_CONTROL (p); 4070 if (rde_param_i_bra_value2value(p)) return; 4071 sym_DDIGIT (p); 4072 if (rde_param_i_bra_value2value(p)) return; 4073 sym_DIGIT (p); 4074 if (rde_param_i_bra_value2value(p)) return; 4075 sym_GRAPH (p); 4076 if (rde_param_i_bra_value2value(p)) return; 4077 sym_LOWER (p); 4078 if (rde_param_i_bra_value2value(p)) return; 4079 sym_PRINTABLE (p); 4080 if (rde_param_i_bra_value2value(p)) return; 4081 sym_PUNCT (p); 4082 if (rde_param_i_bra_value2value(p)) return; 4083 sym_SPACE (p); 4084 if (rde_param_i_bra_value2value(p)) return; 4085 sym_UPPER (p); 4086 if (rde_param_i_bra_value2value(p)) return; 4087 sym_WORDCHAR (p); 4088 if (rde_param_i_bra_value2value(p)) return; 4089 sym_XDIGIT (p); 4090 if (rde_param_i_bra_value2value(p)) return; 4091 sym_Identifier (p); 4092 if (rde_param_i_bra_value2value(p)) return; 4093 sequence_317 (p); 4094 if (rde_param_i_bra_value2value(p)) return; 4095 sym_Literal (p); 4096 if (rde_param_i_bra_value2value(p)) return; 4097 sym_Class (p); 4098 if (rde_param_i_bra_value2value(p)) return; 4099 sym_DOT (p); 4100 rde_param_i_state_merge_value (p); 4101 return; 4102 } 4103 4104 static void sequence_317 (RDE_PARAM p) { 4105 /* 4106 * x 4107 * (OPEN) 4108 * (Expression) 4109 * (CLOSE) 4110 */ 4111 4112 rde_param_i_state_push_void (p); 4113 sym_OPEN (p); 4114 if (rde_param_i_seq_void2value(p)) return; 4115 sym_Expression (p); 4116 if (rde_param_i_seq_value2value(p)) return; 4117 sym_CLOSE (p); 4118 rde_param_i_state_merge_value (p); 4119 return; 4120 } 4121 4122 /* 4123 * leaf Symbol 'PRINTABLE' 4124 */ 4125 4126 static void sym_PRINTABLE (RDE_PARAM p) { 4127 /* 4128 * x 4129 * "<print>" 4130 * (WHITESPACE) 4131 */ 4132 4133 if (rde_param_i_symbol_start (p, 134)) return ; 4134 sequence_327 (p); 4135 rde_param_i_symbol_done_leaf (p, 134, 133); 4136 return; 4137 } 4138 4139 static void sequence_327 (RDE_PARAM p) { 4140 /* 4141 * x 4142 * "<print>" 4143 * (WHITESPACE) 4144 */ 4145 4146 rde_param_i_state_push_void (p); 4147 rde_param_i_next_str (p, "<print>", 132); 4148 if (rde_param_i_seq_void2void(p)) return; 4149 sym_WHITESPACE (p); 4150 rde_param_i_state_merge_void (p); 4151 return; 4152 } 4153 4154 /* 4155 * leaf Symbol 'PUNCT' 4156 */ 4157 4158 static void sym_PUNCT (RDE_PARAM p) { 4159 /* 4160 * x 4161 * "<punct>" 4162 * (WHITESPACE) 4163 */ 4164 4165 if (rde_param_i_symbol_start (p, 137)) return ; 4166 sequence_332 (p); 4167 rde_param_i_symbol_done_leaf (p, 137, 136); 4168 return; 4169 } 4170 4171 static void sequence_332 (RDE_PARAM p) { 4172 /* 4173 * x 4174 * "<punct>" 4175 * (WHITESPACE) 4176 */ 4177 4178 rde_param_i_state_push_void (p); 4179 rde_param_i_next_str (p, "<punct>", 135); 4180 if (rde_param_i_seq_void2void(p)) return; 4181 sym_WHITESPACE (p); 4182 rde_param_i_state_merge_void (p); 4183 return; 4184 } 4185 4186 /* 4187 * leaf Symbol 'QUESTION' 4188 */ 4189 4190 static void sym_QUESTION (RDE_PARAM p) { 4191 /* 4192 * x 4193 * '?' 4194 * (WHITESPACE) 4195 */ 4196 4197 if (rde_param_i_symbol_start (p, 140)) return ; 4198 sequence_337 (p); 4199 rde_param_i_symbol_done_leaf (p, 140, 139); 4200 return; 4201 } 4202 4203 static void sequence_337 (RDE_PARAM p) { 4204 /* 4205 * x 4206 * '?' 4207 * (WHITESPACE) 4208 */ 4209 4210 rde_param_i_state_push_void (p); 4211 rde_param_i_next_char (p, "?", 138); 4212 if (rde_param_i_seq_void2void(p)) return; 4213 sym_WHITESPACE (p); 4214 rde_param_i_state_merge_void (p); 4215 return; 4216 } 4217 4218 /* 4219 * value Symbol 'Range' 4220 */ 4221 4222 static void sym_Range (RDE_PARAM p) { 4223 /* 4224 * / 4225 * x 4226 * (Char) 4227 * (TO) 4228 * (Char) 4229 * (Char) 4230 */ 4231 4232 if (rde_param_i_symbol_start_d (p, 142)) return ; 4233 choice_346 (p); 4234 rde_param_i_symbol_done_d_reduce (p, 142, 141); 4235 return; 4236 } 4237 4238 static void choice_346 (RDE_PARAM p) { 4239 /* 4240 * / 4241 * x 4242 * (Char) 4243 * (TO) 4244 * (Char) 4245 * (Char) 4246 */ 4247 4248 rde_param_i_state_push_value (p); 4249 sequence_343 (p); 4250 if (rde_param_i_bra_value2value(p)) return; 4251 sym_Char (p); 4252 rde_param_i_state_merge_value (p); 4253 return; 4254 } 4255 4256 static void sequence_343 (RDE_PARAM p) { 4257 /* 4258 * x 4259 * (Char) 4260 * (TO) 4261 * (Char) 4262 */ 4263 4264 rde_param_i_state_push_value (p); 4265 sym_Char (p); 4266 if (rde_param_i_seq_value2value(p)) return; 4267 sym_TO (p); 4268 if (rde_param_i_seq_value2value(p)) return; 4269 sym_Char (p); 4270 rde_param_i_state_merge_value (p); 4271 return; 4272 } 4273 4274 /* 4275 * void Symbol 'SEMICOLON' 4276 */ 4277 4278 static void sym_SEMICOLON (RDE_PARAM p) { 4279 /* 4280 * x 4281 * ';' 4282 * (WHITESPACE) 4283 */ 4284 4285 if (rde_param_i_symbol_void_start (p, 145)) return ; 4286 sequence_351 (p); 4287 rde_param_i_symbol_done_void (p, 145, 144); 4288 return; 4289 } 4290 4291 static void sequence_351 (RDE_PARAM p) { 4292 /* 4293 * x 4294 * ';' 4295 * (WHITESPACE) 4296 */ 4297 4298 rde_param_i_state_push_void (p); 4299 rde_param_i_next_char (p, ";", 143); 4300 if (rde_param_i_seq_void2void(p)) return; 4301 sym_WHITESPACE (p); 4302 rde_param_i_state_merge_void (p); 4303 return; 4304 } 4305 4306 /* 4307 * value Symbol 'Sequence' 4308 */ 4309 4310 static void sym_Sequence (RDE_PARAM p) { 4311 /* 4312 * + 4313 * (Prefix) 4314 */ 4315 4316 if (rde_param_i_symbol_start_d (p, 147)) return ; 4317 poskleene_355 (p); 4318 rde_param_i_symbol_done_d_reduce (p, 147, 146); 4319 return; 4320 } 4321 4322 static void poskleene_355 (RDE_PARAM p) { 4323 /* 4324 * + 4325 * (Prefix) 4326 */ 4327 4328 rde_param_i_loc_push (p); 4329 sym_Prefix (p); 4330 if (rde_param_i_kleene_abort(p)) return; 4331 while (1) { 4332 rde_param_i_state_push_2 (p); 4333 sym_Prefix (p); 4334 if (rde_param_i_kleene_close(p)) return; 4335 } 4336 return; 4337 } 4338 4339 /* 4340 * void Symbol 'SLASH' 4341 */ 4342 4343 static void sym_SLASH (RDE_PARAM p) { 4344 /* 4345 * x 4346 * '/' 4347 * (WHITESPACE) 4348 */ 4349 4350 if (rde_param_i_symbol_void_start (p, 150)) return ; 4351 sequence_360 (p); 4352 rde_param_i_symbol_done_void (p, 150, 149); 4353 return; 4354 } 4355 4356 static void sequence_360 (RDE_PARAM p) { 4357 /* 4358 * x 4359 * '/' 4360 * (WHITESPACE) 4361 */ 4362 4363 rde_param_i_state_push_void (p); 4364 rde_param_i_next_char (p, "/", 148); 4365 if (rde_param_i_seq_void2void(p)) return; 4366 sym_WHITESPACE (p); 4367 rde_param_i_state_merge_void (p); 4368 return; 4369 } 4370 4371 /* 4372 * leaf Symbol 'SPACE' 4373 */ 4374 4375 static void sym_SPACE (RDE_PARAM p) { 4376 /* 4377 * x 4378 * "<space>" 4379 * (WHITESPACE) 4380 */ 4381 4382 if (rde_param_i_symbol_start (p, 153)) return ; 4383 sequence_365 (p); 4384 rde_param_i_symbol_done_leaf (p, 153, 152); 4385 return; 4386 } 4387 4388 static void sequence_365 (RDE_PARAM p) { 4389 /* 4390 * x 4391 * "<space>" 4392 * (WHITESPACE) 4393 */ 4394 4395 rde_param_i_state_push_void (p); 4396 rde_param_i_next_str (p, "<space>", 151); 4397 if (rde_param_i_seq_void2void(p)) return; 4398 sym_WHITESPACE (p); 4399 rde_param_i_state_merge_void (p); 4400 return; 4401 } 4402 4403 /* 4404 * leaf Symbol 'STAR' 4405 */ 4406 4407 static void sym_STAR (RDE_PARAM p) { 4408 /* 4409 * x 4410 * '*' 4411 * (WHITESPACE) 4412 */ 4413 4414 if (rde_param_i_symbol_start (p, 156)) return ; 4415 sequence_370 (p); 4416 rde_param_i_symbol_done_leaf (p, 156, 155); 4417 return; 4418 } 4419 4420 static void sequence_370 (RDE_PARAM p) { 4421 /* 4422 * x 4423 * '*' 4424 * (WHITESPACE) 4425 */ 4426 4427 rde_param_i_state_push_void (p); 4428 rde_param_i_next_char (p, "*", 154); 4429 if (rde_param_i_seq_void2void(p)) return; 4430 sym_WHITESPACE (p); 4431 rde_param_i_state_merge_void (p); 4432 return; 4433 } 4434 4435 /* 4436 * value Symbol 'StartExpr' 4437 */ 4438 4439 static void sym_StartExpr (RDE_PARAM p) { 4440 /* 4441 * x 4442 * (OPEN) 4443 * (Expression) 4444 * (CLOSE) 4445 */ 4446 4447 if (rde_param_i_symbol_start_d (p, 158)) return ; 4448 sequence_317 (p); 4449 rde_param_i_symbol_done_d_reduce (p, 158, 157); 4450 return; 4451 } 4452 4453 /* 4454 * value Symbol 'Suffix' 4455 */ 4456 4457 static void sym_Suffix (RDE_PARAM p) { 4458 /* 4459 * x 4460 * (Primary) 4461 * ? 4462 * / 4463 * (QUESTION) 4464 * (STAR) 4465 * (PLUS) 4466 */ 4467 4468 if (rde_param_i_symbol_start_d (p, 160)) return ; 4469 sequence_386 (p); 4470 rde_param_i_symbol_done_d_reduce (p, 160, 159); 4471 return; 4472 } 4473 4474 static void sequence_386 (RDE_PARAM p) { 4475 /* 4476 * x 4477 * (Primary) 4478 * ? 4479 * / 4480 * (QUESTION) 4481 * (STAR) 4482 * (PLUS) 4483 */ 4484 4485 rde_param_i_state_push_value (p); 4486 sym_Primary (p); 4487 if (rde_param_i_seq_value2value(p)) return; 4488 optional_384 (p); 4489 rde_param_i_state_merge_value (p); 4490 return; 4491 } 4492 4493 static void optional_384 (RDE_PARAM p) { 4494 /* 4495 * ? 4496 * / 4497 * (QUESTION) 4498 * (STAR) 4499 * (PLUS) 4500 */ 4501 4502 rde_param_i_state_push_2 (p); 4503 choice_382 (p); 4504 rde_param_i_state_merge_ok (p); 4505 return; 4506 } 4507 4508 static void choice_382 (RDE_PARAM p) { 4509 /* 4510 * / 4511 * (QUESTION) 4512 * (STAR) 4513 * (PLUS) 4514 */ 4515 4516 rde_param_i_state_push_value (p); 4517 sym_QUESTION (p); 4518 if (rde_param_i_bra_value2value(p)) return; 4519 sym_STAR (p); 4520 if (rde_param_i_bra_value2value(p)) return; 4521 sym_PLUS (p); 4522 rde_param_i_state_merge_value (p); 4523 return; 4524 } 4525 4526 /* 4527 * void Symbol 'TO' 4528 */ 4529 4530 static void sym_TO (RDE_PARAM p) { 4531 /* 4532 * '-' 4533 */ 4534 4535 if (rde_param_i_symbol_void_start (p, 163)) return ; 4536 rde_param_i_next_char (p, "-", 161); 4537 rde_param_i_symbol_done_void (p, 163, 162); 4538 return; 4539 } 4540 4541 /* 4542 * leaf Symbol 'UPPER' 4543 */ 4544 4545 static void sym_UPPER (RDE_PARAM p) { 4546 /* 4547 * x 4548 * "<upper>" 4549 * (WHITESPACE) 4550 */ 4551 4552 if (rde_param_i_symbol_start (p, 166)) return ; 4553 sequence_393 (p); 4554 rde_param_i_symbol_done_leaf (p, 166, 165); 4555 return; 4556 } 4557 4558 static void sequence_393 (RDE_PARAM p) { 4559 /* 4560 * x 4561 * "<upper>" 4562 * (WHITESPACE) 4563 */ 4564 4565 rde_param_i_state_push_void (p); 4566 rde_param_i_next_str (p, "<upper>", 164); 4567 if (rde_param_i_seq_void2void(p)) return; 4568 sym_WHITESPACE (p); 4569 rde_param_i_state_merge_void (p); 4570 return; 4571 } 4572 4573 /* 4574 * leaf Symbol 'VOID' 4575 */ 4576 4577 static void sym_VOID (RDE_PARAM p) { 4578 /* 4579 * x 4580 * "void" 4581 * (WHITESPACE) 4582 */ 4583 4584 if (rde_param_i_symbol_start (p, 169)) return ; 4585 sequence_398 (p); 4586 rde_param_i_symbol_done_leaf (p, 169, 168); 4587 return; 4588 } 4589 4590 static void sequence_398 (RDE_PARAM p) { 4591 /* 4592 * x 4593 * "void" 4594 * (WHITESPACE) 4595 */ 4596 4597 rde_param_i_state_push_void (p); 4598 rde_param_i_next_str (p, "void", 167); 4599 if (rde_param_i_seq_void2void(p)) return; 4600 sym_WHITESPACE (p); 4601 rde_param_i_state_merge_void (p); 4602 return; 4603 } 4604 4605 /* 4606 * void Symbol 'WHITESPACE' 4607 */ 4608 4609 static void sym_WHITESPACE (RDE_PARAM p) { 4610 /* 4611 * * 4612 * / 4613 * <space> 4614 * (COMMENT) 4615 */ 4616 4617 if (rde_param_i_symbol_void_start (p, 171)) return ; 4618 kleene_405 (p); 4619 rde_param_i_symbol_done_void (p, 171, 170); 4620 return; 4621 } 4622 4623 static void kleene_405 (RDE_PARAM p) { 4624 /* 4625 * * 4626 * / 4627 * <space> 4628 * (COMMENT) 4629 */ 4630 4631 while (1) { 4632 rde_param_i_state_push_2 (p); 4633 choice_403 (p); 4634 if (rde_param_i_kleene_close(p)) return; 4635 } 4636 return; 4637 } 4638 4639 static void choice_403 (RDE_PARAM p) { 4640 /* 4641 * / 4642 * <space> 4643 * (COMMENT) 4644 */ 4645 4646 rde_param_i_state_push_void (p); 4647 rde_param_i_next_space (p, 10); 4648 if (rde_param_i_bra_void2void(p)) return; 4649 sym_COMMENT (p); 4650 rde_param_i_state_merge_void (p); 4651 return; 4652 } 4653 4654 /* 4655 * leaf Symbol 'WORDCHAR' 4656 */ 4657 4658 static void sym_WORDCHAR (RDE_PARAM p) { 4659 /* 4660 * x 4661 * "<wordchar>" 4662 * (WHITESPACE) 4663 */ 4664 4665 if (rde_param_i_symbol_start (p, 174)) return ; 4666 sequence_410 (p); 4667 rde_param_i_symbol_done_leaf (p, 174, 173); 4668 return; 4669 } 4670 4671 static void sequence_410 (RDE_PARAM p) { 4672 /* 4673 * x 4674 * "<wordchar>" 4675 * (WHITESPACE) 4676 */ 4677 4678 rde_param_i_state_push_void (p); 4679 rde_param_i_next_str (p, "<wordchar>", 172); 4680 if (rde_param_i_seq_void2void(p)) return; 4681 sym_WHITESPACE (p); 4682 rde_param_i_state_merge_void (p); 4683 return; 4684 } 4685 4686 /* 4687 * leaf Symbol 'XDIGIT' 4688 */ 4689 4690 static void sym_XDIGIT (RDE_PARAM p) { 4691 /* 4692 * x 4693 * "<xdigit>" 4694 * (WHITESPACE) 4695 */ 4696 4697 if (rde_param_i_symbol_start (p, 177)) return ; 4698 sequence_415 (p); 4699 rde_param_i_symbol_done_leaf (p, 177, 176); 4700 return; 4701 } 4702 4703 static void sequence_415 (RDE_PARAM p) { 4704 /* 4705 * x 4706 * "<xdigit>" 4707 * (WHITESPACE) 4708 */ 4709 4710 rde_param_i_state_push_void (p); 4711 rde_param_i_next_str (p, "<xdigit>", 175); 4712 if (rde_param_i_seq_void2void(p)) return; 4713 sym_WHITESPACE (p); 4714 rde_param_i_state_merge_void (p); 4715 return; 4716 } 4717 4718 } 4719 4720 ## END of GENERATED CODE. DO NOT EDIT. 4721 # # ## ### ###### ######## ############# 4722 4723 # # ## ### ###### ######## ############# 4724 ## Global PARSER management, per interp 4725 4726 critcl::ccode { 4727 /* -*- c -*- */ 4728 4729 typedef struct PARSERg { 4730 long int counter; 4731 char buf [50]; 4732 } PARSERg; 4733 4734 static void 4735 PARSERgRelease (ClientData cd, Tcl_Interp* interp) 4736 { 4737 ckfree((char*) cd); 4738 } 4739 4740 static const char* 4741 PARSERnewName (Tcl_Interp* interp) 4742 { 4743#define KEY "tcllib/parser/pt_parse_peg_c/critcl" 4744 4745 Tcl_InterpDeleteProc* proc = PARSERgRelease; 4746 PARSERg* parserg; 4747 4748 parserg = Tcl_GetAssocData (interp, KEY, &proc); 4749 if (parserg == NULL) { 4750 parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); 4751 parserg->counter = 0; 4752 4753 Tcl_SetAssocData (interp, KEY, proc, 4754 (ClientData) parserg); 4755 } 4756 4757 parserg->counter ++; 4758 sprintf (parserg->buf, "peg%ld", parserg->counter); 4759 return parserg->buf; 4760#undef KEY 4761 } 4762 4763 static void 4764 PARSERdeleteCmd (ClientData clientData) 4765 { 4766 /* 4767 * Release the whole PARSER 4768 * (Low-level engine only actually). 4769 */ 4770 rde_param_del ((RDE_PARAM) clientData); 4771 } 4772 } 4773 4774 # # ## ### ##### ######## ############# 4775 ## Functions implementing the object methods, and helper. 4776 4777 critcl::ccode { 4778 static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); 4779 4780 static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) 4781 { 4782 int mode; 4783 Tcl_Channel chan; 4784 4785 if (objc != 3) { 4786 Tcl_WrongNumArgs (interp, 2, objv, "chan"); 4787 return TCL_ERROR; 4788 } 4789 4790 chan = Tcl_GetChannel(interp, 4791 Tcl_GetString (objv[2]), 4792 &mode); 4793 4794 if (!chan) { 4795 return TCL_ERROR; 4796 } 4797 4798 rde_param_reset (p, chan); 4799 MAIN (p) ; /* Entrypoint for the generated code. */ 4800 return COMPLETE (p, interp); 4801 } 4802 4803 static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) 4804 { 4805 char* buf; 4806 int len; 4807 4808 if (objc != 3) { 4809 Tcl_WrongNumArgs (interp, 2, objv, "text"); 4810 return TCL_ERROR; 4811 } 4812 4813 buf = Tcl_GetStringFromObj (objv[2], &len); 4814 4815 rde_param_reset (p, NULL); 4816 rde_param_data (p, buf, len); 4817 MAIN (p) ; /* Entrypoint for the generated code. */ 4818 return COMPLETE (p, interp); 4819 } 4820 4821 /* See also rde_critcl/m.c, param_COMPLETE() */ 4822 static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) 4823 { 4824 if (rde_param_query_st (p)) { 4825 long int ac; 4826 Tcl_Obj** av; 4827 4828 rde_param_query_ast (p, &ac, &av); 4829 4830 if (ac > 1) { 4831 Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); 4832 4833 memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); 4834 lv [0] = Tcl_NewObj (); 4835 lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); 4836 lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); 4837 4838 Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); 4839 ckfree ((char*) lv); 4840 4841 } else if (ac == 0) { 4842 /* 4843 * Match, but no AST. This is possible if the grammar 4844 * consists of only the start expression. 4845 */ 4846 Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); 4847 } else { 4848 Tcl_SetObjResult (interp, av [0]); 4849 } 4850 4851 return TCL_OK; 4852 } else { 4853 Tcl_Obj* xv [1]; 4854 const ERROR_STATE* er = rde_param_query_er (p); 4855 Tcl_Obj* res = rde_param_query_er_tcl (p, er); 4856 /* res = list (location, list(msg)) */ 4857 4858 /* Stick the exception type-tag before the existing elements */ 4859 xv [0] = Tcl_NewStringObj ("pt::rde",-1); 4860 Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); 4861 4862 Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); 4863 Tcl_SetObjResult (interp, res); 4864 return TCL_ERROR; 4865 } 4866 } 4867 } 4868 4869 # # ## ### ##### ######## ############# 4870 ## Object command, method dispatch. 4871 4872 critcl::ccode { 4873 static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) 4874 { 4875 RDE_PARAM p = (RDE_PARAM) cd; 4876 int m, res; 4877 4878 static CONST char* methods [] = { 4879 "destroy", "parse", "parset", NULL 4880 }; 4881 enum methods { 4882 M_DESTROY, M_PARSE, M_PARSET 4883 }; 4884 4885 if (objc < 2) { 4886 Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); 4887 return TCL_ERROR; 4888 } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 4889 0, &m) != TCL_OK) { 4890 return TCL_ERROR; 4891 } 4892 4893 /* Dispatch to methods. They check the #args in 4894 * detail before performing the requested 4895 * functionality 4896 */ 4897 4898 switch (m) { 4899 case M_DESTROY: 4900 if (objc != 2) { 4901 Tcl_WrongNumArgs (interp, 2, objv, NULL); 4902 return TCL_ERROR; 4903 } 4904 4905 Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); 4906 return TCL_OK; 4907 4908 case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; 4909 case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; 4910 default: 4911 /* Not coming to this place */ 4912 ASSERT (0,"Reached unreachable location"); 4913 } 4914 4915 return res; 4916 } 4917 } 4918 4919 # # ## ### ##### ######## ############# 4920 # Class command, i.e. object construction. 4921 4922 critcl::ccommand peg_critcl {dummy interp objc objv} { 4923 /* 4924 * Syntax: No arguments beyond the name 4925 */ 4926 4927 RDE_PARAM parser; 4928 CONST char* name; 4929 Tcl_Obj* fqn; 4930 Tcl_CmdInfo ci; 4931 Tcl_Command c; 4932 4933#define USAGE "?name?" 4934 4935 if ((objc != 2) && (objc != 1)) { 4936 Tcl_WrongNumArgs (interp, 1, objv, USAGE); 4937 return TCL_ERROR; 4938 } 4939 4940 if (objc < 2) { 4941 name = PARSERnewName (interp); 4942 } else { 4943 name = Tcl_GetString (objv [1]); 4944 } 4945 4946 if (!Tcl_StringMatch (name, "::*")) { 4947 /* Relative name. Prefix with current namespace */ 4948 4949 Tcl_Eval (interp, "namespace current"); 4950 fqn = Tcl_GetObjResult (interp); 4951 fqn = Tcl_DuplicateObj (fqn); 4952 Tcl_IncrRefCount (fqn); 4953 4954 if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { 4955 Tcl_AppendToObj (fqn, "::", -1); 4956 } 4957 Tcl_AppendToObj (fqn, name, -1); 4958 } else { 4959 fqn = Tcl_NewStringObj (name, -1); 4960 Tcl_IncrRefCount (fqn); 4961 } 4962 Tcl_ResetResult (interp); 4963 4964 if (Tcl_GetCommandInfo (interp, 4965 Tcl_GetString (fqn), 4966 &ci)) { 4967 Tcl_Obj* err; 4968 4969 err = Tcl_NewObj (); 4970 Tcl_AppendToObj (err, "command \"", -1); 4971 Tcl_AppendObjToObj (err, fqn); 4972 Tcl_AppendToObj (err, "\" already exists", -1); 4973 4974 Tcl_DecrRefCount (fqn); 4975 Tcl_SetObjResult (interp, err); 4976 return TCL_ERROR; 4977 } 4978 4979 parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); 4980 c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), 4981 parser_objcmd, (ClientData) parser, 4982 PARSERdeleteCmd); 4983 rde_param_clientdata (parser, (ClientData) c); 4984 Tcl_SetObjResult (interp, fqn); 4985 Tcl_DecrRefCount (fqn); 4986 return TCL_OK; 4987 } 4988 4989 ## 4990 # # ## ### ##### ######## ############# 4991} 4992 4993# # ## ### ##### ######## ############# ##################### 4994## Ready (Note: Our package provide is at the top). 4995return 4996