Finish the import and merge in FreeBSD specific changes.
Add a 'bootstrap' target which *must* be run before building the new version, since the new scanner relies on the current version of flex to build itself otherwise.
This commit is contained in:
parent
036346c9c7
commit
693e59976b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=16519
@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.3 1996/01/08 09:17:39 peter Exp $
|
||||
# $Id: Makefile,v 1.4 1996/05/07 23:19:47 wosch Exp $
|
||||
#
|
||||
# By default, flex will be configured to generate 8-bit scanners only if the
|
||||
# -8 flag is given. If you want it to always generate 8-bit scanners, add
|
||||
@ -19,7 +19,7 @@ SRCS= ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.y \
|
||||
OBJS+= scan.o
|
||||
LFLAGS+= -is
|
||||
CFLAGS+= -I. -I${.CURDIR}
|
||||
MAN1= lex.1 lexdoc.1
|
||||
MAN1= lex.1
|
||||
MLINKS+= lex.1 flex.1
|
||||
MLINKS+= lex.1 flex++.1
|
||||
MLINKS+= lex.1 lex++.1
|
||||
@ -40,17 +40,12 @@ parse.c parse.h: parse.y
|
||||
mv -f y.tab.c parse.c
|
||||
mv -f y.tab.h parse.h
|
||||
|
||||
.if exists(/usr/bin/lex)
|
||||
scan.o: parse.c
|
||||
.else
|
||||
# We must bootstrap
|
||||
scan.o: scan.c parse.h
|
||||
|
||||
scan.c:
|
||||
bootstrap: initscan.c
|
||||
@echo "Bootstrapping flex"
|
||||
@rm -f scan.c
|
||||
@cp -pf ${.CURDIR}/initscan.c scan.c
|
||||
.endif
|
||||
@cp -f ${.CURDIR}/initscan.c scan.c
|
||||
|
||||
scan.o: parse.c
|
||||
|
||||
test: check
|
||||
check: $(PROG)
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
@ -26,7 +26,7 @@
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/ccl.c,v 1.1.1.1 1994/08/24 13:10:33 csgr Exp $ */
|
||||
/* $Header: /home/daffy/u0/vern/flex/RCS/ccl.c,v 2.9 93/09/16 20:32:14 vern Exp $ */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
@ -26,7 +26,7 @@
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/dfa.c,v 1.1.1.1 1994/08/24 13:10:33 csgr Exp $ */
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/dfa.c,v 1.1.1.2 1996/06/19 20:26:04 nate Exp $ */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
@ -60,7 +60,7 @@ int state[];
|
||||
if ( backing_up_report )
|
||||
{
|
||||
fprintf( backing_up_file,
|
||||
"State #%d is non-accepting -\n", ds );
|
||||
_( "State #%d is non-accepting -\n" ), ds );
|
||||
|
||||
/* identify the state */
|
||||
dump_associated_rules( backing_up_file, ds );
|
||||
@ -101,7 +101,7 @@ int state[];
|
||||
void check_trailing_context( nfa_states, num_states, accset, nacc )
|
||||
int *nfa_states, num_states;
|
||||
int *accset;
|
||||
register int nacc;
|
||||
int nacc;
|
||||
{
|
||||
register int i, j;
|
||||
|
||||
@ -127,7 +127,7 @@ register int nacc;
|
||||
if ( accset[j] & YY_TRAILING_HEAD_MASK )
|
||||
{
|
||||
line_warning(
|
||||
"dangerous trailing context",
|
||||
_( "dangerous trailing context" ),
|
||||
rule_linenum[ar] );
|
||||
return;
|
||||
}
|
||||
@ -170,7 +170,7 @@ int ds;
|
||||
|
||||
bubble( rule_set, num_associated_rules );
|
||||
|
||||
fprintf( file, " associated rule line numbers:" );
|
||||
fprintf( file, _( " associated rule line numbers:" ) );
|
||||
|
||||
for ( i = 1; i <= num_associated_rules; ++i )
|
||||
{
|
||||
@ -208,7 +208,7 @@ int state[];
|
||||
out_char_set[i] = state[ec];
|
||||
}
|
||||
|
||||
fprintf( file, " out-transitions: " );
|
||||
fprintf( file, _( " out-transitions: " ) );
|
||||
|
||||
list_character_set( file, out_char_set );
|
||||
|
||||
@ -216,7 +216,7 @@ int state[];
|
||||
for ( i = 0; i < csize; ++i )
|
||||
out_char_set[i] = ! out_char_set[i];
|
||||
|
||||
fprintf( file, "\n jam-transitions: EOF " );
|
||||
fprintf( file, _( "\n jam-transitions: EOF " ) );
|
||||
|
||||
list_character_set( file, out_char_set );
|
||||
|
||||
@ -250,7 +250,7 @@ int *t, *ns_addr, accset[], *nacc_addr, *hv_addr;
|
||||
register int stkpos, ns, tsp;
|
||||
int numstates = *ns_addr, nacc, hashval, transsym, nfaccnum;
|
||||
int stkend, nstate;
|
||||
static int did_stk_init = false, *stk;
|
||||
static int did_stk_init = false, *stk;
|
||||
|
||||
#define MARK_STATE(state) \
|
||||
trans1[state] = trans1[state] - MARKER_DIFFERENCE;
|
||||
@ -352,7 +352,8 @@ ADD_STATE(state) \
|
||||
if ( IS_MARKED(stk[stkpos]) )
|
||||
UNMARK_STATE(stk[stkpos])
|
||||
else
|
||||
flexfatal( "consistency check failed in epsclosure()" );
|
||||
flexfatal(
|
||||
_( "consistency check failed in epsclosure()" ) );
|
||||
}
|
||||
|
||||
*ns_addr = numstates;
|
||||
@ -398,7 +399,7 @@ void ntod()
|
||||
int num_full_table_rows; /* used only for -f */
|
||||
int *nset, *dset;
|
||||
int targptr, totaltrans, i, comstate, comfreq, targ;
|
||||
int *epsclosure(), snstods(), symlist[CSIZE + 1];
|
||||
int symlist[CSIZE + 1];
|
||||
int num_start_states;
|
||||
int todo_head, todo_next;
|
||||
|
||||
@ -435,7 +436,7 @@ void ntod()
|
||||
if ( trace )
|
||||
{
|
||||
dumpnfa( scset[1] );
|
||||
fputs( "\n\nDFA Dump:\n\n", stderr );
|
||||
fputs( _( "\n\nDFA Dump:\n\n" ), stderr );
|
||||
}
|
||||
|
||||
inittbl();
|
||||
@ -510,7 +511,7 @@ void ntod()
|
||||
state[i] = 0;
|
||||
|
||||
place_state( state, 0, 0 );
|
||||
dfaacc[i].dfaacc_state = 0;
|
||||
dfaacc[0].dfaacc_state = 0;
|
||||
}
|
||||
|
||||
else if ( fulltbl )
|
||||
@ -531,19 +532,18 @@ void ntod()
|
||||
/* Unless -Ca, declare it "short" because it's a real
|
||||
* long-shot that that won't be large enough.
|
||||
*/
|
||||
printf( "static const %s yy_nxt[][%d] =\n {\n",
|
||||
out_str_dec( "static yyconst %s yy_nxt[][%d] =\n {\n",
|
||||
/* '}' so vi doesn't get too confused */
|
||||
long_align ? "long" : "short", num_full_table_rows );
|
||||
|
||||
outn( " {" );
|
||||
|
||||
/* Generate 0 entries for state #0. */
|
||||
for ( i = 0; i < num_full_table_rows; ++i )
|
||||
mk2data( 0 );
|
||||
|
||||
/* Force ',' and dataflush() next call to mk2data().*/
|
||||
datapos = NUMDATAITEMS;
|
||||
|
||||
/* Force extra blank line next dataflush(). */
|
||||
dataline = NUMDATALINES;
|
||||
dataflush();
|
||||
outn( " },\n" );
|
||||
}
|
||||
|
||||
/* Create the first states. */
|
||||
@ -582,7 +582,7 @@ void ntod()
|
||||
{
|
||||
if ( ! snstods( nset, 0, accset, 0, 0, &end_of_buffer_state ) )
|
||||
flexfatal(
|
||||
"could not create unique end-of-buffer state" );
|
||||
_( "could not create unique end-of-buffer state" ) );
|
||||
|
||||
++numas;
|
||||
++num_start_states;
|
||||
@ -603,7 +603,7 @@ void ntod()
|
||||
dsize = dfasiz[ds];
|
||||
|
||||
if ( trace )
|
||||
fprintf( stderr, "state # %d:\n", ds );
|
||||
fprintf( stderr, _( "state # %d:\n" ), ds );
|
||||
|
||||
sympartition( dset, dsize, symlist, duplist );
|
||||
|
||||
@ -677,16 +677,26 @@ void ntod()
|
||||
}
|
||||
}
|
||||
|
||||
numsnpairs = numsnpairs + totaltrans;
|
||||
|
||||
if ( caseins && ! useecs )
|
||||
{
|
||||
register int j;
|
||||
|
||||
for ( i = 'A', j = 'a'; i <= 'Z'; ++i, ++j )
|
||||
{
|
||||
if ( state[i] == 0 && state[j] != 0 )
|
||||
/* We're adding a transition. */
|
||||
++totaltrans;
|
||||
|
||||
else if ( state[i] != 0 && state[j] == 0 )
|
||||
/* We're taking away a transition. */
|
||||
--totaltrans;
|
||||
|
||||
state[i] = state[j];
|
||||
}
|
||||
}
|
||||
|
||||
numsnpairs += totaltrans;
|
||||
|
||||
if ( ds > num_start_states )
|
||||
check_for_backing_up( ds, state );
|
||||
|
||||
@ -698,6 +708,8 @@ void ntod()
|
||||
|
||||
if ( fulltbl )
|
||||
{
|
||||
outn( " {" );
|
||||
|
||||
/* Supply array's 0-element. */
|
||||
if ( ds == end_of_buffer_state )
|
||||
mk2data( -end_of_buffer_state );
|
||||
@ -710,11 +722,8 @@ void ntod()
|
||||
*/
|
||||
mk2data( state[i] ? state[i] : -ds );
|
||||
|
||||
/* Force ',' and dataflush() next call to mk2data().*/
|
||||
datapos = NUMDATAITEMS;
|
||||
|
||||
/* Force extra blank line next dataflush(). */
|
||||
dataline = NUMDATALINES;
|
||||
dataflush();
|
||||
outn( " },\n" );
|
||||
}
|
||||
|
||||
else if ( fullspd )
|
||||
@ -977,7 +986,8 @@ int ds[], dsize, transsym, nset[];
|
||||
}
|
||||
|
||||
else if ( sym >= 'A' && sym <= 'Z' && caseins )
|
||||
flexfatal( "consistency check failed in symfollowset" );
|
||||
flexfatal(
|
||||
_( "consistency check failed in symfollowset" ) );
|
||||
|
||||
else if ( sym == SYM_EPSILON )
|
||||
{ /* do nothing */
|
||||
@ -1030,7 +1040,7 @@ int symlist[], duplist[];
|
||||
if ( tch < -lastccl || tch >= csize )
|
||||
{
|
||||
flexfatal(
|
||||
"bad transition character detected in sympartition()" );
|
||||
_( "bad transition character detected in sympartition()" ) );
|
||||
}
|
||||
|
||||
if ( tch >= 0 )
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
@ -26,7 +26,7 @@
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/ecs.c,v 1.1.1.1 1994/08/24 13:10:33 csgr Exp $ */
|
||||
/* $Header: /home/daffy/u0/vern/flex/RCS/ecs.c,v 2.9 93/12/07 10:18:20 vern Exp $ */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
@ -26,21 +26,50 @@
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* @(#) $Header: /home/ncvs/src/usr.bin/lex/flexdef.h,v 1.1.1.1 1994/08/24 13:10:32 csgr Exp $ (LBL) */
|
||||
/* @(#) $Header: /home/ncvs/src/usr.bin/lex/flexdef.h,v 1.1.1.2 1996/06/19 20:26:08 nate Exp $ (LBL) */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if HAVE_STRING_H
|
||||
#include "config.h"
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#define HAVE_STRING_H 1
|
||||
#define MS_DOS 1
|
||||
#ifndef __STDC__
|
||||
#define __STDC__ 1
|
||||
#endif
|
||||
#pragma warn -pro
|
||||
#pragma warn -rch
|
||||
#pragma warn -use
|
||||
#pragma warn -aus
|
||||
#pragma warn -par
|
||||
#pragma warn -pia
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#if __STDC__
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/* As an aid for the internationalization patch to flex, which
|
||||
* is maintained outside this distribution for copyright reasons.
|
||||
*/
|
||||
#define _(String) (String)
|
||||
|
||||
/* Always be prepared to generate an 8-bit scanner. */
|
||||
#define CSIZE 256
|
||||
#define Char unsigned char
|
||||
@ -51,7 +80,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef PROTO
|
||||
#ifdef __STDC__
|
||||
#if __STDC__
|
||||
#define PROTO(proto) proto
|
||||
#else
|
||||
#define PROTO(proto) ()
|
||||
@ -59,9 +88,11 @@
|
||||
#endif
|
||||
|
||||
#ifdef VMS
|
||||
#define unlink delete
|
||||
#ifndef __VMS_POSIX
|
||||
#define unlink remove
|
||||
#define SHORT_FILE_NAMES
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MS_DOS
|
||||
#define SHORT_FILE_NAMES
|
||||
@ -90,6 +121,7 @@
|
||||
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define unspecified -1
|
||||
|
||||
|
||||
/* Special chk[] values marking the slots taking by end-of-buffer and action
|
||||
@ -106,8 +138,8 @@
|
||||
*/
|
||||
#define NUMDATALINES 10
|
||||
|
||||
/* Transition_struct_out() definitions. */
|
||||
#define TRANS_STRUCT_PRINT_LENGTH 15
|
||||
/* transition_struct_out() definitions. */
|
||||
#define TRANS_STRUCT_PRINT_LENGTH 14
|
||||
|
||||
/* Returns true if an nfa state has an epsilon out-transition slot
|
||||
* that can be used. This definition is currently not used.
|
||||
@ -180,11 +212,13 @@
|
||||
|
||||
#define JAMSTATE -32766 /* marks a reference to the state that always jams */
|
||||
|
||||
/* Maximum number of NFA states. */
|
||||
#define MAXIMUM_MNS 31999
|
||||
|
||||
/* Enough so that if it's subtracted from an NFA state number, the result
|
||||
* is guaranteed to be negative.
|
||||
*/
|
||||
#define MARKER_DIFFERENCE 32000
|
||||
#define MAXIMUM_MNS 31999
|
||||
#define MARKER_DIFFERENCE (MAXIMUM_MNS+2)
|
||||
|
||||
/* Maximum number of nxt/chk pairs for non-templates. */
|
||||
#define INITIAL_MAX_XPAIRS 2000
|
||||
@ -212,7 +246,7 @@
|
||||
|
||||
/* The percentage the number of homogeneous out-transitions of a state
|
||||
* must be of the number of total out-transitions of the state in order
|
||||
* that the state's transition table is first compared with a potential
|
||||
* that the state's transition table is first compared with a potential
|
||||
* template of the most common out-transition instead of with the first
|
||||
* proto in the proto queue.
|
||||
*/
|
||||
@ -300,7 +334,7 @@ typedef struct hash_entry **hash_table;
|
||||
#define START_COND_HASH_SIZE 101
|
||||
#define CCL_HASH_SIZE 101
|
||||
|
||||
extern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE];
|
||||
extern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE];
|
||||
extern struct hash_entry *sctbl[START_COND_HASH_SIZE];
|
||||
extern struct hash_entry *ccltab[CCL_HASH_SIZE];
|
||||
|
||||
@ -316,6 +350,7 @@ extern struct hash_entry *ccltab[CCL_HASH_SIZE];
|
||||
* interactive - if true (-I), generate an interactive scanner
|
||||
* caseins - if true (-i), generate a case-insensitive scanner
|
||||
* lex_compat - if true (-l), maximize compatibility with AT&T lex
|
||||
* do_yylineno - if true, generate code to maintain yylineno
|
||||
* useecs - if true (-Ce flag), use equivalence classes
|
||||
* fulltbl - if true (-Cf flag), don't compress the DFA state table
|
||||
* usemecs - if true (-Cm flag), use meta-equivalence classes
|
||||
@ -333,6 +368,8 @@ extern struct hash_entry *ccltab[CCL_HASH_SIZE];
|
||||
* otherwise, use fread().
|
||||
* yytext_is_array - if true (i.e., %array directive), then declare
|
||||
* yytext as a array instead of a character pointer. Nice and inefficient.
|
||||
* do_yywrap - do yywrap() processing on EOF. If false, EOF treated as
|
||||
* "no more files".
|
||||
* csize - size of character set for the scanner we're generating;
|
||||
* 128 for 7-bit chars and 256 for 8-bit
|
||||
* yymore_used - if true, yymore() is used in input rules
|
||||
@ -341,20 +378,20 @@ extern struct hash_entry *ccltab[CCL_HASH_SIZE];
|
||||
* having "reject" set for variable trailing context)
|
||||
* continued_action - true if this rule's action is to "fall through" to
|
||||
* the next rule's action (i.e., the '|' action)
|
||||
* yymore_really_used - has a REALLY_xxx value indicating whether a
|
||||
* %used or %notused was used with yymore()
|
||||
* in_rule - true if we're inside an individual rule, false if not.
|
||||
* yymore_really_used - whether to treat yymore() as really used, regardless
|
||||
* of what we think based on references to it in the user's actions.
|
||||
* reject_really_used - same for REJECT
|
||||
*/
|
||||
|
||||
extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt;
|
||||
extern int interactive, caseins, lex_compat, useecs, fulltbl, usemecs;
|
||||
extern int fullspd, gen_line_dirs, performance_report, backing_up_report;
|
||||
extern int C_plus_plus, long_align, use_read, yytext_is_array, csize;
|
||||
extern int yymore_used, reject, real_reject, continued_action;
|
||||
extern int interactive, caseins, lex_compat, do_yylineno;
|
||||
extern int useecs, fulltbl, usemecs, fullspd;
|
||||
extern int gen_line_dirs, performance_report, backing_up_report;
|
||||
extern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap;
|
||||
extern int csize;
|
||||
extern int yymore_used, reject, real_reject, continued_action, in_rule;
|
||||
|
||||
#define REALLY_NOT_DETERMINED 0
|
||||
#define REALLY_USED 1
|
||||
#define REALLY_NOT_USED 2
|
||||
extern int yymore_really_used, reject_really_used;
|
||||
|
||||
|
||||
@ -363,15 +400,22 @@ extern int yymore_really_used, reject_really_used;
|
||||
* dataline - number of contiguous lines of data in current data
|
||||
* statement. Used to generate readable -f output
|
||||
* linenum - current input line number
|
||||
* out_linenum - current output line number
|
||||
* skelfile - the skeleton file
|
||||
* skel - compiled-in skeleton array
|
||||
* skel_ind - index into "skel" array, if skelfile is nil
|
||||
* yyin - input file
|
||||
* backing_up_file - file to summarize backing-up states to
|
||||
* infilename - name of input file
|
||||
* outfilename - name of output file
|
||||
* did_outfilename - whether outfilename was explicitly set
|
||||
* prefix - the prefix used for externally visible names ("yy" by default)
|
||||
* yyclass - yyFlexLexer subclass to use for YY_DECL
|
||||
* do_stdinit - whether to initialize yyin/yyout to stdin/stdout
|
||||
* use_stdout - the -t flag
|
||||
* input_files - array holding names of input files
|
||||
* num_input_files - size of input_files array
|
||||
* program_name - name with which program was invoked
|
||||
* program_name - name with which program was invoked
|
||||
*
|
||||
* action_array - array to hold the rule actions
|
||||
* action_size - size of action_array
|
||||
@ -383,11 +427,14 @@ extern int yymore_really_used, reject_really_used;
|
||||
* to "action_array"
|
||||
*/
|
||||
|
||||
extern int datapos, dataline, linenum;
|
||||
extern int datapos, dataline, linenum, out_linenum;
|
||||
extern FILE *skelfile, *yyin, *backing_up_file;
|
||||
extern char *skel[];
|
||||
extern const char *skel[];
|
||||
extern int skel_ind;
|
||||
extern char *infilename;
|
||||
extern char *infilename, *outfilename;
|
||||
extern int did_outfilename;
|
||||
extern char *prefix, *yyclass;
|
||||
extern int do_stdinit, use_stdout;
|
||||
extern char **input_files;
|
||||
extern int num_input_files;
|
||||
extern char *program_name;
|
||||
@ -438,8 +485,8 @@ extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
|
||||
* rule_useful - true if we've determined that the rule can be matched
|
||||
*/
|
||||
|
||||
extern int current_mns, num_rules, num_eof_rules, default_rule;
|
||||
extern int current_max_rules, lastnfa;
|
||||
extern int current_mns, current_max_rules;
|
||||
extern int num_rules, num_eof_rules, default_rule, lastnfa;
|
||||
extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
|
||||
extern int *accptnum, *assoc_rule, *state_type;
|
||||
extern int *rule_type, *rule_linenum, *rule_useful;
|
||||
@ -513,16 +560,10 @@ extern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
|
||||
* scxclu - true if start condition is exclusive
|
||||
* sceof - true if start condition has EOF rule
|
||||
* scname - start condition name
|
||||
* actvsc - stack of active start conditions for the current rule;
|
||||
* a negative entry means that the start condition is *not*
|
||||
* active for the current rule. Start conditions may appear
|
||||
* multiple times on the stack; the entry for it closest
|
||||
* to the top of the stack (i.e., actvsc[actvp]) is the
|
||||
* one to use. Others are present from "<sc>{" scoping
|
||||
* constructs.
|
||||
*/
|
||||
|
||||
extern int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc;
|
||||
extern int lastsc, *scset, *scbol, *scxclu, *sceof;
|
||||
extern int current_max_scs;
|
||||
extern char **scname;
|
||||
|
||||
|
||||
@ -581,8 +622,8 @@ extern int end_of_buffer_state;
|
||||
* ccltbl - holds the characters in each ccl - indexed by cclmap
|
||||
*/
|
||||
|
||||
extern int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse;
|
||||
extern int current_max_ccl_tbl_size;
|
||||
extern int lastccl, *cclmap, *ccllen, *cclng, cclreuse;
|
||||
extern int current_maxccls, current_max_ccl_tbl_size;
|
||||
extern Char *ccltbl;
|
||||
|
||||
|
||||
@ -611,11 +652,11 @@ extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
|
||||
extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
|
||||
extern int num_backing_up, bol_needed;
|
||||
|
||||
void *allocate_array PROTO((int, int));
|
||||
void *reallocate_array PROTO((void*, int, int));
|
||||
void *allocate_array PROTO((int, size_t));
|
||||
void *reallocate_array PROTO((void*, int, size_t));
|
||||
|
||||
void *flex_alloc PROTO((unsigned int));
|
||||
void *flex_realloc PROTO((void*, unsigned int));
|
||||
void *flex_alloc PROTO((size_t));
|
||||
void *flex_realloc PROTO((void*, size_t));
|
||||
void flex_free PROTO((void*));
|
||||
|
||||
#define allocate_integer_array(size) \
|
||||
@ -678,11 +719,23 @@ extern void list_character_set PROTO((FILE*, int[]));
|
||||
|
||||
/* from file dfa.c */
|
||||
|
||||
/* Check a DFA state for backing up. */
|
||||
extern void check_for_backing_up PROTO((int, int[]));
|
||||
|
||||
/* Check to see if NFA state set constitutes "dangerous" trailing context. */
|
||||
extern void check_trailing_context PROTO((int*, int, int*, int));
|
||||
|
||||
/* Construct the epsilon closure of a set of ndfa states. */
|
||||
extern int *epsclosure PROTO((int*, int*, int[], int*, int*));
|
||||
|
||||
/* Increase the maximum number of dfas. */
|
||||
extern void increase_max_dfas PROTO((void));
|
||||
|
||||
extern void ntod PROTO((void)); /* convert a ndfa to a dfa */
|
||||
|
||||
/* Converts a set of ndfa states into a dfa state. */
|
||||
extern int snstods PROTO((int[], int, int[], int, int, int*));
|
||||
|
||||
|
||||
/* from file ecs.c */
|
||||
|
||||
@ -701,17 +754,61 @@ extern void mkechar PROTO((int, int[], int[]));
|
||||
|
||||
/* from file gen.c */
|
||||
|
||||
extern void do_indent PROTO((void)); /* indent to the current level */
|
||||
|
||||
/* Generate the code to keep backing-up information. */
|
||||
extern void gen_backing_up PROTO((void));
|
||||
|
||||
/* Generate the code to perform the backing up. */
|
||||
extern void gen_bu_action PROTO((void));
|
||||
|
||||
/* Generate full speed compressed transition table. */
|
||||
extern void genctbl PROTO((void));
|
||||
|
||||
/* Generate the code to find the action number. */
|
||||
extern void gen_find_action PROTO((void));
|
||||
|
||||
extern void genftbl PROTO((void)); /* generate full transition table */
|
||||
|
||||
/* Generate the code to find the next compressed-table state. */
|
||||
extern void gen_next_compressed_state PROTO((char*));
|
||||
|
||||
/* Generate the code to find the next match. */
|
||||
extern void gen_next_match PROTO((void));
|
||||
|
||||
/* Generate the code to find the next state. */
|
||||
extern void gen_next_state PROTO((int));
|
||||
|
||||
/* Generate the code to make a NUL transition. */
|
||||
extern void gen_NUL_trans PROTO((void));
|
||||
|
||||
/* Generate the code to find the start state. */
|
||||
extern void gen_start_state PROTO((void));
|
||||
|
||||
/* Generate data statements for the transition tables. */
|
||||
extern void gentabs PROTO((void));
|
||||
|
||||
/* Write out a formatted string at the current indentation level. */
|
||||
extern void indent_put2s PROTO((char[], char[]));
|
||||
|
||||
/* Write out a string + newline at the current indentation level. */
|
||||
extern void indent_puts PROTO((char[]));
|
||||
|
||||
extern void make_tables PROTO((void)); /* generate transition tables */
|
||||
|
||||
|
||||
/* from file main.c */
|
||||
|
||||
extern void check_options PROTO((void));
|
||||
extern void flexend PROTO((int));
|
||||
extern void usage PROTO((void));
|
||||
|
||||
|
||||
/* from file misc.c */
|
||||
|
||||
/* Add a #define to the action file. */
|
||||
extern void action_define PROTO(( char *defname, int value ));
|
||||
|
||||
/* Add the given text to the stored actions. */
|
||||
extern void add_action PROTO(( char *new_text ));
|
||||
|
||||
@ -727,26 +824,41 @@ extern void bubble PROTO((int [], int));
|
||||
/* Check a character to make sure it's in the expected range. */
|
||||
extern void check_char PROTO((int c));
|
||||
|
||||
/* Replace upper-case letter to lower-case. */
|
||||
extern Char clower PROTO((int));
|
||||
|
||||
/* Returns a dynamically allocated copy of a string. */
|
||||
extern char *copy_string PROTO((register const char *));
|
||||
|
||||
/* Returns a dynamically allocated copy of a (potentially) unsigned string. */
|
||||
extern Char *copy_unsigned_string PROTO((register Char *));
|
||||
|
||||
/* Shell sort a character array. */
|
||||
extern void cshell PROTO((Char [], int, int));
|
||||
|
||||
/* Finish up a block of data declarations. */
|
||||
extern void dataend PROTO((void));
|
||||
|
||||
/* Flush generated data statements. */
|
||||
extern void dataflush PROTO((void));
|
||||
|
||||
/* Report an error message and terminate. */
|
||||
extern void flexerror PROTO((char[]));
|
||||
extern void flexerror PROTO((const char[]));
|
||||
|
||||
/* Report a fatal error message and terminate. */
|
||||
extern void flexfatal PROTO((char[]));
|
||||
extern void flexfatal PROTO((const char[]));
|
||||
|
||||
/* Convert a hexadecimal digit string to an integer value. */
|
||||
extern int htoi PROTO((Char[]));
|
||||
|
||||
/* Report an error message formatted with one integer argument. */
|
||||
extern void lerrif PROTO((char[], int));
|
||||
extern void lerrif PROTO((const char[], int));
|
||||
|
||||
/* Report an error message formatted with one string argument. */
|
||||
extern void lerrsf PROTO((char[], char[]));
|
||||
extern void lerrsf PROTO((const char[], const char[]));
|
||||
|
||||
/* Spit out a "# line" statement. */
|
||||
extern void line_directive_out PROTO((FILE*));
|
||||
/* Spit out a "#line" statement. */
|
||||
extern void line_directive_out PROTO((FILE*, int));
|
||||
|
||||
/* Mark the current position in the action array as the end of the section 1
|
||||
* user defs.
|
||||
@ -764,6 +876,25 @@ extern void mkdata PROTO((int)); /* generate a data statement */
|
||||
/* Return the integer represented by a string of digits. */
|
||||
extern int myctoi PROTO((char []));
|
||||
|
||||
/* Return character corresponding to escape sequence. */
|
||||
extern Char myesc PROTO((Char[]));
|
||||
|
||||
/* Convert an octal digit string to an integer value. */
|
||||
extern int otoi PROTO((Char [] ));
|
||||
|
||||
/* Output a (possibly-formatted) string to the generated scanner. */
|
||||
extern void out PROTO((const char []));
|
||||
extern void out_dec PROTO((const char [], int));
|
||||
extern void out_dec2 PROTO((const char [], int, int));
|
||||
extern void out_hex PROTO((const char [], unsigned int));
|
||||
extern void out_line_count PROTO((const char []));
|
||||
extern void out_str PROTO((const char [], const char []));
|
||||
extern void out_str3
|
||||
PROTO((const char [], const char [], const char [], const char []));
|
||||
extern void out_str_dec PROTO((const char [], const char [], int));
|
||||
extern void outc PROTO((int));
|
||||
extern void outn PROTO((const char []));
|
||||
|
||||
/* Return a printable version of the given character, which might be
|
||||
* 8-bit.
|
||||
*/
|
||||
@ -779,7 +910,7 @@ extern void transition_struct_out PROTO((int, int));
|
||||
extern void *yy_flex_xmalloc PROTO(( int ));
|
||||
|
||||
/* Set a region of memory to 0. */
|
||||
extern void zero_out PROTO((char *, int));
|
||||
extern void zero_out PROTO((char *, size_t));
|
||||
|
||||
|
||||
/* from file nfa.c */
|
||||
@ -826,6 +957,9 @@ extern void new_rule PROTO((void)); /* initialize for a new rule */
|
||||
|
||||
/* from file parse.y */
|
||||
|
||||
/* Build the "<<EOF>>" action for the active start conditions. */
|
||||
extern void build_eof_action PROTO((void));
|
||||
|
||||
/* Write out a message formatted with one string, pinpointing its location. */
|
||||
extern void format_pinpoint_message PROTO((char[], char[]));
|
||||
|
||||
@ -833,15 +967,17 @@ extern void format_pinpoint_message PROTO((char[], char[]));
|
||||
extern void pinpoint_message PROTO((char[]));
|
||||
|
||||
/* Write out a warning, pinpointing it at the given line. */
|
||||
void line_warning PROTO(( char[], int ));
|
||||
extern void line_warning PROTO(( char[], int ));
|
||||
|
||||
/* Write out a message, pinpointing it at the given line. */
|
||||
void line_pinpoint PROTO(( char[], int ));
|
||||
extern void line_pinpoint PROTO(( char[], int ));
|
||||
|
||||
/* Report a formatted syntax error. */
|
||||
extern void format_synerr PROTO((char [], char[]));
|
||||
extern void synerr PROTO((char [])); /* report a syntax error */
|
||||
extern void format_warn PROTO((char [], char[]));
|
||||
extern void warn PROTO((char [])); /* report a warning */
|
||||
extern void yyerror PROTO((char [])); /* report a parse error */
|
||||
extern int yyparse PROTO((void)); /* the YACC parser */
|
||||
|
||||
|
||||
@ -859,13 +995,21 @@ extern int yywrap PROTO((void));
|
||||
|
||||
/* from file sym.c */
|
||||
|
||||
/* Add symbol and definitions to symbol table. */
|
||||
extern int addsym PROTO((register char[], char*, int, hash_table, int));
|
||||
|
||||
/* Save the text of a character class. */
|
||||
extern void cclinstal PROTO ((Char [], int));
|
||||
|
||||
/* Lookup the number associated with character class. */
|
||||
extern int ccllookup PROTO((Char []));
|
||||
|
||||
/* Find symbol in symbol table. */
|
||||
extern struct hash_entry *findsym PROTO((register char[], hash_table, int ));
|
||||
|
||||
extern void ndinstal PROTO((char[], Char[])); /* install a name definition */
|
||||
extern Char *ndlookup PROTO((char[])); /* lookup a name definition */
|
||||
|
||||
/* Increase maximum number of SC's. */
|
||||
extern void scextend PROTO((void));
|
||||
extern void scinstal PROTO((char[], int)); /* make a start condition */
|
||||
@ -881,6 +1025,8 @@ extern void bldtbl PROTO((int[], int, int, int, int));
|
||||
|
||||
extern void cmptmps PROTO((void)); /* compress template table entries */
|
||||
extern void expand_nxt_chk PROTO((void)); /* increase nxt/chk arrays */
|
||||
/* Finds a space in the table for a state to be placed. */
|
||||
extern int find_table_space PROTO((int*, int));
|
||||
extern void inittbl PROTO((void)); /* initialize transition tables */
|
||||
/* Make the default, "jam" table entries. */
|
||||
extern void mkdeftbl PROTO((void));
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
4237
usr.bin/lex/lex.1
4237
usr.bin/lex/lex.1
File diff suppressed because it is too large
Load Diff
3045
usr.bin/lex/lexdoc.1
3045
usr.bin/lex/lexdoc.1
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
@ -26,16 +26,27 @@
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/misc.c,v 1.1.1.1 1994/08/24 13:10:32 csgr Exp $ */
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/misc.c,v 1.1.1.2 1996/06/19 20:26:19 nate Exp $ */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
|
||||
void action_define( defname, value )
|
||||
char *defname;
|
||||
int value;
|
||||
{
|
||||
char buf[MAXLINE];
|
||||
|
||||
/* declare functions that have forward references */
|
||||
if ( (int) strlen( defname ) > MAXLINE / 2 )
|
||||
{
|
||||
format_pinpoint_message( _( "name \"%s\" ridiculously long" ),
|
||||
defname );
|
||||
return;
|
||||
}
|
||||
|
||||
void dataflush PROTO((void));
|
||||
int otoi PROTO((Char []));
|
||||
sprintf( buf, "#define %s %d\n", defname, value );
|
||||
add_action( buf );
|
||||
}
|
||||
|
||||
|
||||
void add_action( new_text )
|
||||
@ -45,7 +56,16 @@ char *new_text;
|
||||
|
||||
while ( len + action_index >= action_size - 10 /* slop */ )
|
||||
{
|
||||
action_size *= 2;
|
||||
int new_size = action_size * 2;
|
||||
|
||||
if ( new_size <= 0 )
|
||||
/* Increase just a little, to try to avoid overflow
|
||||
* on 16-bit machines.
|
||||
*/
|
||||
action_size += action_size / 8;
|
||||
else
|
||||
action_size = new_size;
|
||||
|
||||
action_array =
|
||||
reallocate_character_array( action_array, action_size );
|
||||
}
|
||||
@ -59,21 +79,16 @@ char *new_text;
|
||||
/* allocate_array - allocate memory for an integer array of the given size */
|
||||
|
||||
void *allocate_array( size, element_size )
|
||||
int size, element_size;
|
||||
int size;
|
||||
size_t element_size;
|
||||
{
|
||||
register void *mem;
|
||||
size_t num_bytes = element_size * size;
|
||||
|
||||
/* On 16-bit int machines (e.g., 80286) we might be trying to
|
||||
* allocate more than a signed int can hold, and that won't
|
||||
* work. Cheap test:
|
||||
*/
|
||||
if ( element_size * size <= 0 )
|
||||
flexfatal( "request for < 1 byte in allocate_array()" );
|
||||
|
||||
mem = flex_alloc( element_size * size );
|
||||
|
||||
if ( mem == NULL )
|
||||
flexfatal( "memory allocation failed in allocate_array()" );
|
||||
mem = flex_alloc( num_bytes );
|
||||
if ( ! mem )
|
||||
flexfatal(
|
||||
_( "memory allocation failed in allocate_array()" ) );
|
||||
|
||||
return mem;
|
||||
}
|
||||
@ -151,11 +166,12 @@ void check_char( c )
|
||||
int c;
|
||||
{
|
||||
if ( c >= CSIZE )
|
||||
lerrsf( "bad character '%s' detected in check_char()",
|
||||
lerrsf( _( "bad character '%s' detected in check_char()" ),
|
||||
readable_form( c ) );
|
||||
|
||||
if ( c >= csize )
|
||||
lerrsf( "scanner requires -8 flag to use the character '%s'",
|
||||
lerrsf(
|
||||
_( "scanner requires -8 flag to use the character %s" ),
|
||||
readable_form( c ) );
|
||||
}
|
||||
|
||||
@ -173,21 +189,24 @@ register int c;
|
||||
/* copy_string - returns a dynamically allocated copy of a string */
|
||||
|
||||
char *copy_string( str )
|
||||
register char *str;
|
||||
register const char *str;
|
||||
{
|
||||
register char *c;
|
||||
register const char *c1;
|
||||
register char *c2;
|
||||
char *copy;
|
||||
unsigned int size;
|
||||
|
||||
/* find length */
|
||||
for ( c = str; *c; ++c )
|
||||
for ( c1 = str; *c1; ++c1 )
|
||||
;
|
||||
|
||||
copy = (char *) flex_alloc( (c - str + 1) * sizeof( char ) );
|
||||
size = (c1 - str + 1) * sizeof( char );
|
||||
copy = (char *) flex_alloc( size );
|
||||
|
||||
if ( copy == NULL )
|
||||
flexfatal( "dynamic memory failure in copy_string()" );
|
||||
flexfatal( _( "dynamic memory failure in copy_string()" ) );
|
||||
|
||||
for ( c = copy; (*c++ = *str++); )
|
||||
for ( c2 = copy; (*c2++ = *str++) != 0; )
|
||||
;
|
||||
|
||||
return copy;
|
||||
@ -210,7 +229,7 @@ register Char *str;
|
||||
|
||||
copy = allocate_Character_array( c - str + 1 );
|
||||
|
||||
for ( c = copy; (*c++ = *str++); )
|
||||
for ( c = copy; (*c++ = *str++) != 0; )
|
||||
;
|
||||
|
||||
return copy;
|
||||
@ -275,7 +294,7 @@ void dataend()
|
||||
dataflush();
|
||||
|
||||
/* add terminator for initialization; { for vi */
|
||||
puts( " } ;\n" );
|
||||
outn( " } ;\n" );
|
||||
|
||||
dataline = 0;
|
||||
datapos = 0;
|
||||
@ -286,14 +305,14 @@ void dataend()
|
||||
|
||||
void dataflush()
|
||||
{
|
||||
putchar( '\n' );
|
||||
outc( '\n' );
|
||||
|
||||
if ( ++dataline >= NUMDATALINES )
|
||||
{
|
||||
/* Put out a blank line so that the table is grouped into
|
||||
* large blocks that enable the user to find elements easily.
|
||||
*/
|
||||
putchar( '\n' );
|
||||
outc( '\n' );
|
||||
dataline = 0;
|
||||
}
|
||||
|
||||
@ -305,7 +324,7 @@ void dataflush()
|
||||
/* flexerror - report an error message and terminate */
|
||||
|
||||
void flexerror( msg )
|
||||
char msg[];
|
||||
const char msg[];
|
||||
{
|
||||
fprintf( stderr, "%s: %s\n", program_name, msg );
|
||||
flexend( 1 );
|
||||
@ -315,37 +334,14 @@ char msg[];
|
||||
/* flexfatal - report a fatal error message and terminate */
|
||||
|
||||
void flexfatal( msg )
|
||||
char msg[];
|
||||
const char msg[];
|
||||
{
|
||||
fprintf( stderr, "%s: fatal internal error, %s\n", program_name, msg );
|
||||
fprintf( stderr, _( "%s: fatal internal error, %s\n" ),
|
||||
program_name, msg );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
|
||||
/* lerrif - report an error message formatted with one integer argument */
|
||||
|
||||
void lerrif( msg, arg )
|
||||
char msg[];
|
||||
int arg;
|
||||
{
|
||||
char errmsg[MAXLINE];
|
||||
(void) sprintf( errmsg, msg, arg );
|
||||
flexerror( errmsg );
|
||||
}
|
||||
|
||||
|
||||
/* lerrsf - report an error message formatted with one string argument */
|
||||
|
||||
void lerrsf( msg, arg )
|
||||
char msg[], arg[];
|
||||
{
|
||||
char errmsg[MAXLINE];
|
||||
|
||||
(void) sprintf( errmsg, msg, arg );
|
||||
flexerror( errmsg );
|
||||
}
|
||||
|
||||
|
||||
/* htoi - convert a hexadecimal digit string to an integer value */
|
||||
|
||||
int htoi( str )
|
||||
@ -359,50 +355,82 @@ Char str[];
|
||||
}
|
||||
|
||||
|
||||
/* is_hex_digit - returns true if a character is a valid hex digit, false
|
||||
* otherwise
|
||||
*/
|
||||
/* lerrif - report an error message formatted with one integer argument */
|
||||
|
||||
int is_hex_digit( ch )
|
||||
int ch;
|
||||
void lerrif( msg, arg )
|
||||
const char msg[];
|
||||
int arg;
|
||||
{
|
||||
if ( isdigit( ch ) )
|
||||
return 1;
|
||||
|
||||
switch ( clower( ch ) )
|
||||
{
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'd':
|
||||
case 'e':
|
||||
case 'f':
|
||||
return 1;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
char errmsg[MAXLINE];
|
||||
(void) sprintf( errmsg, msg, arg );
|
||||
flexerror( errmsg );
|
||||
}
|
||||
|
||||
|
||||
/* line_directive_out - spit out a "# line" statement */
|
||||
/* lerrsf - report an error message formatted with one string argument */
|
||||
|
||||
void line_directive_out( output_file )
|
||||
FILE *output_file;
|
||||
void lerrsf( msg, arg )
|
||||
const char msg[], arg[];
|
||||
{
|
||||
if ( infilename && gen_line_dirs )
|
||||
{
|
||||
char directive[MAXLINE];
|
||||
sprintf( directive, "# line %d \"%s\"\n", linenum, infilename );
|
||||
char errmsg[MAXLINE];
|
||||
|
||||
/* If output_file is nil then we should put the directive in
|
||||
* the accumulated actions.
|
||||
*/
|
||||
if ( output_file )
|
||||
fputs( directive, output_file );
|
||||
else
|
||||
add_action( directive );
|
||||
(void) sprintf( errmsg, msg, arg );
|
||||
flexerror( errmsg );
|
||||
}
|
||||
|
||||
|
||||
/* line_directive_out - spit out a "#line" statement */
|
||||
|
||||
void line_directive_out( output_file, do_infile )
|
||||
FILE *output_file;
|
||||
int do_infile;
|
||||
{
|
||||
char directive[MAXLINE], filename[MAXLINE];
|
||||
char *s1, *s2, *s3;
|
||||
static char line_fmt[] = "#line %d \"%s\"\n";
|
||||
|
||||
if ( ! gen_line_dirs )
|
||||
return;
|
||||
|
||||
if ( (do_infile && ! infilename) || (! do_infile && ! outfilename) )
|
||||
/* don't know the filename to use, skip */
|
||||
return;
|
||||
|
||||
s1 = do_infile ? infilename : outfilename;
|
||||
s2 = filename;
|
||||
s3 = &filename[sizeof( filename ) - 2];
|
||||
|
||||
while ( s2 < s3 && *s1 )
|
||||
{
|
||||
if ( *s1 == '\\' )
|
||||
/* Escape the '\' */
|
||||
*s2++ = '\\';
|
||||
|
||||
*s2++ = *s1++;
|
||||
}
|
||||
|
||||
*s2 = '\0';
|
||||
|
||||
if ( do_infile )
|
||||
sprintf( directive, line_fmt, linenum, filename );
|
||||
else
|
||||
{
|
||||
if ( output_file == stdout )
|
||||
/* Account for the line directive itself. */
|
||||
++out_linenum;
|
||||
|
||||
sprintf( directive, line_fmt, out_linenum, filename );
|
||||
}
|
||||
|
||||
/* If output_file is nil then we should put the directive in
|
||||
* the accumulated actions.
|
||||
*/
|
||||
if ( output_file )
|
||||
{
|
||||
fputs( directive, output_file );
|
||||
}
|
||||
else
|
||||
add_action( directive );
|
||||
}
|
||||
|
||||
|
||||
@ -439,20 +467,20 @@ int value;
|
||||
{
|
||||
if ( datapos >= NUMDATAITEMS )
|
||||
{
|
||||
putchar( ',' );
|
||||
outc( ',' );
|
||||
dataflush();
|
||||
}
|
||||
|
||||
if ( datapos == 0 )
|
||||
/* Indent. */
|
||||
fputs( " ", stdout );
|
||||
out( " " );
|
||||
|
||||
else
|
||||
putchar( ',' );
|
||||
outc( ',' );
|
||||
|
||||
++datapos;
|
||||
|
||||
printf( "%5d", value );
|
||||
out_dec( "%5d", value );
|
||||
}
|
||||
|
||||
|
||||
@ -466,19 +494,19 @@ int value;
|
||||
{
|
||||
if ( datapos >= NUMDATAITEMS )
|
||||
{
|
||||
putchar( ',' );
|
||||
outc( ',' );
|
||||
dataflush();
|
||||
}
|
||||
|
||||
if ( datapos == 0 )
|
||||
/* Indent. */
|
||||
fputs( " ", stdout );
|
||||
out( " " );
|
||||
else
|
||||
putchar( ',' );
|
||||
outc( ',' );
|
||||
|
||||
++datapos;
|
||||
|
||||
printf( "%5d", value );
|
||||
out_dec( "%5d", value );
|
||||
}
|
||||
|
||||
|
||||
@ -510,7 +538,7 @@ Char array[];
|
||||
case 'r': return '\r';
|
||||
case 't': return '\t';
|
||||
|
||||
#ifdef __STDC__
|
||||
#if __STDC__
|
||||
case 'a': return '\a';
|
||||
case 'v': return '\v';
|
||||
#else
|
||||
@ -526,8 +554,6 @@ Char array[];
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
{ /* \<octal> */
|
||||
int sptr = 1;
|
||||
|
||||
@ -554,7 +580,7 @@ Char array[];
|
||||
int sptr = 2;
|
||||
|
||||
while ( isascii( array[sptr] ) &&
|
||||
is_hex_digit( (char) array[sptr] ) )
|
||||
isxdigit( (char) array[sptr] ) )
|
||||
/* Don't increment inside loop control
|
||||
* because if isdigit() is a macro it might
|
||||
* expand into multiple increments ...
|
||||
@ -589,6 +615,96 @@ Char str[];
|
||||
}
|
||||
|
||||
|
||||
/* out - various flavors of outputing a (possibly formatted) string for the
|
||||
* generated scanner, keeping track of the line count.
|
||||
*/
|
||||
|
||||
void out( str )
|
||||
const char str[];
|
||||
{
|
||||
fputs( str, stdout );
|
||||
out_line_count( str );
|
||||
}
|
||||
|
||||
void out_dec( fmt, n )
|
||||
const char fmt[];
|
||||
int n;
|
||||
{
|
||||
printf( fmt, n );
|
||||
out_line_count( fmt );
|
||||
}
|
||||
|
||||
void out_dec2( fmt, n1, n2 )
|
||||
const char fmt[];
|
||||
int n1, n2;
|
||||
{
|
||||
printf( fmt, n1, n2 );
|
||||
out_line_count( fmt );
|
||||
}
|
||||
|
||||
void out_hex( fmt, x )
|
||||
const char fmt[];
|
||||
unsigned int x;
|
||||
{
|
||||
printf( fmt, x );
|
||||
out_line_count( fmt );
|
||||
}
|
||||
|
||||
void out_line_count( str )
|
||||
const char str[];
|
||||
{
|
||||
register int i;
|
||||
|
||||
for ( i = 0; str[i]; ++i )
|
||||
if ( str[i] == '\n' )
|
||||
++out_linenum;
|
||||
}
|
||||
|
||||
void out_str( fmt, str )
|
||||
const char fmt[], str[];
|
||||
{
|
||||
printf( fmt, str );
|
||||
out_line_count( fmt );
|
||||
out_line_count( str );
|
||||
}
|
||||
|
||||
void out_str3( fmt, s1, s2, s3 )
|
||||
const char fmt[], s1[], s2[], s3[];
|
||||
{
|
||||
printf( fmt, s1, s2, s3 );
|
||||
out_line_count( fmt );
|
||||
out_line_count( s1 );
|
||||
out_line_count( s2 );
|
||||
out_line_count( s3 );
|
||||
}
|
||||
|
||||
void out_str_dec( fmt, str, n )
|
||||
const char fmt[], str[];
|
||||
int n;
|
||||
{
|
||||
printf( fmt, str, n );
|
||||
out_line_count( fmt );
|
||||
out_line_count( str );
|
||||
}
|
||||
|
||||
void outc( c )
|
||||
int c;
|
||||
{
|
||||
putc( c, stdout );
|
||||
|
||||
if ( c == '\n' )
|
||||
++out_linenum;
|
||||
}
|
||||
|
||||
void outn( str )
|
||||
const char str[];
|
||||
{
|
||||
puts( str );
|
||||
out_line_count( str );
|
||||
++out_linenum;
|
||||
}
|
||||
|
||||
|
||||
/* readable_form - return the the human-readable form of a character
|
||||
*
|
||||
* The returned string is in static storage.
|
||||
@ -609,7 +725,7 @@ register int c;
|
||||
case '\r': return "\\r";
|
||||
case '\t': return "\\t";
|
||||
|
||||
#ifdef __STDC__
|
||||
#if __STDC__
|
||||
case '\a': return "\\a";
|
||||
case '\v': return "\\v";
|
||||
#endif
|
||||
@ -638,19 +754,15 @@ register int c;
|
||||
|
||||
void *reallocate_array( array, size, element_size )
|
||||
void *array;
|
||||
int size, element_size;
|
||||
int size;
|
||||
size_t element_size;
|
||||
{
|
||||
register void *new_array;
|
||||
size_t num_bytes = element_size * size;
|
||||
|
||||
/* Same worry as in allocate_array(): */
|
||||
if ( size * element_size <= 0 )
|
||||
flexfatal(
|
||||
"attempt to increase array size by less than 1 byte" );
|
||||
|
||||
new_array = flex_realloc( array, size * element_size );
|
||||
|
||||
if ( new_array == NULL )
|
||||
flexfatal( "attempt to increase array size failed" );
|
||||
new_array = flex_realloc( array, num_bytes );
|
||||
if ( ! new_array )
|
||||
flexfatal( _( "attempt to increase array size failed" ) );
|
||||
|
||||
return new_array;
|
||||
}
|
||||
@ -673,7 +785,7 @@ void skelout()
|
||||
*/
|
||||
while ( skelfile ?
|
||||
(fgets( buf, MAXLINE, skelfile ) != NULL) :
|
||||
((buf = skel[skel_ind++]) != 0) )
|
||||
((buf = (char *) skel[skel_ind++]) != 0) )
|
||||
{ /* copy from skel array */
|
||||
if ( buf[0] == '%' )
|
||||
{ /* control line */
|
||||
@ -696,7 +808,7 @@ void skelout()
|
||||
|
||||
default:
|
||||
flexfatal(
|
||||
"bad line in skeleton file" );
|
||||
_( "bad line in skeleton file" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -706,9 +818,9 @@ void skelout()
|
||||
/* Skeleton file reads include final
|
||||
* newline, skel[] array does not.
|
||||
*/
|
||||
fputs( buf, stdout );
|
||||
out( buf );
|
||||
else
|
||||
printf( "%s\n", buf );
|
||||
outn( buf );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -723,16 +835,16 @@ void skelout()
|
||||
void transition_struct_out( element_v, element_n )
|
||||
int element_v, element_n;
|
||||
{
|
||||
printf( "%7d, %5d,", element_v, element_n );
|
||||
out_dec2( " {%4d,%4d },", element_v, element_n );
|
||||
|
||||
datapos += TRANS_STRUCT_PRINT_LENGTH;
|
||||
|
||||
if ( datapos >= 75 )
|
||||
if ( datapos >= 79 - TRANS_STRUCT_PRINT_LENGTH )
|
||||
{
|
||||
putchar( '\n' );
|
||||
outc( '\n' );
|
||||
|
||||
if ( ++dataline % 10 == 0 )
|
||||
putchar( '\n' );
|
||||
outc( '\n' );
|
||||
|
||||
datapos = 0;
|
||||
}
|
||||
@ -745,10 +857,11 @@ int element_v, element_n;
|
||||
void *yy_flex_xmalloc( size )
|
||||
int size;
|
||||
{
|
||||
void *result = flex_alloc( size );
|
||||
void *result = flex_alloc( (size_t) size );
|
||||
|
||||
if ( ! result )
|
||||
flexfatal( "memory allocation failed in yy_flex_xmalloc()" );
|
||||
flexfatal(
|
||||
_( "memory allocation failed in yy_flex_xmalloc()" ) );
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -761,7 +874,7 @@ int size;
|
||||
|
||||
void zero_out( region_ptr, size_in_bytes )
|
||||
char *region_ptr;
|
||||
int size_in_bytes;
|
||||
size_t size_in_bytes;
|
||||
{
|
||||
register char *rp, *rp_end;
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
@ -26,7 +26,7 @@
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/nfa.c,v 1.1.1.1 1994/08/24 13:10:32 csgr Exp $ */
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/nfa.c,v 1.1.1.2 1996/06/19 20:26:24 nate Exp $ */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
@ -97,7 +97,7 @@ int state1;
|
||||
int sym, tsp1, tsp2, anum, ns;
|
||||
|
||||
fprintf( stderr,
|
||||
"\n\n********** beginning dump of nfa with start state %d\n",
|
||||
_( "\n\n********** beginning dump of nfa with start state %d\n" ),
|
||||
state1 );
|
||||
|
||||
/* We probably should loop starting at firstst[state1] and going to
|
||||
@ -109,7 +109,7 @@ int state1;
|
||||
/* for ( ns = firstst[state1]; ns <= lastst[state1]; ++ns ) */
|
||||
for ( ns = 1; ns <= lastnfa; ++ns )
|
||||
{
|
||||
fprintf( stderr, "state # %4d\t", ns );
|
||||
fprintf( stderr, _( "state # %4d\t" ), ns );
|
||||
|
||||
sym = transchar[ns];
|
||||
tsp1 = trans1[ns];
|
||||
@ -124,7 +124,7 @@ int state1;
|
||||
fprintf( stderr, "\n" );
|
||||
}
|
||||
|
||||
fprintf( stderr, "********** end of dump\n" );
|
||||
fprintf( stderr, _( "********** end of dump\n" ) );
|
||||
}
|
||||
|
||||
|
||||
@ -170,7 +170,7 @@ int mach;
|
||||
}
|
||||
|
||||
if ( state == 0 )
|
||||
flexfatal( "empty machine in dupmachine()" );
|
||||
flexfatal( _( "empty machine in dupmachine()" ) );
|
||||
|
||||
state_offset = state - i + 1;
|
||||
|
||||
@ -222,7 +222,7 @@ int mach, variable_trail_rule, headcnt, trailcnt;
|
||||
|
||||
if ( performance_report > 0 )
|
||||
fprintf( stderr,
|
||||
"Variable trailing context rule at line %d\n",
|
||||
_( "Variable trailing context rule at line %d\n" ),
|
||||
rule_linenum[num_rules] );
|
||||
|
||||
variable_trailing_context_rules = true;
|
||||
@ -265,12 +265,12 @@ int mach, variable_trail_rule, headcnt, trailcnt;
|
||||
/* Okay, in the action code at this point yytext and yyleng have
|
||||
* their proper final values for this rule, so here's the point
|
||||
* to do any user action. But don't do it for continued actions,
|
||||
* as that'll result in multiple YY_USER_ACTION's.
|
||||
* as that'll result in multiple YY_RULE_SETUP's.
|
||||
*/
|
||||
if ( ! continued_action )
|
||||
add_action( "YY_USER_ACTION\n" );
|
||||
add_action( "YY_RULE_SETUP\n" );
|
||||
|
||||
line_directive_out( (FILE *) 0 );
|
||||
line_directive_out( (FILE *) 0, 1 );
|
||||
}
|
||||
|
||||
|
||||
@ -344,7 +344,7 @@ register int mach;
|
||||
|
||||
default:
|
||||
flexerror(
|
||||
"bad state type in mark_beginning_as_normal()" );
|
||||
_( "bad state type in mark_beginning_as_normal()" ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -597,7 +597,7 @@ int sym;
|
||||
{
|
||||
if ( (current_mns += MNS_INCREMENT) >= MAXIMUM_MNS )
|
||||
lerrif(
|
||||
"input rules are too complicated (>= %d NFA states)",
|
||||
_( "input rules are too complicated (>= %d NFA states)" ),
|
||||
current_mns );
|
||||
|
||||
++num_reallocs;
|
||||
@ -676,7 +676,7 @@ int statefrom, stateto;
|
||||
|
||||
else if ( (transchar[statefrom] != SYM_EPSILON) ||
|
||||
(trans2[statefrom] != NO_TRANSITION) )
|
||||
flexfatal( "found too many transitions in mkxtion()" );
|
||||
flexfatal( _( "found too many transitions in mkxtion()" ) );
|
||||
|
||||
else
|
||||
{ /* second out-transition for an epsilon state */
|
||||
@ -702,7 +702,7 @@ void new_rule()
|
||||
}
|
||||
|
||||
if ( num_rules > MAX_RULE )
|
||||
lerrif( "too many rules (> %d)!", MAX_RULE );
|
||||
lerrif( _( "too many rules (> %d)!" ), MAX_RULE );
|
||||
|
||||
rule_linenum[num_rules] = linenum;
|
||||
rule_useful[num_rules] = false;
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
@ -26,7 +26,7 @@
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/sym.c,v 1.1.1.1 1994/08/24 13:10:31 csgr Exp $ */
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/sym.c,v 1.1.1.2 1996/06/19 20:26:39 nate Exp $ */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
@ -75,9 +75,9 @@ int table_size;
|
||||
flex_alloc( sizeof( struct hash_entry ) );
|
||||
|
||||
if ( new_entry == NULL )
|
||||
flexfatal( "symbol table memory allocation failed" );
|
||||
flexfatal( _( "symbol table memory allocation failed" ) );
|
||||
|
||||
if ( (successor = table[hash_val]) )
|
||||
if ( (successor = table[hash_val]) != 0 )
|
||||
{
|
||||
new_entry->next = successor;
|
||||
successor->prev = new_entry;
|
||||
@ -185,7 +185,7 @@ Char definition[];
|
||||
if ( addsym( copy_string( name ),
|
||||
(char *) copy_unsigned_string( definition ), 0,
|
||||
ndtbl, NAME_TABLE_HASH_SIZE ) )
|
||||
synerr( "name defined twice" );
|
||||
synerr( _( "name defined twice" ) );
|
||||
}
|
||||
|
||||
|
||||
@ -214,7 +214,6 @@ void scextend()
|
||||
scxclu = reallocate_integer_array( scxclu, current_max_scs );
|
||||
sceof = reallocate_integer_array( sceof, current_max_scs );
|
||||
scname = reallocate_char_ptr_array( scname, current_max_scs );
|
||||
actvsc = reallocate_integer_array( actvsc, current_max_scs );
|
||||
}
|
||||
|
||||
|
||||
@ -231,7 +230,7 @@ int xcluflg;
|
||||
char *copy_string();
|
||||
|
||||
/* Generate start condition definition, for use in BEGIN et al. */
|
||||
printf( "#define %s %d\n", str, lastsc );
|
||||
action_define( str, lastsc );
|
||||
|
||||
if ( ++lastsc >= current_max_scs )
|
||||
scextend();
|
||||
@ -240,7 +239,8 @@ int xcluflg;
|
||||
|
||||
if ( addsym( scname[lastsc], (char *) 0, lastsc,
|
||||
sctbl, START_COND_HASH_SIZE ) )
|
||||
format_pinpoint_message( "start condition %s declared twice",
|
||||
format_pinpoint_message(
|
||||
_( "start condition %s declared twice" ),
|
||||
str );
|
||||
|
||||
scset[lastsc] = mkstate( SYM_EPSILON );
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
@ -26,7 +26,7 @@
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/tblcmp.c,v 1.1.1.1 1994/08/24 13:10:31 csgr Exp $ */
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/tblcmp.c,v 1.1.1.2 1996/06/19 20:26:43 nate Exp $ */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
@ -310,7 +310,7 @@ void expand_nxt_chk()
|
||||
chk = reallocate_integer_array( chk, current_max_xpairs );
|
||||
|
||||
zero_out( (char *) (chk + old_max),
|
||||
MAX_XPAIRS_INCREMENT * sizeof( int ) / sizeof( char ) );
|
||||
(size_t) (MAX_XPAIRS_INCREMENT * sizeof( int )) );
|
||||
}
|
||||
|
||||
|
||||
@ -436,8 +436,7 @@ void inittbl()
|
||||
{
|
||||
register int i;
|
||||
|
||||
zero_out( (char *) chk,
|
||||
current_max_xpairs * sizeof( int ) / sizeof( char ) );
|
||||
zero_out( (char *) chk, (size_t) (current_max_xpairs * sizeof( int )) );
|
||||
|
||||
tblend = 0;
|
||||
firstfree = tblend + 1;
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
@ -26,7 +26,7 @@
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/yylex.c,v 1.1.1.1 1994/08/24 13:10:34 csgr Exp $ */
|
||||
/* $Header: /home/ncvs/src/usr.bin/lex/yylex.c,v 1.1.1.2 1996/06/19 20:26:46 nate Exp $ */
|
||||
|
||||
#include <ctype.h>
|
||||
#include "flexdef.h"
|
||||
@ -39,6 +39,7 @@ int yylex()
|
||||
{
|
||||
int toktype;
|
||||
static int beglin = false;
|
||||
extern char *yytext;
|
||||
|
||||
if ( eofseen )
|
||||
toktype = EOF;
|
||||
@ -51,7 +52,7 @@ int yylex()
|
||||
|
||||
if ( sectnum == 1 )
|
||||
{
|
||||
synerr( "premature EOF" );
|
||||
synerr( _( "premature EOF" ) );
|
||||
sectnum = 2;
|
||||
toktype = SECTEND;
|
||||
}
|
||||
@ -109,10 +110,6 @@ int yylex()
|
||||
fputs( "%x", stderr );
|
||||
break;
|
||||
|
||||
case WHITESPACE:
|
||||
(void) putc( ' ', stderr );
|
||||
break;
|
||||
|
||||
case SECTEND:
|
||||
fputs( "%%\n", stderr );
|
||||
|
||||
@ -120,9 +117,8 @@ int yylex()
|
||||
* writing out numbers as we echo rules.
|
||||
* flexscan() has already assigned sectnum.
|
||||
*/
|
||||
|
||||
if ( sectnum == 2 )
|
||||
beglin = 1;
|
||||
beglin = 1;
|
||||
|
||||
break;
|
||||
|
||||
@ -183,13 +179,34 @@ int yylex()
|
||||
fprintf( stderr, "<<EOF>>" );
|
||||
break;
|
||||
|
||||
case OPTION_OP:
|
||||
fprintf( stderr, "%s ", yytext );
|
||||
break;
|
||||
|
||||
case OPT_OUTFILE:
|
||||
case OPT_PREFIX:
|
||||
case CCE_ALNUM:
|
||||
case CCE_ALPHA:
|
||||
case CCE_BLANK:
|
||||
case CCE_CNTRL:
|
||||
case CCE_DIGIT:
|
||||
case CCE_GRAPH:
|
||||
case CCE_LOWER:
|
||||
case CCE_PRINT:
|
||||
case CCE_PUNCT:
|
||||
case CCE_SPACE:
|
||||
case CCE_UPPER:
|
||||
case CCE_XDIGIT:
|
||||
fprintf( stderr, "%s", yytext );
|
||||
break;
|
||||
|
||||
case 0:
|
||||
fprintf( stderr, "End Marker" );
|
||||
fprintf( stderr, _( "End Marker\n" ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf( stderr,
|
||||
"*Something Weird* - tok: %d val: %d\n",
|
||||
_( "*Something Weird* - tok: %d val: %d\n" ),
|
||||
toktype, yylval );
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user