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