flexdef.h revision 16519
12258Scsgr/* flexdef - definitions file for flex */ 22258Scsgr 32258Scsgr/*- 42258Scsgr * Copyright (c) 1990 The Regents of the University of California. 52258Scsgr * All rights reserved. 62258Scsgr * 72258Scsgr * This code is derived from software contributed to Berkeley by 82258Scsgr * Vern Paxson. 916519Snate * 102258Scsgr * The United States Government has rights in this work pursuant 112258Scsgr * to contract no. DE-AC03-76SF00098 between the United States 122258Scsgr * Department of Energy and the University of California. 132258Scsgr * 142258Scsgr * Redistribution and use in source and binary forms are permitted provided 152258Scsgr * that: (1) source distributions retain this entire copyright notice and 162258Scsgr * comment, and (2) distributions including binaries display the following 172258Scsgr * acknowledgement: ``This product includes software developed by the 182258Scsgr * University of California, Berkeley and its contributors'' in the 192258Scsgr * documentation or other materials provided with the distribution and in 202258Scsgr * all advertising materials mentioning features or use of this software. 212258Scsgr * Neither the name of the University nor the names of its contributors may 222258Scsgr * be used to endorse or promote products derived from this software without 232258Scsgr * specific prior written permission. 242258Scsgr * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 252258Scsgr * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 262258Scsgr * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 272258Scsgr */ 282258Scsgr 2916519Snate/* @(#) $Header: /home/ncvs/src/usr.bin/lex/flexdef.h,v 1.1.1.2 1996/06/19 20:26:08 nate Exp $ (LBL) */ 302258Scsgr 312258Scsgr#include <stdio.h> 322258Scsgr#include <ctype.h> 332258Scsgr 3416519Snate#include "config.h" 3516519Snate 3616519Snate#ifdef __TURBOC__ 3716519Snate#define HAVE_STRING_H 1 3816519Snate#define MS_DOS 1 3916519Snate#ifndef __STDC__ 4016519Snate#define __STDC__ 1 4116519Snate#endif 4216519Snate #pragma warn -pro 4316519Snate #pragma warn -rch 4416519Snate #pragma warn -use 4516519Snate #pragma warn -aus 4616519Snate #pragma warn -par 4716519Snate #pragma warn -pia 4816519Snate#endif 4916519Snate 5016519Snate#ifdef HAVE_STRING_H 512258Scsgr#include <string.h> 522258Scsgr#else 532258Scsgr#include <strings.h> 542258Scsgr#endif 552258Scsgr 5616519Snate#ifdef HAVE_SYS_TYPES_H 5716519Snate#include <sys/types.h> 5816519Snate#endif 5916519Snate 6016519Snate#ifdef HAVE_MALLOC_H 6116519Snate#include <malloc.h> 6216519Snate#endif 6316519Snate 6416519Snate#ifdef STDC_HEADERS 652258Scsgr#include <stdlib.h> 662258Scsgr#endif 672258Scsgr 6816519Snate/* As an aid for the internationalization patch to flex, which 6916519Snate * is maintained outside this distribution for copyright reasons. 7016519Snate */ 7116519Snate#define _(String) (String) 7216519Snate 732258Scsgr/* Always be prepared to generate an 8-bit scanner. */ 742258Scsgr#define CSIZE 256 752258Scsgr#define Char unsigned char 762258Scsgr 772258Scsgr/* Size of input alphabet - should be size of ASCII set. */ 782258Scsgr#ifndef DEFAULT_CSIZE 792258Scsgr#define DEFAULT_CSIZE 128 802258Scsgr#endif 812258Scsgr 822258Scsgr#ifndef PROTO 8316519Snate#if __STDC__ 842258Scsgr#define PROTO(proto) proto 852258Scsgr#else 862258Scsgr#define PROTO(proto) () 872258Scsgr#endif 882258Scsgr#endif 892258Scsgr 902258Scsgr#ifdef VMS 9116519Snate#ifndef __VMS_POSIX 9216519Snate#define unlink remove 932258Scsgr#define SHORT_FILE_NAMES 942258Scsgr#endif 9516519Snate#endif 962258Scsgr 972258Scsgr#ifdef MS_DOS 982258Scsgr#define SHORT_FILE_NAMES 992258Scsgr#endif 1002258Scsgr 1012258Scsgr 1022258Scsgr/* Maximum line length we'll have to deal with. */ 1032258Scsgr#define MAXLINE 2048 1042258Scsgr 1052258Scsgr#ifndef MIN 1062258Scsgr#define MIN(x,y) ((x) < (y) ? (x) : (y)) 1072258Scsgr#endif 1082258Scsgr#ifndef MAX 1092258Scsgr#define MAX(x,y) ((x) > (y) ? (x) : (y)) 1102258Scsgr#endif 1112258Scsgr#ifndef ABS 1122258Scsgr#define ABS(x) ((x) < 0 ? -(x) : (x)) 1132258Scsgr#endif 1142258Scsgr 1152258Scsgr 1162258Scsgr/* ANSI C does not guarantee that isascii() is defined */ 1172258Scsgr#ifndef isascii 1182258Scsgr#define isascii(c) ((c) <= 0177) 1192258Scsgr#endif 1202258Scsgr 1212258Scsgr 1222258Scsgr#define true 1 1232258Scsgr#define false 0 12416519Snate#define unspecified -1 1252258Scsgr 1262258Scsgr 1272258Scsgr/* Special chk[] values marking the slots taking by end-of-buffer and action 1282258Scsgr * numbers. 1292258Scsgr */ 1302258Scsgr#define EOB_POSITION -1 1312258Scsgr#define ACTION_POSITION -2 1322258Scsgr 1332258Scsgr/* Number of data items per line for -f output. */ 1342258Scsgr#define NUMDATAITEMS 10 1352258Scsgr 1362258Scsgr/* Number of lines of data in -f output before inserting a blank line for 1372258Scsgr * readability. 1382258Scsgr */ 1392258Scsgr#define NUMDATALINES 10 1402258Scsgr 14116519Snate/* transition_struct_out() definitions. */ 14216519Snate#define TRANS_STRUCT_PRINT_LENGTH 14 1432258Scsgr 1442258Scsgr/* Returns true if an nfa state has an epsilon out-transition slot 1452258Scsgr * that can be used. This definition is currently not used. 1462258Scsgr */ 1472258Scsgr#define FREE_EPSILON(state) \ 1482258Scsgr (transchar[state] == SYM_EPSILON && \ 1492258Scsgr trans2[state] == NO_TRANSITION && \ 1502258Scsgr finalst[state] != state) 1512258Scsgr 1522258Scsgr/* Returns true if an nfa state has an epsilon out-transition character 1532258Scsgr * and both slots are free 1542258Scsgr */ 1552258Scsgr#define SUPER_FREE_EPSILON(state) \ 1562258Scsgr (transchar[state] == SYM_EPSILON && \ 1572258Scsgr trans1[state] == NO_TRANSITION) \ 1582258Scsgr 1592258Scsgr/* Maximum number of NFA states that can comprise a DFA state. It's real 1602258Scsgr * big because if there's a lot of rules, the initial state will have a 1612258Scsgr * huge epsilon closure. 1622258Scsgr */ 1632258Scsgr#define INITIAL_MAX_DFA_SIZE 750 1642258Scsgr#define MAX_DFA_SIZE_INCREMENT 750 1652258Scsgr 1662258Scsgr 1672258Scsgr/* A note on the following masks. They are used to mark accepting numbers 1682258Scsgr * as being special. As such, they implicitly limit the number of accepting 1692258Scsgr * numbers (i.e., rules) because if there are too many rules the rule numbers 1702258Scsgr * will overload the mask bits. Fortunately, this limit is \large/ (0x2000 == 1712258Scsgr * 8192) so unlikely to actually cause any problems. A check is made in 1722258Scsgr * new_rule() to ensure that this limit is not reached. 1732258Scsgr */ 1742258Scsgr 1752258Scsgr/* Mask to mark a trailing context accepting number. */ 1762258Scsgr#define YY_TRAILING_MASK 0x2000 1772258Scsgr 1782258Scsgr/* Mask to mark the accepting number of the "head" of a trailing context 1792258Scsgr * rule. 1802258Scsgr */ 1812258Scsgr#define YY_TRAILING_HEAD_MASK 0x4000 1822258Scsgr 1832258Scsgr/* Maximum number of rules, as outlined in the above note. */ 1842258Scsgr#define MAX_RULE (YY_TRAILING_MASK - 1) 1852258Scsgr 1862258Scsgr 1872258Scsgr/* NIL must be 0. If not, its special meaning when making equivalence classes 1882258Scsgr * (it marks the representative of a given e.c.) will be unidentifiable. 1892258Scsgr */ 1902258Scsgr#define NIL 0 1912258Scsgr 1922258Scsgr#define JAM -1 /* to mark a missing DFA transition */ 1932258Scsgr#define NO_TRANSITION NIL 1942258Scsgr#define UNIQUE -1 /* marks a symbol as an e.c. representative */ 1952258Scsgr#define INFINITY -1 /* for x{5,} constructions */ 1962258Scsgr 1972258Scsgr#define INITIAL_MAX_CCLS 100 /* max number of unique character classes */ 1982258Scsgr#define MAX_CCLS_INCREMENT 100 1992258Scsgr 2002258Scsgr/* Size of table holding members of character classes. */ 2012258Scsgr#define INITIAL_MAX_CCL_TBL_SIZE 500 2022258Scsgr#define MAX_CCL_TBL_SIZE_INCREMENT 250 2032258Scsgr 2042258Scsgr#define INITIAL_MAX_RULES 100 /* default maximum number of rules */ 2052258Scsgr#define MAX_RULES_INCREMENT 100 2062258Scsgr 2072258Scsgr#define INITIAL_MNS 2000 /* default maximum number of nfa states */ 2082258Scsgr#define MNS_INCREMENT 1000 /* amount to bump above by if it's not enough */ 2092258Scsgr 2102258Scsgr#define INITIAL_MAX_DFAS 1000 /* default maximum number of dfa states */ 2112258Scsgr#define MAX_DFAS_INCREMENT 1000 2122258Scsgr 2132258Scsgr#define JAMSTATE -32766 /* marks a reference to the state that always jams */ 2142258Scsgr 21516519Snate/* Maximum number of NFA states. */ 21616519Snate#define MAXIMUM_MNS 31999 21716519Snate 2182258Scsgr/* Enough so that if it's subtracted from an NFA state number, the result 2192258Scsgr * is guaranteed to be negative. 2202258Scsgr */ 22116519Snate#define MARKER_DIFFERENCE (MAXIMUM_MNS+2) 2222258Scsgr 2232258Scsgr/* Maximum number of nxt/chk pairs for non-templates. */ 2242258Scsgr#define INITIAL_MAX_XPAIRS 2000 2252258Scsgr#define MAX_XPAIRS_INCREMENT 2000 2262258Scsgr 2272258Scsgr/* Maximum number of nxt/chk pairs needed for templates. */ 2282258Scsgr#define INITIAL_MAX_TEMPLATE_XPAIRS 2500 2292258Scsgr#define MAX_TEMPLATE_XPAIRS_INCREMENT 2500 2302258Scsgr 2312258Scsgr#define SYM_EPSILON (CSIZE + 1) /* to mark transitions on the symbol epsilon */ 2322258Scsgr 2332258Scsgr#define INITIAL_MAX_SCS 40 /* maximum number of start conditions */ 2342258Scsgr#define MAX_SCS_INCREMENT 40 /* amount to bump by if it's not enough */ 2352258Scsgr 2362258Scsgr#define ONE_STACK_SIZE 500 /* stack of states with only one out-transition */ 2372258Scsgr#define SAME_TRANS -1 /* transition is the same as "default" entry for state */ 2382258Scsgr 2392258Scsgr/* The following percentages are used to tune table compression: 2402258Scsgr 2412258Scsgr * The percentage the number of out-transitions a state must be of the 2422258Scsgr * number of equivalence classes in order to be considered for table 2432258Scsgr * compaction by using protos. 2442258Scsgr */ 2452258Scsgr#define PROTO_SIZE_PERCENTAGE 15 2462258Scsgr 2472258Scsgr/* The percentage the number of homogeneous out-transitions of a state 2482258Scsgr * must be of the number of total out-transitions of the state in order 24916519Snate * that the state's transition table is first compared with a potential 2502258Scsgr * template of the most common out-transition instead of with the first 2512258Scsgr * proto in the proto queue. 2522258Scsgr */ 2532258Scsgr#define CHECK_COM_PERCENTAGE 50 2542258Scsgr 2552258Scsgr/* The percentage the number of differences between a state's transition 2562258Scsgr * table and the proto it was first compared with must be of the total 2572258Scsgr * number of out-transitions of the state in order to keep the first 2582258Scsgr * proto as a good match and not search any further. 2592258Scsgr */ 2602258Scsgr#define FIRST_MATCH_DIFF_PERCENTAGE 10 2612258Scsgr 2622258Scsgr/* The percentage the number of differences between a state's transition 2632258Scsgr * table and the most similar proto must be of the state's total number 2642258Scsgr * of out-transitions to use the proto as an acceptable close match. 2652258Scsgr */ 2662258Scsgr#define ACCEPTABLE_DIFF_PERCENTAGE 50 2672258Scsgr 2682258Scsgr/* The percentage the number of homogeneous out-transitions of a state 2692258Scsgr * must be of the number of total out-transitions of the state in order 2702258Scsgr * to consider making a template from the state. 2712258Scsgr */ 2722258Scsgr#define TEMPLATE_SAME_PERCENTAGE 60 2732258Scsgr 2742258Scsgr/* The percentage the number of differences between a state's transition 2752258Scsgr * table and the most similar proto must be of the state's total number 2762258Scsgr * of out-transitions to create a new proto from the state. 2772258Scsgr */ 2782258Scsgr#define NEW_PROTO_DIFF_PERCENTAGE 20 2792258Scsgr 2802258Scsgr/* The percentage the total number of out-transitions of a state must be 2812258Scsgr * of the number of equivalence classes in order to consider trying to 2822258Scsgr * fit the transition table into "holes" inside the nxt/chk table. 2832258Scsgr */ 2842258Scsgr#define INTERIOR_FIT_PERCENTAGE 15 2852258Scsgr 2862258Scsgr/* Size of region set aside to cache the complete transition table of 2872258Scsgr * protos on the proto queue to enable quick comparisons. 2882258Scsgr */ 2892258Scsgr#define PROT_SAVE_SIZE 2000 2902258Scsgr 2912258Scsgr#define MSP 50 /* maximum number of saved protos (protos on the proto queue) */ 2922258Scsgr 2932258Scsgr/* Maximum number of out-transitions a state can have that we'll rummage 2942258Scsgr * around through the interior of the internal fast table looking for a 2952258Scsgr * spot for it. 2962258Scsgr */ 2972258Scsgr#define MAX_XTIONS_FULL_INTERIOR_FIT 4 2982258Scsgr 2992258Scsgr/* Maximum number of rules which will be reported as being associated 3002258Scsgr * with a DFA state. 3012258Scsgr */ 3022258Scsgr#define MAX_ASSOC_RULES 100 3032258Scsgr 3042258Scsgr/* Number that, if used to subscript an array, has a good chance of producing 3052258Scsgr * an error; should be small enough to fit into a short. 3062258Scsgr */ 3072258Scsgr#define BAD_SUBSCRIPT -32767 3082258Scsgr 3092258Scsgr/* Absolute value of largest number that can be stored in a short, with a 3102258Scsgr * bit of slop thrown in for general paranoia. 3112258Scsgr */ 3122258Scsgr#define MAX_SHORT 32700 3132258Scsgr 3142258Scsgr 3152258Scsgr/* Declarations for global variables. */ 3162258Scsgr 3172258Scsgr/* Variables for symbol tables: 3182258Scsgr * sctbl - start-condition symbol table 3192258Scsgr * ndtbl - name-definition symbol table 3202258Scsgr * ccltab - character class text symbol table 3212258Scsgr */ 3222258Scsgr 3232258Scsgrstruct hash_entry 3242258Scsgr { 3252258Scsgr struct hash_entry *prev, *next; 3262258Scsgr char *name; 3272258Scsgr char *str_val; 3282258Scsgr int int_val; 3292258Scsgr } ; 3302258Scsgr 3312258Scsgrtypedef struct hash_entry **hash_table; 3322258Scsgr 3332258Scsgr#define NAME_TABLE_HASH_SIZE 101 3342258Scsgr#define START_COND_HASH_SIZE 101 3352258Scsgr#define CCL_HASH_SIZE 101 3362258Scsgr 33716519Snateextern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE]; 3382258Scsgrextern struct hash_entry *sctbl[START_COND_HASH_SIZE]; 3392258Scsgrextern struct hash_entry *ccltab[CCL_HASH_SIZE]; 3402258Scsgr 3412258Scsgr 3422258Scsgr/* Variables for flags: 3432258Scsgr * printstats - if true (-v), dump statistics 3442258Scsgr * syntaxerror - true if a syntax error has been found 3452258Scsgr * eofseen - true if we've seen an eof in the input file 3462258Scsgr * ddebug - if true (-d), make a "debug" scanner 3472258Scsgr * trace - if true (-T), trace processing 3482258Scsgr * nowarn - if true (-w), do not generate warnings 3492258Scsgr * spprdflt - if true (-s), suppress the default rule 3502258Scsgr * interactive - if true (-I), generate an interactive scanner 3512258Scsgr * caseins - if true (-i), generate a case-insensitive scanner 3522258Scsgr * lex_compat - if true (-l), maximize compatibility with AT&T lex 35316519Snate * do_yylineno - if true, generate code to maintain yylineno 3542258Scsgr * useecs - if true (-Ce flag), use equivalence classes 3552258Scsgr * fulltbl - if true (-Cf flag), don't compress the DFA state table 3562258Scsgr * usemecs - if true (-Cm flag), use meta-equivalence classes 3572258Scsgr * fullspd - if true (-F flag), use Jacobson method of table representation 3582258Scsgr * gen_line_dirs - if true (i.e., no -L flag), generate #line directives 3592258Scsgr * performance_report - if > 0 (i.e., -p flag), generate a report relating 3602258Scsgr * to scanner performance; if > 1 (-p -p), report on minor performance 3612258Scsgr * problems, too 3622258Scsgr * backing_up_report - if true (i.e., -b flag), generate "lex.backup" file 3632258Scsgr * listing backing-up states 3642258Scsgr * C_plus_plus - if true (i.e., -+ flag), generate a C++ scanner class; 3652258Scsgr * otherwise, a standard C scanner 3662258Scsgr * long_align - if true (-Ca flag), favor long-word alignment. 3672258Scsgr * use_read - if true (-f, -F, or -Cr) then use read() for scanner input; 3682258Scsgr * otherwise, use fread(). 3692258Scsgr * yytext_is_array - if true (i.e., %array directive), then declare 3702258Scsgr * yytext as a array instead of a character pointer. Nice and inefficient. 37116519Snate * do_yywrap - do yywrap() processing on EOF. If false, EOF treated as 37216519Snate * "no more files". 3732258Scsgr * csize - size of character set for the scanner we're generating; 3742258Scsgr * 128 for 7-bit chars and 256 for 8-bit 3752258Scsgr * yymore_used - if true, yymore() is used in input rules 3762258Scsgr * reject - if true, generate back-up tables for REJECT macro 3772258Scsgr * real_reject - if true, scanner really uses REJECT (as opposed to just 3782258Scsgr * having "reject" set for variable trailing context) 3792258Scsgr * continued_action - true if this rule's action is to "fall through" to 3802258Scsgr * the next rule's action (i.e., the '|' action) 38116519Snate * in_rule - true if we're inside an individual rule, false if not. 38216519Snate * yymore_really_used - whether to treat yymore() as really used, regardless 38316519Snate * of what we think based on references to it in the user's actions. 3842258Scsgr * reject_really_used - same for REJECT 3852258Scsgr */ 3862258Scsgr 3872258Scsgrextern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt; 38816519Snateextern int interactive, caseins, lex_compat, do_yylineno; 38916519Snateextern int useecs, fulltbl, usemecs, fullspd; 39016519Snateextern int gen_line_dirs, performance_report, backing_up_report; 39116519Snateextern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap; 39216519Snateextern int csize; 39316519Snateextern int yymore_used, reject, real_reject, continued_action, in_rule; 3942258Scsgr 3952258Scsgrextern int yymore_really_used, reject_really_used; 3962258Scsgr 3972258Scsgr 3982258Scsgr/* Variables used in the flex input routines: 3992258Scsgr * datapos - characters on current output line 4002258Scsgr * dataline - number of contiguous lines of data in current data 4012258Scsgr * statement. Used to generate readable -f output 4022258Scsgr * linenum - current input line number 40316519Snate * out_linenum - current output line number 4042258Scsgr * skelfile - the skeleton file 4052258Scsgr * skel - compiled-in skeleton array 4062258Scsgr * skel_ind - index into "skel" array, if skelfile is nil 4072258Scsgr * yyin - input file 4082258Scsgr * backing_up_file - file to summarize backing-up states to 4092258Scsgr * infilename - name of input file 41016519Snate * outfilename - name of output file 41116519Snate * did_outfilename - whether outfilename was explicitly set 41216519Snate * prefix - the prefix used for externally visible names ("yy" by default) 41316519Snate * yyclass - yyFlexLexer subclass to use for YY_DECL 41416519Snate * do_stdinit - whether to initialize yyin/yyout to stdin/stdout 41516519Snate * use_stdout - the -t flag 4162258Scsgr * input_files - array holding names of input files 4172258Scsgr * num_input_files - size of input_files array 41816519Snate * program_name - name with which program was invoked 4192258Scsgr * 4202258Scsgr * action_array - array to hold the rule actions 4212258Scsgr * action_size - size of action_array 4222258Scsgr * defs1_offset - index where the user's section 1 definitions start 4232258Scsgr * in action_array 4242258Scsgr * prolog_offset - index where the prolog starts in action_array 4252258Scsgr * action_offset - index where the non-prolog starts in action_array 4262258Scsgr * action_index - index where the next action should go, with respect 4272258Scsgr * to "action_array" 4282258Scsgr */ 4292258Scsgr 43016519Snateextern int datapos, dataline, linenum, out_linenum; 4312258Scsgrextern FILE *skelfile, *yyin, *backing_up_file; 43216519Snateextern const char *skel[]; 4332258Scsgrextern int skel_ind; 43416519Snateextern char *infilename, *outfilename; 43516519Snateextern int did_outfilename; 43616519Snateextern char *prefix, *yyclass; 43716519Snateextern int do_stdinit, use_stdout; 4382258Scsgrextern char **input_files; 4392258Scsgrextern int num_input_files; 4402258Scsgrextern char *program_name; 4412258Scsgr 4422258Scsgrextern char *action_array; 4432258Scsgrextern int action_size; 4442258Scsgrextern int defs1_offset, prolog_offset, action_offset, action_index; 4452258Scsgr 4462258Scsgr 4472258Scsgr/* Variables for stack of states having only one out-transition: 4482258Scsgr * onestate - state number 4492258Scsgr * onesym - transition symbol 4502258Scsgr * onenext - target state 4512258Scsgr * onedef - default base entry 4522258Scsgr * onesp - stack pointer 4532258Scsgr */ 4542258Scsgr 4552258Scsgrextern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE]; 4562258Scsgrextern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp; 4572258Scsgr 4582258Scsgr 4592258Scsgr/* Variables for nfa machine data: 4602258Scsgr * current_mns - current maximum on number of NFA states 4612258Scsgr * num_rules - number of the last accepting state; also is number of 4622258Scsgr * rules created so far 4632258Scsgr * num_eof_rules - number of <<EOF>> rules 4642258Scsgr * default_rule - number of the default rule 4652258Scsgr * current_max_rules - current maximum number of rules 4662258Scsgr * lastnfa - last nfa state number created 4672258Scsgr * firstst - physically the first state of a fragment 4682258Scsgr * lastst - last physical state of fragment 4692258Scsgr * finalst - last logical state of fragment 4702258Scsgr * transchar - transition character 4712258Scsgr * trans1 - transition state 4722258Scsgr * trans2 - 2nd transition state for epsilons 4732258Scsgr * accptnum - accepting number 4742258Scsgr * assoc_rule - rule associated with this NFA state (or 0 if none) 4752258Scsgr * state_type - a STATE_xxx type identifying whether the state is part 4762258Scsgr * of a normal rule, the leading state in a trailing context 4772258Scsgr * rule (i.e., the state which marks the transition from 4782258Scsgr * recognizing the text-to-be-matched to the beginning of 4792258Scsgr * the trailing context), or a subsequent state in a trailing 4802258Scsgr * context rule 4812258Scsgr * rule_type - a RULE_xxx type identifying whether this a ho-hum 4822258Scsgr * normal rule or one which has variable head & trailing 4832258Scsgr * context 4842258Scsgr * rule_linenum - line number associated with rule 4852258Scsgr * rule_useful - true if we've determined that the rule can be matched 4862258Scsgr */ 4872258Scsgr 48816519Snateextern int current_mns, current_max_rules; 48916519Snateextern int num_rules, num_eof_rules, default_rule, lastnfa; 4902258Scsgrextern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2; 4912258Scsgrextern int *accptnum, *assoc_rule, *state_type; 4922258Scsgrextern int *rule_type, *rule_linenum, *rule_useful; 4932258Scsgr 4942258Scsgr/* Different types of states; values are useful as masks, as well, for 4952258Scsgr * routines like check_trailing_context(). 4962258Scsgr */ 4972258Scsgr#define STATE_NORMAL 0x1 4982258Scsgr#define STATE_TRAILING_CONTEXT 0x2 4992258Scsgr 5002258Scsgr/* Global holding current type of state we're making. */ 5012258Scsgr 5022258Scsgrextern int current_state_type; 5032258Scsgr 5042258Scsgr/* Different types of rules. */ 5052258Scsgr#define RULE_NORMAL 0 5062258Scsgr#define RULE_VARIABLE 1 5072258Scsgr 5082258Scsgr/* True if the input rules include a rule with both variable-length head 5092258Scsgr * and trailing context, false otherwise. 5102258Scsgr */ 5112258Scsgrextern int variable_trailing_context_rules; 5122258Scsgr 5132258Scsgr 5142258Scsgr/* Variables for protos: 5152258Scsgr * numtemps - number of templates created 5162258Scsgr * numprots - number of protos created 5172258Scsgr * protprev - backlink to a more-recently used proto 5182258Scsgr * protnext - forward link to a less-recently used proto 5192258Scsgr * prottbl - base/def table entry for proto 5202258Scsgr * protcomst - common state of proto 5212258Scsgr * firstprot - number of the most recently used proto 5222258Scsgr * lastprot - number of the least recently used proto 5232258Scsgr * protsave contains the entire state array for protos 5242258Scsgr */ 5252258Scsgr 5262258Scsgrextern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP]; 5272258Scsgrextern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE]; 5282258Scsgr 5292258Scsgr 5302258Scsgr/* Variables for managing equivalence classes: 5312258Scsgr * numecs - number of equivalence classes 5322258Scsgr * nextecm - forward link of Equivalence Class members 5332258Scsgr * ecgroup - class number or backward link of EC members 5342258Scsgr * nummecs - number of meta-equivalence classes (used to compress 5352258Scsgr * templates) 5362258Scsgr * tecfwd - forward link of meta-equivalence classes members 5372258Scsgr * tecbck - backward link of MEC's 5382258Scsgr */ 5392258Scsgr 5402258Scsgr/* Reserve enough room in the equivalence class arrays so that we 5412258Scsgr * can use the CSIZE'th element to hold equivalence class information 5422258Scsgr * for the NUL character. Later we'll move this information into 5432258Scsgr * the 0th element. 5442258Scsgr */ 5452258Scsgrextern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs; 5462258Scsgr 5472258Scsgr/* Meta-equivalence classes are indexed starting at 1, so it's possible 5482258Scsgr * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1 5492258Scsgr * slots total (since the arrays are 0-based). nextecm[] and ecgroup[] 5502258Scsgr * don't require the extra position since they're indexed from 1 .. CSIZE - 1. 5512258Scsgr */ 5522258Scsgrextern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1]; 5532258Scsgr 5542258Scsgr 5552258Scsgr/* Variables for start conditions: 5562258Scsgr * lastsc - last start condition created 5572258Scsgr * current_max_scs - current limit on number of start conditions 5582258Scsgr * scset - set of rules active in start condition 5592258Scsgr * scbol - set of rules active only at the beginning of line in a s.c. 5602258Scsgr * scxclu - true if start condition is exclusive 5612258Scsgr * sceof - true if start condition has EOF rule 5622258Scsgr * scname - start condition name 5632258Scsgr */ 5642258Scsgr 56516519Snateextern int lastsc, *scset, *scbol, *scxclu, *sceof; 56616519Snateextern int current_max_scs; 5672258Scsgrextern char **scname; 5682258Scsgr 5692258Scsgr 5702258Scsgr/* Variables for dfa machine data: 5712258Scsgr * current_max_dfa_size - current maximum number of NFA states in DFA 5722258Scsgr * current_max_xpairs - current maximum number of non-template xtion pairs 5732258Scsgr * current_max_template_xpairs - current maximum number of template pairs 5742258Scsgr * current_max_dfas - current maximum number DFA states 5752258Scsgr * lastdfa - last dfa state number created 5762258Scsgr * nxt - state to enter upon reading character 5772258Scsgr * chk - check value to see if "nxt" applies 5782258Scsgr * tnxt - internal nxt table for templates 5792258Scsgr * base - offset into "nxt" for given state 5802258Scsgr * def - where to go if "chk" disallows "nxt" entry 5812258Scsgr * nultrans - NUL transition for each state 5822258Scsgr * NUL_ec - equivalence class of the NUL character 5832258Scsgr * tblend - last "nxt/chk" table entry being used 5842258Scsgr * firstfree - first empty entry in "nxt/chk" table 5852258Scsgr * dss - nfa state set for each dfa 5862258Scsgr * dfasiz - size of nfa state set for each dfa 5872258Scsgr * dfaacc - accepting set for each dfa state (if using REJECT), or accepting 5882258Scsgr * number, if not 5892258Scsgr * accsiz - size of accepting set for each dfa state 5902258Scsgr * dhash - dfa state hash value 5912258Scsgr * numas - number of DFA accepting states created; note that this 5922258Scsgr * is not necessarily the same value as num_rules, which is the analogous 5932258Scsgr * value for the NFA 5942258Scsgr * numsnpairs - number of state/nextstate transition pairs 5952258Scsgr * jambase - position in base/def where the default jam table starts 5962258Scsgr * jamstate - state number corresponding to "jam" state 5972258Scsgr * end_of_buffer_state - end-of-buffer dfa state number 5982258Scsgr */ 5992258Scsgr 6002258Scsgrextern int current_max_dfa_size, current_max_xpairs; 6012258Scsgrextern int current_max_template_xpairs, current_max_dfas; 6022258Scsgrextern int lastdfa, *nxt, *chk, *tnxt; 6032258Scsgrextern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz; 6042258Scsgrextern union dfaacc_union 6052258Scsgr { 6062258Scsgr int *dfaacc_set; 6072258Scsgr int dfaacc_state; 6082258Scsgr } *dfaacc; 6092258Scsgrextern int *accsiz, *dhash, numas; 6102258Scsgrextern int numsnpairs, jambase, jamstate; 6112258Scsgrextern int end_of_buffer_state; 6122258Scsgr 6132258Scsgr/* Variables for ccl information: 6142258Scsgr * lastccl - ccl index of the last created ccl 6152258Scsgr * current_maxccls - current limit on the maximum number of unique ccl's 6162258Scsgr * cclmap - maps a ccl index to its set pointer 6172258Scsgr * ccllen - gives the length of a ccl 6182258Scsgr * cclng - true for a given ccl if the ccl is negated 6192258Scsgr * cclreuse - counts how many times a ccl is re-used 6202258Scsgr * current_max_ccl_tbl_size - current limit on number of characters needed 6212258Scsgr * to represent the unique ccl's 6222258Scsgr * ccltbl - holds the characters in each ccl - indexed by cclmap 6232258Scsgr */ 6242258Scsgr 62516519Snateextern int lastccl, *cclmap, *ccllen, *cclng, cclreuse; 62616519Snateextern int current_maxccls, current_max_ccl_tbl_size; 6272258Scsgrextern Char *ccltbl; 6282258Scsgr 6292258Scsgr 6302258Scsgr/* Variables for miscellaneous information: 6312258Scsgr * nmstr - last NAME scanned by the scanner 6322258Scsgr * sectnum - section number currently being parsed 6332258Scsgr * nummt - number of empty nxt/chk table entries 6342258Scsgr * hshcol - number of hash collisions detected by snstods 6352258Scsgr * dfaeql - number of times a newly created dfa was equal to an old one 6362258Scsgr * numeps - number of epsilon NFA states created 6372258Scsgr * eps2 - number of epsilon states which have 2 out-transitions 6382258Scsgr * num_reallocs - number of times it was necessary to realloc() a group 6392258Scsgr * of arrays 6402258Scsgr * tmpuses - number of DFA states that chain to templates 6412258Scsgr * totnst - total number of NFA states used to make DFA states 6422258Scsgr * peakpairs - peak number of transition pairs we had to store internally 6432258Scsgr * numuniq - number of unique transitions 6442258Scsgr * numdup - number of duplicate transitions 6452258Scsgr * hshsave - number of hash collisions saved by checking number of states 6462258Scsgr * num_backing_up - number of DFA states requiring backing up 6472258Scsgr * bol_needed - whether scanner needs beginning-of-line recognition 6482258Scsgr */ 6492258Scsgr 6502258Scsgrextern char nmstr[MAXLINE]; 6512258Scsgrextern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; 6522258Scsgrextern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; 6532258Scsgrextern int num_backing_up, bol_needed; 6542258Scsgr 65516519Snatevoid *allocate_array PROTO((int, size_t)); 65616519Snatevoid *reallocate_array PROTO((void*, int, size_t)); 6572258Scsgr 65816519Snatevoid *flex_alloc PROTO((size_t)); 65916519Snatevoid *flex_realloc PROTO((void*, size_t)); 6602258Scsgrvoid flex_free PROTO((void*)); 6612258Scsgr 6622258Scsgr#define allocate_integer_array(size) \ 6632258Scsgr (int *) allocate_array( size, sizeof( int ) ) 6642258Scsgr 6652258Scsgr#define reallocate_integer_array(array,size) \ 6662258Scsgr (int *) reallocate_array( (void *) array, size, sizeof( int ) ) 6672258Scsgr 6682258Scsgr#define allocate_int_ptr_array(size) \ 6692258Scsgr (int **) allocate_array( size, sizeof( int * ) ) 6702258Scsgr 6712258Scsgr#define allocate_char_ptr_array(size) \ 6722258Scsgr (char **) allocate_array( size, sizeof( char * ) ) 6732258Scsgr 6742258Scsgr#define allocate_dfaacc_union(size) \ 6752258Scsgr (union dfaacc_union *) \ 6762258Scsgr allocate_array( size, sizeof( union dfaacc_union ) ) 6772258Scsgr 6782258Scsgr#define reallocate_int_ptr_array(array,size) \ 6792258Scsgr (int **) reallocate_array( (void *) array, size, sizeof( int * ) ) 6802258Scsgr 6812258Scsgr#define reallocate_char_ptr_array(array,size) \ 6822258Scsgr (char **) reallocate_array( (void *) array, size, sizeof( char * ) ) 6832258Scsgr 6842258Scsgr#define reallocate_dfaacc_union(array, size) \ 6852258Scsgr (union dfaacc_union *) \ 6862258Scsgr reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) ) 6872258Scsgr 6882258Scsgr#define allocate_character_array(size) \ 6892258Scsgr (char *) allocate_array( size, sizeof( char ) ) 6902258Scsgr 6912258Scsgr#define reallocate_character_array(array,size) \ 6922258Scsgr (char *) reallocate_array( (void *) array, size, sizeof( char ) ) 6932258Scsgr 6942258Scsgr#define allocate_Character_array(size) \ 6952258Scsgr (Char *) allocate_array( size, sizeof( Char ) ) 6962258Scsgr 6972258Scsgr#define reallocate_Character_array(array,size) \ 6982258Scsgr (Char *) reallocate_array( (void *) array, size, sizeof( Char ) ) 6992258Scsgr 7002258Scsgr 7012258Scsgr/* Used to communicate between scanner and parser. The type should really 7022258Scsgr * be YYSTYPE, but we can't easily get our hands on it. 7032258Scsgr */ 7042258Scsgrextern int yylval; 7052258Scsgr 7062258Scsgr 7072258Scsgr/* External functions that are cross-referenced among the flex source files. */ 7082258Scsgr 7092258Scsgr 7102258Scsgr/* from file ccl.c */ 7112258Scsgr 7122258Scsgrextern void ccladd PROTO((int, int)); /* add a single character to a ccl */ 7132258Scsgrextern int cclinit PROTO((void)); /* make an empty ccl */ 7142258Scsgrextern void cclnegate PROTO((int)); /* negate a ccl */ 7152258Scsgr 7162258Scsgr/* List the members of a set of characters in CCL form. */ 7172258Scsgrextern void list_character_set PROTO((FILE*, int[])); 7182258Scsgr 7192258Scsgr 7202258Scsgr/* from file dfa.c */ 7212258Scsgr 72216519Snate/* Check a DFA state for backing up. */ 72316519Snateextern void check_for_backing_up PROTO((int, int[])); 72416519Snate 72516519Snate/* Check to see if NFA state set constitutes "dangerous" trailing context. */ 72616519Snateextern void check_trailing_context PROTO((int*, int, int*, int)); 72716519Snate 72816519Snate/* Construct the epsilon closure of a set of ndfa states. */ 72916519Snateextern int *epsclosure PROTO((int*, int*, int[], int*, int*)); 73016519Snate 7312258Scsgr/* Increase the maximum number of dfas. */ 7322258Scsgrextern void increase_max_dfas PROTO((void)); 7332258Scsgr 7342258Scsgrextern void ntod PROTO((void)); /* convert a ndfa to a dfa */ 7352258Scsgr 73616519Snate/* Converts a set of ndfa states into a dfa state. */ 73716519Snateextern int snstods PROTO((int[], int, int[], int, int, int*)); 7382258Scsgr 73916519Snate 7402258Scsgr/* from file ecs.c */ 7412258Scsgr 7422258Scsgr/* Convert character classes to set of equivalence classes. */ 7432258Scsgrextern void ccl2ecl PROTO((void)); 7442258Scsgr 7452258Scsgr/* Associate equivalence class numbers with class members. */ 7462258Scsgrextern int cre8ecs PROTO((int[], int[], int)); 7472258Scsgr 7482258Scsgr/* Update equivalence classes based on character class transitions. */ 7492258Scsgrextern void mkeccl PROTO((Char[], int, int[], int[], int, int)); 7502258Scsgr 7512258Scsgr/* Create equivalence class for single character. */ 7522258Scsgrextern void mkechar PROTO((int, int[], int[])); 7532258Scsgr 7542258Scsgr 7552258Scsgr/* from file gen.c */ 7562258Scsgr 75716519Snateextern void do_indent PROTO((void)); /* indent to the current level */ 75816519Snate 75916519Snate/* Generate the code to keep backing-up information. */ 76016519Snateextern void gen_backing_up PROTO((void)); 76116519Snate 76216519Snate/* Generate the code to perform the backing up. */ 76316519Snateextern void gen_bu_action PROTO((void)); 76416519Snate 76516519Snate/* Generate full speed compressed transition table. */ 76616519Snateextern void genctbl PROTO((void)); 76716519Snate 76816519Snate/* Generate the code to find the action number. */ 76916519Snateextern void gen_find_action PROTO((void)); 77016519Snate 77116519Snateextern void genftbl PROTO((void)); /* generate full transition table */ 77216519Snate 77316519Snate/* Generate the code to find the next compressed-table state. */ 77416519Snateextern void gen_next_compressed_state PROTO((char*)); 77516519Snate 77616519Snate/* Generate the code to find the next match. */ 77716519Snateextern void gen_next_match PROTO((void)); 77816519Snate 77916519Snate/* Generate the code to find the next state. */ 78016519Snateextern void gen_next_state PROTO((int)); 78116519Snate 78216519Snate/* Generate the code to make a NUL transition. */ 78316519Snateextern void gen_NUL_trans PROTO((void)); 78416519Snate 78516519Snate/* Generate the code to find the start state. */ 78616519Snateextern void gen_start_state PROTO((void)); 78716519Snate 78816519Snate/* Generate data statements for the transition tables. */ 78916519Snateextern void gentabs PROTO((void)); 79016519Snate 79116519Snate/* Write out a formatted string at the current indentation level. */ 79216519Snateextern void indent_put2s PROTO((char[], char[])); 79316519Snate 79416519Snate/* Write out a string + newline at the current indentation level. */ 79516519Snateextern void indent_puts PROTO((char[])); 79616519Snate 7972258Scsgrextern void make_tables PROTO((void)); /* generate transition tables */ 7982258Scsgr 7992258Scsgr 8002258Scsgr/* from file main.c */ 8012258Scsgr 80216519Snateextern void check_options PROTO((void)); 8032258Scsgrextern void flexend PROTO((int)); 8042258Scsgrextern void usage PROTO((void)); 8052258Scsgr 8062258Scsgr 8072258Scsgr/* from file misc.c */ 8082258Scsgr 80916519Snate/* Add a #define to the action file. */ 81016519Snateextern void action_define PROTO(( char *defname, int value )); 81116519Snate 8122258Scsgr/* Add the given text to the stored actions. */ 8132258Scsgrextern void add_action PROTO(( char *new_text )); 8142258Scsgr 8152258Scsgr/* True if a string is all lower case. */ 8162258Scsgrextern int all_lower PROTO((register char *)); 8172258Scsgr 8182258Scsgr/* True if a string is all upper case. */ 8192258Scsgrextern int all_upper PROTO((register char *)); 8202258Scsgr 8212258Scsgr/* Bubble sort an integer array. */ 8222258Scsgrextern void bubble PROTO((int [], int)); 8232258Scsgr 8242258Scsgr/* Check a character to make sure it's in the expected range. */ 8252258Scsgrextern void check_char PROTO((int c)); 8262258Scsgr 82716519Snate/* Replace upper-case letter to lower-case. */ 82816519Snateextern Char clower PROTO((int)); 82916519Snate 83016519Snate/* Returns a dynamically allocated copy of a string. */ 83116519Snateextern char *copy_string PROTO((register const char *)); 83216519Snate 83316519Snate/* Returns a dynamically allocated copy of a (potentially) unsigned string. */ 83416519Snateextern Char *copy_unsigned_string PROTO((register Char *)); 83516519Snate 8362258Scsgr/* Shell sort a character array. */ 8372258Scsgrextern void cshell PROTO((Char [], int, int)); 8382258Scsgr 8392258Scsgr/* Finish up a block of data declarations. */ 8402258Scsgrextern void dataend PROTO((void)); 8412258Scsgr 84216519Snate/* Flush generated data statements. */ 84316519Snateextern void dataflush PROTO((void)); 84416519Snate 8452258Scsgr/* Report an error message and terminate. */ 84616519Snateextern void flexerror PROTO((const char[])); 8472258Scsgr 8482258Scsgr/* Report a fatal error message and terminate. */ 84916519Snateextern void flexfatal PROTO((const char[])); 8502258Scsgr 85116519Snate/* Convert a hexadecimal digit string to an integer value. */ 85216519Snateextern int htoi PROTO((Char[])); 85316519Snate 8542258Scsgr/* Report an error message formatted with one integer argument. */ 85516519Snateextern void lerrif PROTO((const char[], int)); 8562258Scsgr 8572258Scsgr/* Report an error message formatted with one string argument. */ 85816519Snateextern void lerrsf PROTO((const char[], const char[])); 8592258Scsgr 86016519Snate/* Spit out a "#line" statement. */ 86116519Snateextern void line_directive_out PROTO((FILE*, int)); 8622258Scsgr 8632258Scsgr/* Mark the current position in the action array as the end of the section 1 8642258Scsgr * user defs. 8652258Scsgr */ 8662258Scsgrextern void mark_defs1 PROTO((void)); 8672258Scsgr 8682258Scsgr/* Mark the current position in the action array as the end of the prolog. */ 8692258Scsgrextern void mark_prolog PROTO((void)); 8702258Scsgr 8712258Scsgr/* Generate a data statment for a two-dimensional array. */ 8722258Scsgrextern void mk2data PROTO((int)); 8732258Scsgr 8742258Scsgrextern void mkdata PROTO((int)); /* generate a data statement */ 8752258Scsgr 8762258Scsgr/* Return the integer represented by a string of digits. */ 8772258Scsgrextern int myctoi PROTO((char [])); 8782258Scsgr 87916519Snate/* Return character corresponding to escape sequence. */ 88016519Snateextern Char myesc PROTO((Char[])); 88116519Snate 88216519Snate/* Convert an octal digit string to an integer value. */ 88316519Snateextern int otoi PROTO((Char [] )); 88416519Snate 88516519Snate/* Output a (possibly-formatted) string to the generated scanner. */ 88616519Snateextern void out PROTO((const char [])); 88716519Snateextern void out_dec PROTO((const char [], int)); 88816519Snateextern void out_dec2 PROTO((const char [], int, int)); 88916519Snateextern void out_hex PROTO((const char [], unsigned int)); 89016519Snateextern void out_line_count PROTO((const char [])); 89116519Snateextern void out_str PROTO((const char [], const char [])); 89216519Snateextern void out_str3 89316519Snate PROTO((const char [], const char [], const char [], const char [])); 89416519Snateextern void out_str_dec PROTO((const char [], const char [], int)); 89516519Snateextern void outc PROTO((int)); 89616519Snateextern void outn PROTO((const char [])); 89716519Snate 8982258Scsgr/* Return a printable version of the given character, which might be 8992258Scsgr * 8-bit. 9002258Scsgr */ 9012258Scsgrextern char *readable_form PROTO((int)); 9022258Scsgr 9032258Scsgr/* Write out one section of the skeleton file. */ 9042258Scsgrextern void skelout PROTO((void)); 9052258Scsgr 9062258Scsgr/* Output a yy_trans_info structure. */ 9072258Scsgrextern void transition_struct_out PROTO((int, int)); 9082258Scsgr 9092258Scsgr/* Only needed when using certain broken versions of bison to build parse.c. */ 9102258Scsgrextern void *yy_flex_xmalloc PROTO(( int )); 9112258Scsgr 9122258Scsgr/* Set a region of memory to 0. */ 91316519Snateextern void zero_out PROTO((char *, size_t)); 9142258Scsgr 9152258Scsgr 9162258Scsgr/* from file nfa.c */ 9172258Scsgr 9182258Scsgr/* Add an accepting state to a machine. */ 9192258Scsgrextern void add_accept PROTO((int, int)); 9202258Scsgr 9212258Scsgr/* Make a given number of copies of a singleton machine. */ 9222258Scsgrextern int copysingl PROTO((int, int)); 9232258Scsgr 9242258Scsgr/* Debugging routine to write out an nfa. */ 9252258Scsgrextern void dumpnfa PROTO((int)); 9262258Scsgr 9272258Scsgr/* Finish up the processing for a rule. */ 9282258Scsgrextern void finish_rule PROTO((int, int, int, int)); 9292258Scsgr 9302258Scsgr/* Connect two machines together. */ 9312258Scsgrextern int link_machines PROTO((int, int)); 9322258Scsgr 9332258Scsgr/* Mark each "beginning" state in a machine as being a "normal" (i.e., 9342258Scsgr * not trailing context associated) state. 9352258Scsgr */ 9362258Scsgrextern void mark_beginning_as_normal PROTO((register int)); 9372258Scsgr 9382258Scsgr/* Make a machine that branches to two machines. */ 9392258Scsgrextern int mkbranch PROTO((int, int)); 9402258Scsgr 9412258Scsgrextern int mkclos PROTO((int)); /* convert a machine into a closure */ 9422258Scsgrextern int mkopt PROTO((int)); /* make a machine optional */ 9432258Scsgr 9442258Scsgr/* Make a machine that matches either one of two machines. */ 9452258Scsgrextern int mkor PROTO((int, int)); 9462258Scsgr 9472258Scsgr/* Convert a machine into a positive closure. */ 9482258Scsgrextern int mkposcl PROTO((int)); 9492258Scsgr 9502258Scsgrextern int mkrep PROTO((int, int, int)); /* make a replicated machine */ 9512258Scsgr 9522258Scsgr/* Create a state with a transition on a given symbol. */ 9532258Scsgrextern int mkstate PROTO((int)); 9542258Scsgr 9552258Scsgrextern void new_rule PROTO((void)); /* initialize for a new rule */ 9562258Scsgr 9572258Scsgr 9582258Scsgr/* from file parse.y */ 9592258Scsgr 96016519Snate/* Build the "<<EOF>>" action for the active start conditions. */ 96116519Snateextern void build_eof_action PROTO((void)); 96216519Snate 9632258Scsgr/* Write out a message formatted with one string, pinpointing its location. */ 9642258Scsgrextern void format_pinpoint_message PROTO((char[], char[])); 9652258Scsgr 9662258Scsgr/* Write out a message, pinpointing its location. */ 9672258Scsgrextern void pinpoint_message PROTO((char[])); 9682258Scsgr 9692258Scsgr/* Write out a warning, pinpointing it at the given line. */ 97016519Snateextern void line_warning PROTO(( char[], int )); 9712258Scsgr 9722258Scsgr/* Write out a message, pinpointing it at the given line. */ 97316519Snateextern void line_pinpoint PROTO(( char[], int )); 9742258Scsgr 9752258Scsgr/* Report a formatted syntax error. */ 9762258Scsgrextern void format_synerr PROTO((char [], char[])); 9772258Scsgrextern void synerr PROTO((char [])); /* report a syntax error */ 97816519Snateextern void format_warn PROTO((char [], char[])); 9792258Scsgrextern void warn PROTO((char [])); /* report a warning */ 98016519Snateextern void yyerror PROTO((char [])); /* report a parse error */ 9812258Scsgrextern int yyparse PROTO((void)); /* the YACC parser */ 9822258Scsgr 9832258Scsgr 9842258Scsgr/* from file scan.l */ 9852258Scsgr 9862258Scsgr/* The Flex-generated scanner for flex. */ 9872258Scsgrextern int flexscan PROTO((void)); 9882258Scsgr 9892258Scsgr/* Open the given file (if NULL, stdin) for scanning. */ 9902258Scsgrextern void set_input_file PROTO((char*)); 9912258Scsgr 9922258Scsgr/* Wrapup a file in the lexical analyzer. */ 9932258Scsgrextern int yywrap PROTO((void)); 9942258Scsgr 9952258Scsgr 9962258Scsgr/* from file sym.c */ 9972258Scsgr 99816519Snate/* Add symbol and definitions to symbol table. */ 99916519Snateextern int addsym PROTO((register char[], char*, int, hash_table, int)); 100016519Snate 10012258Scsgr/* Save the text of a character class. */ 10022258Scsgrextern void cclinstal PROTO ((Char [], int)); 10032258Scsgr 10042258Scsgr/* Lookup the number associated with character class. */ 10052258Scsgrextern int ccllookup PROTO((Char [])); 10062258Scsgr 100716519Snate/* Find symbol in symbol table. */ 100816519Snateextern struct hash_entry *findsym PROTO((register char[], hash_table, int )); 100916519Snate 10102258Scsgrextern void ndinstal PROTO((char[], Char[])); /* install a name definition */ 101116519Snateextern Char *ndlookup PROTO((char[])); /* lookup a name definition */ 101216519Snate 10132258Scsgr/* Increase maximum number of SC's. */ 10142258Scsgrextern void scextend PROTO((void)); 10152258Scsgrextern void scinstal PROTO((char[], int)); /* make a start condition */ 10162258Scsgr 10172258Scsgr/* Lookup the number associated with a start condition. */ 10182258Scsgrextern int sclookup PROTO((char[])); 10192258Scsgr 10202258Scsgr 10212258Scsgr/* from file tblcmp.c */ 10222258Scsgr 10232258Scsgr/* Build table entries for dfa state. */ 10242258Scsgrextern void bldtbl PROTO((int[], int, int, int, int)); 10252258Scsgr 10262258Scsgrextern void cmptmps PROTO((void)); /* compress template table entries */ 10272258Scsgrextern void expand_nxt_chk PROTO((void)); /* increase nxt/chk arrays */ 102816519Snate/* Finds a space in the table for a state to be placed. */ 102916519Snateextern int find_table_space PROTO((int*, int)); 10302258Scsgrextern void inittbl PROTO((void)); /* initialize transition tables */ 10312258Scsgr/* Make the default, "jam" table entries. */ 10322258Scsgrextern void mkdeftbl PROTO((void)); 10332258Scsgr 10342258Scsgr/* Create table entries for a state (or state fragment) which has 10352258Scsgr * only one out-transition. 10362258Scsgr */ 10372258Scsgrextern void mk1tbl PROTO((int, int, int, int)); 10382258Scsgr 10392258Scsgr/* Place a state into full speed transition table. */ 10402258Scsgrextern void place_state PROTO((int*, int, int)); 10412258Scsgr 10422258Scsgr/* Save states with only one out-transition to be processed later. */ 10432258Scsgrextern void stack1 PROTO((int, int, int, int)); 10442258Scsgr 10452258Scsgr 10462258Scsgr/* from file yylex.c */ 10472258Scsgr 10482258Scsgrextern int yylex PROTO((void)); 1049