|
|
1.1 ! root 1: /*- ! 2: * Copyright (c) 1990 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * This code is derived from software contributed to Berkeley by ! 6: * Vern Paxson. ! 7: * ! 8: * The United States Government has rights in this work pursuant ! 9: * to contract no. DE-AC03-76SF00098 between the United States ! 10: * Department of Energy and the University of California. ! 11: * ! 12: * Redistribution and use in source and binary forms are permitted provided ! 13: * that: (1) source distributions retain this entire copyright notice and ! 14: * comment, and (2) distributions including binaries display the following ! 15: * acknowledgement: ``This product includes software developed by the ! 16: * University of California, Berkeley and its contributors'' in the ! 17: * documentation or other materials provided with the distribution and in ! 18: * all advertising materials mentioning features or use of this software. ! 19: * Neither the name of the University nor the names of its contributors may ! 20: * be used to endorse or promote products derived from this software without ! 21: * specific prior written permission. ! 22: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 23: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 24: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 25: * ! 26: * @(#)flexdef.h 5.3 (Berkeley) 6/18/90 ! 27: */ ! 28: ! 29: /* flexdef - definitions file for flex */ ! 30: ! 31: #ifndef FILE ! 32: #include <stdio.h> ! 33: #endif ! 34: ! 35: /* always be prepared to generate an 8-bit scanner */ ! 36: #define FLEX_8_BIT_CHARS ! 37: ! 38: #ifdef FLEX_8_BIT_CHARS ! 39: #define CSIZE 256 ! 40: #define Char unsigned char ! 41: #else ! 42: #define Char char ! 43: #define CSIZE 128 ! 44: #endif ! 45: ! 46: /* size of input alphabet - should be size of ASCII set */ ! 47: #ifndef DEFAULT_CSIZE ! 48: #define DEFAULT_CSIZE 128 ! 49: #endif ! 50: ! 51: #ifndef PROTO ! 52: #ifdef __STDC__ ! 53: #define PROTO(proto) proto ! 54: #else ! 55: #define PROTO(proto) () ! 56: #endif ! 57: #endif ! 58: ! 59: #include <string.h> ! 60: ! 61: #ifdef AMIGA ! 62: #define bzero(s, n) setmem((char *)(s), n, '\0') ! 63: #ifndef abs ! 64: #define abs(x) ((x) < 0 ? -(x) : (x)) ! 65: #endif ! 66: #else ! 67: #define bzero(s, n) (void) memset((char *)(s), '\0', n) ! 68: #endif ! 69: ! 70: #ifdef VMS ! 71: #define unlink delete ! 72: #define SHORT_FILE_NAMES ! 73: #endif ! 74: ! 75: char *malloc(), *realloc(); ! 76: ! 77: ! 78: /* maximum line length we'll have to deal with */ ! 79: #define MAXLINE BUFSIZ ! 80: ! 81: /* maximum size of file name */ ! 82: #define FILENAMESIZE 1024 ! 83: ! 84: #ifndef min ! 85: #define min(x,y) ((x) < (y) ? (x) : (y)) ! 86: #endif ! 87: #ifndef max ! 88: #define max(x,y) ((x) > (y) ? (x) : (y)) ! 89: #endif ! 90: ! 91: #ifdef MS_DOS ! 92: #ifndef abs ! 93: #define abs(x) ((x) < 0 ? -(x) : (x)) ! 94: #endif ! 95: #define SHORT_FILE_NAMES ! 96: #endif ! 97: ! 98: #define true 1 ! 99: #define false 0 ! 100: ! 101: ! 102: /* special chk[] values marking the slots taking by end-of-buffer and action ! 103: * numbers ! 104: */ ! 105: #define EOB_POSITION -1 ! 106: #define ACTION_POSITION -2 ! 107: ! 108: /* number of data items per line for -f output */ ! 109: #define NUMDATAITEMS 10 ! 110: ! 111: /* number of lines of data in -f output before inserting a blank line for ! 112: * readability. ! 113: */ ! 114: #define NUMDATALINES 10 ! 115: ! 116: /* transition_struct_out() definitions */ ! 117: #define TRANS_STRUCT_PRINT_LENGTH 15 ! 118: ! 119: /* returns true if an nfa state has an epsilon out-transition slot ! 120: * that can be used. This definition is currently not used. ! 121: */ ! 122: #define FREE_EPSILON(state) \ ! 123: (transchar[state] == SYM_EPSILON && \ ! 124: trans2[state] == NO_TRANSITION && \ ! 125: finalst[state] != state) ! 126: ! 127: /* returns true if an nfa state has an epsilon out-transition character ! 128: * and both slots are free ! 129: */ ! 130: #define SUPER_FREE_EPSILON(state) \ ! 131: (transchar[state] == SYM_EPSILON && \ ! 132: trans1[state] == NO_TRANSITION) \ ! 133: ! 134: /* maximum number of NFA states that can comprise a DFA state. It's real ! 135: * big because if there's a lot of rules, the initial state will have a ! 136: * huge epsilon closure. ! 137: */ ! 138: #define INITIAL_MAX_DFA_SIZE 750 ! 139: #define MAX_DFA_SIZE_INCREMENT 750 ! 140: ! 141: ! 142: /* a note on the following masks. They are used to mark accepting numbers ! 143: * as being special. As such, they implicitly limit the number of accepting ! 144: * numbers (i.e., rules) because if there are too many rules the rule numbers ! 145: * will overload the mask bits. Fortunately, this limit is \large/ (0x2000 == ! 146: * 8192) so unlikely to actually cause any problems. A check is made in ! 147: * new_rule() to ensure that this limit is not reached. ! 148: */ ! 149: ! 150: /* mask to mark a trailing context accepting number */ ! 151: #define YY_TRAILING_MASK 0x2000 ! 152: ! 153: /* mask to mark the accepting number of the "head" of a trailing context rule */ ! 154: #define YY_TRAILING_HEAD_MASK 0x4000 ! 155: ! 156: /* maximum number of rules, as outlined in the above note */ ! 157: #define MAX_RULE (YY_TRAILING_MASK - 1) ! 158: ! 159: ! 160: /* NIL must be 0. If not, its special meaning when making equivalence classes ! 161: * (it marks the representative of a given e.c.) will be unidentifiable ! 162: */ ! 163: #define NIL 0 ! 164: ! 165: #define JAM -1 /* to mark a missing DFA transition */ ! 166: #define NO_TRANSITION NIL ! 167: #define UNIQUE -1 /* marks a symbol as an e.c. representative */ ! 168: #define INFINITY -1 /* for x{5,} constructions */ ! 169: ! 170: #define INITIAL_MAX_CCLS 100 /* max number of unique character classes */ ! 171: #define MAX_CCLS_INCREMENT 100 ! 172: ! 173: /* size of table holding members of character classes */ ! 174: #define INITIAL_MAX_CCL_TBL_SIZE 500 ! 175: #define MAX_CCL_TBL_SIZE_INCREMENT 250 ! 176: ! 177: #define INITIAL_MAX_RULES 100 /* default maximum number of rules */ ! 178: #define MAX_RULES_INCREMENT 100 ! 179: ! 180: #define INITIAL_MNS 2000 /* default maximum number of nfa states */ ! 181: #define MNS_INCREMENT 1000 /* amount to bump above by if it's not enough */ ! 182: ! 183: #define INITIAL_MAX_DFAS 1000 /* default maximum number of dfa states */ ! 184: #define MAX_DFAS_INCREMENT 1000 ! 185: ! 186: #define JAMSTATE -32766 /* marks a reference to the state that always jams */ ! 187: ! 188: /* enough so that if it's subtracted from an NFA state number, the result ! 189: * is guaranteed to be negative ! 190: */ ! 191: #define MARKER_DIFFERENCE 32000 ! 192: #define MAXIMUM_MNS 31999 ! 193: ! 194: /* maximum number of nxt/chk pairs for non-templates */ ! 195: #define INITIAL_MAX_XPAIRS 2000 ! 196: #define MAX_XPAIRS_INCREMENT 2000 ! 197: ! 198: /* maximum number of nxt/chk pairs needed for templates */ ! 199: #define INITIAL_MAX_TEMPLATE_XPAIRS 2500 ! 200: #define MAX_TEMPLATE_XPAIRS_INCREMENT 2500 ! 201: ! 202: #define SYM_EPSILON (CSIZE + 1) /* to mark transitions on the symbol epsilon */ ! 203: ! 204: #define INITIAL_MAX_SCS 40 /* maximum number of start conditions */ ! 205: #define MAX_SCS_INCREMENT 40 /* amount to bump by if it's not enough */ ! 206: ! 207: #define ONE_STACK_SIZE 500 /* stack of states with only one out-transition */ ! 208: #define SAME_TRANS -1 /* transition is the same as "default" entry for state */ ! 209: ! 210: /* the following percentages are used to tune table compression: ! 211: ! 212: * the percentage the number of out-transitions a state must be of the ! 213: * number of equivalence classes in order to be considered for table ! 214: * compaction by using protos ! 215: */ ! 216: #define PROTO_SIZE_PERCENTAGE 15 ! 217: ! 218: /* the percentage the number of homogeneous out-transitions of a state ! 219: * must be of the number of total out-transitions of the state in order ! 220: * that the state's transition table is first compared with a potential ! 221: * template of the most common out-transition instead of with the first ! 222: * proto in the proto queue ! 223: */ ! 224: #define CHECK_COM_PERCENTAGE 50 ! 225: ! 226: /* the percentage the number of differences between a state's transition ! 227: * table and the proto it was first compared with must be of the total ! 228: * number of out-transitions of the state in order to keep the first ! 229: * proto as a good match and not search any further ! 230: */ ! 231: #define FIRST_MATCH_DIFF_PERCENTAGE 10 ! 232: ! 233: /* the percentage the number of differences between a state's transition ! 234: * table and the most similar proto must be of the state's total number ! 235: * of out-transitions to use the proto as an acceptable close match ! 236: */ ! 237: #define ACCEPTABLE_DIFF_PERCENTAGE 50 ! 238: ! 239: /* the percentage the number of homogeneous out-transitions of a state ! 240: * must be of the number of total out-transitions of the state in order ! 241: * to consider making a template from the state ! 242: */ ! 243: #define TEMPLATE_SAME_PERCENTAGE 60 ! 244: ! 245: /* the percentage the number of differences between a state's transition ! 246: * table and the most similar proto must be of the state's total number ! 247: * of out-transitions to create a new proto from the state ! 248: */ ! 249: #define NEW_PROTO_DIFF_PERCENTAGE 20 ! 250: ! 251: /* the percentage the total number of out-transitions of a state must be ! 252: * of the number of equivalence classes in order to consider trying to ! 253: * fit the transition table into "holes" inside the nxt/chk table. ! 254: */ ! 255: #define INTERIOR_FIT_PERCENTAGE 15 ! 256: ! 257: /* size of region set aside to cache the complete transition table of ! 258: * protos on the proto queue to enable quick comparisons ! 259: */ ! 260: #define PROT_SAVE_SIZE 2000 ! 261: ! 262: #define MSP 50 /* maximum number of saved protos (protos on the proto queue) */ ! 263: ! 264: /* maximum number of out-transitions a state can have that we'll rummage ! 265: * around through the interior of the internal fast table looking for a ! 266: * spot for it ! 267: */ ! 268: #define MAX_XTIONS_FULL_INTERIOR_FIT 4 ! 269: ! 270: /* maximum number of rules which will be reported as being associated ! 271: * with a DFA state ! 272: */ ! 273: #define MAX_ASSOC_RULES 100 ! 274: ! 275: /* number that, if used to subscript an array, has a good chance of producing ! 276: * an error; should be small enough to fit into a short ! 277: */ ! 278: #define BAD_SUBSCRIPT -32767 ! 279: ! 280: /* absolute value of largest number that can be stored in a short, with a ! 281: * bit of slop thrown in for general paranoia. ! 282: */ ! 283: #define MAX_SHORT 32766 ! 284: ! 285: ! 286: /* Declarations for global variables. */ ! 287: ! 288: /* variables for symbol tables: ! 289: * sctbl - start-condition symbol table ! 290: * ndtbl - name-definition symbol table ! 291: * ccltab - character class text symbol table ! 292: */ ! 293: ! 294: struct hash_entry ! 295: { ! 296: struct hash_entry *prev, *next; ! 297: char *name; ! 298: char *str_val; ! 299: int int_val; ! 300: } ; ! 301: ! 302: typedef struct hash_entry *hash_table[]; ! 303: ! 304: #define NAME_TABLE_HASH_SIZE 101 ! 305: #define START_COND_HASH_SIZE 101 ! 306: #define CCL_HASH_SIZE 101 ! 307: ! 308: extern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE]; ! 309: extern struct hash_entry *sctbl[START_COND_HASH_SIZE]; ! 310: extern struct hash_entry *ccltab[CCL_HASH_SIZE]; ! 311: ! 312: ! 313: /* variables for flags: ! 314: * printstats - if true (-v), dump statistics ! 315: * syntaxerror - true if a syntax error has been found ! 316: * eofseen - true if we've seen an eof in the input file ! 317: * ddebug - if true (-d), make a "debug" scanner ! 318: * trace - if true (-T), trace processing ! 319: * spprdflt - if true (-s), suppress the default rule ! 320: * interactive - if true (-I), generate an interactive scanner ! 321: * caseins - if true (-i), generate a case-insensitive scanner ! 322: * useecs - if true (-Ce flag), use equivalence classes ! 323: * fulltbl - if true (-Cf flag), don't compress the DFA state table ! 324: * usemecs - if true (-Cm flag), use meta-equivalence classes ! 325: * fullspd - if true (-F flag), use Jacobson method of table representation ! 326: * gen_line_dirs - if true (i.e., no -L flag), generate #line directives ! 327: * performance_report - if true (i.e., -p flag), generate a report relating ! 328: * to scanner performance ! 329: * backtrack_report - if true (i.e., -b flag), generate "lex.backtrack" file ! 330: * listing backtracking states ! 331: * csize - size of character set for the scanner we're generating; ! 332: * 128 for 7-bit chars and 256 for 8-bit ! 333: * yymore_used - if true, yymore() is used in input rules ! 334: * reject - if true, generate backtracking tables for REJECT macro ! 335: * real_reject - if true, scanner really uses REJECT (as opposed to just ! 336: * having "reject" set for variable trailing context) ! 337: * continued_action - true if this rule's action is to "fall through" to ! 338: * the next rule's action (i.e., the '|' action) ! 339: * yymore_really_used - has a REALLY_xxx value indicating whether a ! 340: * %used or %notused was used with yymore() ! 341: * reject_really_used - same for REJECT ! 342: */ ! 343: ! 344: extern int printstats, syntaxerror, eofseen, ddebug, trace, spprdflt; ! 345: extern int interactive, caseins, useecs, fulltbl, usemecs; ! 346: extern int fullspd, gen_line_dirs, performance_report, backtrack_report, csize; ! 347: extern int yymore_used, reject, real_reject, continued_action; ! 348: ! 349: #define REALLY_NOT_DETERMINED 0 ! 350: #define REALLY_USED 1 ! 351: #define REALLY_NOT_USED 2 ! 352: extern int yymore_really_used, reject_really_used; ! 353: ! 354: ! 355: /* variables used in the flex input routines: ! 356: * datapos - characters on current output line ! 357: * dataline - number of contiguous lines of data in current data ! 358: * statement. Used to generate readable -f output ! 359: * linenum - current input line number ! 360: * skelfile - the skeleton file ! 361: * yyin - input file ! 362: * temp_action_file - temporary file to hold actions ! 363: * backtrack_file - file to summarize backtracking states to ! 364: * infilename - name of input file ! 365: * action_file_name - name of the temporary file ! 366: * input_files - array holding names of input files ! 367: * num_input_files - size of input_files array ! 368: * program_name - name with which program was invoked ! 369: */ ! 370: ! 371: extern int datapos, dataline, linenum; ! 372: extern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file; ! 373: extern char *infilename; ! 374: extern char *action_file_name; ! 375: extern char **input_files; ! 376: extern int num_input_files; ! 377: extern char *program_name; ! 378: ! 379: ! 380: /* variables for stack of states having only one out-transition: ! 381: * onestate - state number ! 382: * onesym - transition symbol ! 383: * onenext - target state ! 384: * onedef - default base entry ! 385: * onesp - stack pointer ! 386: */ ! 387: ! 388: extern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE]; ! 389: extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp; ! 390: ! 391: ! 392: /* variables for nfa machine data: ! 393: * current_mns - current maximum on number of NFA states ! 394: * num_rules - number of the last accepting state; also is number of ! 395: * rules created so far ! 396: * current_max_rules - current maximum number of rules ! 397: * lastnfa - last nfa state number created ! 398: * firstst - physically the first state of a fragment ! 399: * lastst - last physical state of fragment ! 400: * finalst - last logical state of fragment ! 401: * transchar - transition character ! 402: * trans1 - transition state ! 403: * trans2 - 2nd transition state for epsilons ! 404: * accptnum - accepting number ! 405: * assoc_rule - rule associated with this NFA state (or 0 if none) ! 406: * state_type - a STATE_xxx type identifying whether the state is part ! 407: * of a normal rule, the leading state in a trailing context ! 408: * rule (i.e., the state which marks the transition from ! 409: * recognizing the text-to-be-matched to the beginning of ! 410: * the trailing context), or a subsequent state in a trailing ! 411: * context rule ! 412: * rule_type - a RULE_xxx type identifying whether this a a ho-hum ! 413: * normal rule or one which has variable head & trailing ! 414: * context ! 415: * rule_linenum - line number associated with rule ! 416: */ ! 417: ! 418: extern int current_mns, num_rules, current_max_rules, lastnfa; ! 419: extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2; ! 420: extern int *accptnum, *assoc_rule, *state_type, *rule_type, *rule_linenum; ! 421: ! 422: /* different types of states; values are useful as masks, as well, for ! 423: * routines like check_trailing_context() ! 424: */ ! 425: #define STATE_NORMAL 0x1 ! 426: #define STATE_TRAILING_CONTEXT 0x2 ! 427: ! 428: /* global holding current type of state we're making */ ! 429: ! 430: extern int current_state_type; ! 431: ! 432: /* different types of rules */ ! 433: #define RULE_NORMAL 0 ! 434: #define RULE_VARIABLE 1 ! 435: ! 436: /* true if the input rules include a rule with both variable-length head ! 437: * and trailing context, false otherwise ! 438: */ ! 439: extern int variable_trailing_context_rules; ! 440: ! 441: ! 442: /* variables for protos: ! 443: * numtemps - number of templates created ! 444: * numprots - number of protos created ! 445: * protprev - backlink to a more-recently used proto ! 446: * protnext - forward link to a less-recently used proto ! 447: * prottbl - base/def table entry for proto ! 448: * protcomst - common state of proto ! 449: * firstprot - number of the most recently used proto ! 450: * lastprot - number of the least recently used proto ! 451: * protsave contains the entire state array for protos ! 452: */ ! 453: ! 454: extern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP]; ! 455: extern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE]; ! 456: ! 457: ! 458: /* variables for managing equivalence classes: ! 459: * numecs - number of equivalence classes ! 460: * nextecm - forward link of Equivalence Class members ! 461: * ecgroup - class number or backward link of EC members ! 462: * nummecs - number of meta-equivalence classes (used to compress ! 463: * templates) ! 464: * tecfwd - forward link of meta-equivalence classes members ! 465: * tecbck - backward link of MEC's ! 466: * xlation - maps character codes to their translations, or nil if no %t table ! 467: * num_xlations - number of different xlation values ! 468: */ ! 469: ! 470: /* reserve enough room in the equivalence class arrays so that we ! 471: * can use the CSIZE'th element to hold equivalence class information ! 472: * for the NUL character. Later we'll move this information into ! 473: * the 0th element. ! 474: */ ! 475: extern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs; ! 476: ! 477: /* meta-equivalence classes are indexed starting at 1, so it's possible ! 478: * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1 ! 479: * slots total (since the arrays are 0-based). nextecm[] and ecgroup[] ! 480: * don't require the extra position since they're indexed from 1 .. CSIZE - 1. ! 481: */ ! 482: extern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1]; ! 483: ! 484: extern int *xlation; ! 485: extern int num_xlations; ! 486: ! 487: ! 488: /* variables for start conditions: ! 489: * lastsc - last start condition created ! 490: * current_max_scs - current limit on number of start conditions ! 491: * scset - set of rules active in start condition ! 492: * scbol - set of rules active only at the beginning of line in a s.c. ! 493: * scxclu - true if start condition is exclusive ! 494: * sceof - true if start condition has EOF rule ! 495: * scname - start condition name ! 496: * actvsc - stack of active start conditions for the current rule ! 497: */ ! 498: ! 499: extern int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc; ! 500: extern char **scname; ! 501: ! 502: ! 503: /* variables for dfa machine data: ! 504: * current_max_dfa_size - current maximum number of NFA states in DFA ! 505: * current_max_xpairs - current maximum number of non-template xtion pairs ! 506: * current_max_template_xpairs - current maximum number of template pairs ! 507: * current_max_dfas - current maximum number DFA states ! 508: * lastdfa - last dfa state number created ! 509: * nxt - state to enter upon reading character ! 510: * chk - check value to see if "nxt" applies ! 511: * tnxt - internal nxt table for templates ! 512: * base - offset into "nxt" for given state ! 513: * def - where to go if "chk" disallows "nxt" entry ! 514: * nultrans - NUL transition for each state ! 515: * NUL_ec - equivalence class of the NUL character ! 516: * tblend - last "nxt/chk" table entry being used ! 517: * firstfree - first empty entry in "nxt/chk" table ! 518: * dss - nfa state set for each dfa ! 519: * dfasiz - size of nfa state set for each dfa ! 520: * dfaacc - accepting set for each dfa state (or accepting number, if ! 521: * -r is not given) ! 522: * accsiz - size of accepting set for each dfa state ! 523: * dhash - dfa state hash value ! 524: * numas - number of DFA accepting states created; note that this ! 525: * is not necessarily the same value as num_rules, which is the analogous ! 526: * value for the NFA ! 527: * numsnpairs - number of state/nextstate transition pairs ! 528: * jambase - position in base/def where the default jam table starts ! 529: * jamstate - state number corresponding to "jam" state ! 530: * end_of_buffer_state - end-of-buffer dfa state number ! 531: */ ! 532: ! 533: extern int current_max_dfa_size, current_max_xpairs; ! 534: extern int current_max_template_xpairs, current_max_dfas; ! 535: extern int lastdfa, lasttemp, *nxt, *chk, *tnxt; ! 536: extern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz; ! 537: extern union dfaacc_union ! 538: { ! 539: int *dfaacc_set; ! 540: int dfaacc_state; ! 541: } *dfaacc; ! 542: extern int *accsiz, *dhash, numas; ! 543: extern int numsnpairs, jambase, jamstate; ! 544: extern int end_of_buffer_state; ! 545: ! 546: /* variables for ccl information: ! 547: * lastccl - ccl index of the last created ccl ! 548: * current_maxccls - current limit on the maximum number of unique ccl's ! 549: * cclmap - maps a ccl index to its set pointer ! 550: * ccllen - gives the length of a ccl ! 551: * cclng - true for a given ccl if the ccl is negated ! 552: * cclreuse - counts how many times a ccl is re-used ! 553: * current_max_ccl_tbl_size - current limit on number of characters needed ! 554: * to represent the unique ccl's ! 555: * ccltbl - holds the characters in each ccl - indexed by cclmap ! 556: */ ! 557: ! 558: extern int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse; ! 559: extern int current_max_ccl_tbl_size; ! 560: extern Char *ccltbl; ! 561: ! 562: ! 563: /* variables for miscellaneous information: ! 564: * starttime - real-time when we started ! 565: * endtime - real-time when we ended ! 566: * nmstr - last NAME scanned by the scanner ! 567: * sectnum - section number currently being parsed ! 568: * nummt - number of empty nxt/chk table entries ! 569: * hshcol - number of hash collisions detected by snstods ! 570: * dfaeql - number of times a newly created dfa was equal to an old one ! 571: * numeps - number of epsilon NFA states created ! 572: * eps2 - number of epsilon states which have 2 out-transitions ! 573: * num_reallocs - number of times it was necessary to realloc() a group ! 574: * of arrays ! 575: * tmpuses - number of DFA states that chain to templates ! 576: * totnst - total number of NFA states used to make DFA states ! 577: * peakpairs - peak number of transition pairs we had to store internally ! 578: * numuniq - number of unique transitions ! 579: * numdup - number of duplicate transitions ! 580: * hshsave - number of hash collisions saved by checking number of states ! 581: * num_backtracking - number of DFA states requiring back-tracking ! 582: * bol_needed - whether scanner needs beginning-of-line recognition ! 583: */ ! 584: ! 585: extern char *starttime, *endtime, nmstr[MAXLINE]; ! 586: extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; ! 587: extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; ! 588: extern int num_backtracking, bol_needed; ! 589: ! 590: void *allocate_array(), *reallocate_array(); ! 591: ! 592: #define allocate_integer_array(size) \ ! 593: (int *) allocate_array( size, sizeof( int ) ) ! 594: ! 595: #define reallocate_integer_array(array,size) \ ! 596: (int *) reallocate_array( (void *) array, size, sizeof( int ) ) ! 597: ! 598: #define allocate_int_ptr_array(size) \ ! 599: (int **) allocate_array( size, sizeof( int * ) ) ! 600: ! 601: #define allocate_char_ptr_array(size) \ ! 602: (char **) allocate_array( size, sizeof( char * ) ) ! 603: ! 604: #define allocate_dfaacc_union(size) \ ! 605: (union dfaacc_union *) \ ! 606: allocate_array( size, sizeof( union dfaacc_union ) ) ! 607: ! 608: #define reallocate_int_ptr_array(array,size) \ ! 609: (int **) reallocate_array( (void *) array, size, sizeof( int * ) ) ! 610: ! 611: #define reallocate_char_ptr_array(array,size) \ ! 612: (char **) reallocate_array( (void *) array, size, sizeof( char * ) ) ! 613: ! 614: #define reallocate_dfaacc_union(array, size) \ ! 615: (union dfaacc_union *) \ ! 616: reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) ) ! 617: ! 618: #define allocate_character_array(size) \ ! 619: (Char *) allocate_array( size, sizeof( Char ) ) ! 620: ! 621: #define reallocate_character_array(array,size) \ ! 622: (Char *) reallocate_array( (void *) array, size, sizeof( Char ) ) ! 623: ! 624: ! 625: /* used to communicate between scanner and parser. The type should really ! 626: * be YYSTYPE, but we can't easily get our hands on it. ! 627: */ ! 628: extern int yylval; ! 629: ! 630: ! 631: /* external functions that are cross-referenced among the flex source files */ ! 632: ! 633: ! 634: /* from file ccl.c */ ! 635: ! 636: extern void ccladd PROTO((int, int)); /* Add a single character to a ccl */ ! 637: extern int cclinit PROTO(()); /* make an empty ccl */ ! 638: extern void cclnegate PROTO((int)); /* negate a ccl */ ! 639: ! 640: /* list the members of a set of characters in CCL form */ ! 641: extern void list_character_set PROTO((FILE*, int[])); ! 642: ! 643: ! 644: /* from file dfa.c */ ! 645: ! 646: /* increase the maximum number of dfas */ ! 647: extern void increase_max_dfas PROTO(()); ! 648: ! 649: extern void ntod PROTO(()); /* convert a ndfa to a dfa */ ! 650: ! 651: ! 652: /* from file ecs.c */ ! 653: ! 654: /* convert character classes to set of equivalence classes */ ! 655: extern void ccl2ecl PROTO(()); ! 656: ! 657: /* associate equivalence class numbers with class members */ ! 658: extern int cre8ecs PROTO((int[], int[], int)); ! 659: ! 660: /* associate equivalence class numbers using %t table */ ! 661: extern int ecs_from_xlation PROTO((int[])); ! 662: ! 663: /* update equivalence classes based on character class transitions */ ! 664: extern void mkeccl PROTO((Char[], int, int[], int[], int, int)); ! 665: ! 666: /* create equivalence class for single character */ ! 667: extern void mkechar PROTO((int, int[], int[])); ! 668: ! 669: ! 670: /* from file gen.c */ ! 671: ! 672: extern void make_tables PROTO(()); /* generate transition tables */ ! 673: ! 674: ! 675: /* from file main.c */ ! 676: ! 677: extern void flexend PROTO((int)); ! 678: ! 679: ! 680: /* from file misc.c */ ! 681: ! 682: /* write out the actions from the temporary file to lex.yy.c */ ! 683: extern void action_out PROTO(()); ! 684: ! 685: /* true if a string is all lower case */ ! 686: extern int all_lower PROTO((register Char *)); ! 687: ! 688: /* true if a string is all upper case */ ! 689: extern int all_upper PROTO((register Char *)); ! 690: ! 691: /* bubble sort an integer array */ ! 692: extern void bubble PROTO((int [], int)); ! 693: ! 694: /* shell sort a character array */ ! 695: extern void cshell PROTO((Char [], int, int)); ! 696: ! 697: extern void dataend PROTO(()); /* finish up a block of data declarations */ ! 698: ! 699: /* report an error message and terminate */ ! 700: extern void flexerror PROTO((char[])); ! 701: ! 702: /* report a fatal error message and terminate */ ! 703: extern void flexfatal PROTO((char[])); ! 704: ! 705: /* report an error message formatted with one integer argument */ ! 706: extern void lerrif PROTO((char[], int)); ! 707: ! 708: /* report an error message formatted with one string argument */ ! 709: extern void lerrsf PROTO((char[], char[])); ! 710: ! 711: /* spit out a "# line" statement */ ! 712: extern void line_directive_out PROTO((FILE*)); ! 713: ! 714: /* generate a data statment for a two-dimensional array */ ! 715: extern void mk2data PROTO((int)); ! 716: ! 717: extern void mkdata PROTO((int)); /* generate a data statement */ ! 718: ! 719: /* return the integer represented by a string of digits */ ! 720: extern int myctoi PROTO((Char [])); ! 721: ! 722: /* write out one section of the skeleton file */ ! 723: extern void skelout PROTO(()); ! 724: ! 725: /* output a yy_trans_info structure */ ! 726: extern void transition_struct_out PROTO((int, int)); ! 727: ! 728: ! 729: /* from file nfa.c */ ! 730: ! 731: /* add an accepting state to a machine */ ! 732: extern void add_accept PROTO((int, int)); ! 733: ! 734: /* make a given number of copies of a singleton machine */ ! 735: extern int copysingl PROTO((int, int)); ! 736: ! 737: /* debugging routine to write out an nfa */ ! 738: extern void dumpnfa PROTO((int)); ! 739: ! 740: /* finish up the processing for a rule */ ! 741: extern void finish_rule PROTO((int, int, int, int)); ! 742: ! 743: /* connect two machines together */ ! 744: extern int link_machines PROTO((int, int)); ! 745: ! 746: /* mark each "beginning" state in a machine as being a "normal" (i.e., ! 747: * not trailing context associated) state ! 748: */ ! 749: extern void mark_beginning_as_normal PROTO((register int)); ! 750: ! 751: /* make a machine that branches to two machines */ ! 752: extern int mkbranch PROTO((int, int)); ! 753: ! 754: extern int mkclos PROTO((int)); /* convert a machine into a closure */ ! 755: extern int mkopt PROTO((int)); /* make a machine optional */ ! 756: ! 757: /* make a machine that matches either one of two machines */ ! 758: extern int mkor PROTO((int, int)); ! 759: ! 760: /* convert a machine into a positive closure */ ! 761: extern int mkposcl PROTO((int)); ! 762: ! 763: extern int mkrep PROTO((int, int, int)); /* make a replicated machine */ ! 764: ! 765: /* create a state with a transition on a given symbol */ ! 766: extern int mkstate PROTO((int)); ! 767: ! 768: extern void new_rule PROTO(()); /* initialize for a new rule */ ! 769: ! 770: ! 771: /* from file parse.y */ ! 772: ! 773: /* write out a message formatted with one string, pinpointing its location */ ! 774: extern void format_pinpoint_message PROTO((char[], char[])); ! 775: ! 776: /* write out a message, pinpointing its location */ ! 777: extern void pinpoint_message PROTO((char[])); ! 778: ! 779: extern void synerr PROTO((char [])); /* report a syntax error */ ! 780: extern int yyparse PROTO(()); /* the YACC parser */ ! 781: ! 782: ! 783: /* from file scan.l */ ! 784: ! 785: extern int flexscan PROTO(()); /* the Flex-generated scanner for flex */ ! 786: ! 787: /* open the given file (if NULL, stdin) for scanning */ ! 788: extern void set_input_file PROTO((char*)); ! 789: ! 790: extern int yywrap PROTO(()); /* wrapup a file in the lexical analyzer */ ! 791: ! 792: ! 793: /* from file sym.c */ ! 794: ! 795: /* save the text of a character class */ ! 796: extern void cclinstal PROTO ((Char [], int)); ! 797: ! 798: /* lookup the number associated with character class */ ! 799: extern int ccllookup PROTO((Char [])); ! 800: ! 801: extern void ndinstal PROTO((char[], Char[])); /* install a name definition */ ! 802: extern void scinstal PROTO((char[], int)); /* make a start condition */ ! 803: ! 804: /* lookup the number associated with a start condition */ ! 805: extern int sclookup PROTO((char[])); ! 806: ! 807: ! 808: /* from file tblcmp.c */ ! 809: ! 810: /* build table entries for dfa state */ ! 811: extern void bldtbl PROTO((int[], int, int, int, int)); ! 812: ! 813: extern void cmptmps PROTO(()); /* compress template table entries */ ! 814: extern void inittbl PROTO(()); /* initialize transition tables */ ! 815: extern void mkdeftbl PROTO(()); /* make the default, "jam" table entries */ ! 816: ! 817: /* create table entries for a state (or state fragment) which has ! 818: * only one out-transition */ ! 819: extern void mk1tbl PROTO((int, int, int, int)); ! 820: ! 821: /* place a state into full speed transition table */ ! 822: extern void place_state PROTO((int*, int, int)); ! 823: ! 824: /* save states with only one out-transition to be processed later */ ! 825: extern void stack1 PROTO((int, int, int, int)); ! 826: ! 827: ! 828: /* from file yylex.c */ ! 829: ! 830: extern int yylex PROTO(()); ! 831: ! 832: ! 833: /* The Unix kernel calls used here */ ! 834: ! 835: extern int read PROTO((int, char*, int)); ! 836: extern int unlink PROTO((char*)); ! 837: extern int write PROTO((int, char*, int));
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.