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