summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVern Paxson <vern@ee.lbl.gov>1994-11-24 16:42:44 +0000
committerVern Paxson <vern@ee.lbl.gov>1994-11-24 16:42:44 +0000
commit8618b3545e8b4d0bb298f95104a5340db460bfb3 (patch)
treebeaab437b39e8dbf0840236e41c62c6287630b26
parent89dad6fe3a0e9f72a17d2e16bca197ffe681c932 (diff)
Brian Madsen's tweaks for Borland
-rw-r--r--dfa.c4
-rw-r--r--flex.skl11
-rw-r--r--flexdef.h109
-rw-r--r--gen.c7
-rw-r--r--misc.c58
-rw-r--r--parse.y9
-rw-r--r--scan.l4
-rw-r--r--sym.c2
8 files changed, 135 insertions, 69 deletions
diff --git a/dfa.c b/dfa.c
index 4273cfc..7a4d42a 100644
--- a/dfa.c
+++ b/dfa.c
@@ -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;
@@ -398,7 +398,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;
diff --git a/flex.skl b/flex.skl
index e308b1f..693f755 100644
--- a/flex.skl
+++ b/flex.skl
@@ -45,7 +45,12 @@ class istream;
#ifdef __TURBOC__
+#pragma warn -rch
+#pragma warn -use
+#include <io.h>
+#include <stdlib.h>
#define YY_USE_CONST
+#define YY_USE_PROTOS
#endif
@@ -244,7 +249,11 @@ static void yy_flex_free YY_PROTO(( void * ));
#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
- (yy_current_buffer->yy_current_buffer = is_interactive)
+ { \
+ if ( ! yy_current_buffer ) \
+ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+ yy_current_buffer->yy_is_interactive = is_interactive; \
+ }
%% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here
diff --git a/flexdef.h b/flexdef.h
index fdd7b02..3de9f5d 100644
--- a/flexdef.h
+++ b/flexdef.h
@@ -33,6 +33,20 @@
#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
@@ -51,16 +65,6 @@
#include <stdlib.h>
#endif
-#ifdef __BORLANDC__
-/* Gag. */
-#pragma warn -pro
-#pragma warn -rch
-#pragma warn -use
-#pragma warn -aus
-#pragma warn -par
-#pragma warn -pia
-#endif
-
/* Always be prepared to generate an 8-bit scanner. */
#define CSIZE 256
#define Char unsigned char
@@ -703,11 +707,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 */
@@ -726,6 +742,46 @@ 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 */
@@ -756,6 +812,15 @@ 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 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));
@@ -768,6 +833,9 @@ extern void flexerror PROTO((char[]));
/* Report a fatal error message and terminate. */
extern void flexfatal PROTO((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));
@@ -793,6 +861,9 @@ 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 [] ));
@@ -870,6 +941,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[]));
@@ -877,16 +951,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 */
@@ -904,13 +979,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 */
@@ -926,6 +1009,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));
diff --git a/gen.c b/gen.c
index 84a588e..e336395 100644
--- a/gen.c
+++ b/gen.c
@@ -227,7 +227,6 @@ void genctbl()
void genecs()
{
- Char clower();
register int i, j;
int numrows;
@@ -388,7 +387,7 @@ void gen_find_action()
}
-/* genftbl - generates full transition table */
+/* genftbl - generate full transition table */
void genftbl()
{
@@ -581,7 +580,7 @@ void gen_next_match()
void gen_next_state( worry_about_NULs )
int worry_about_NULs;
- { /* NOTE - changes in here should be reflected in get_next_match() */
+ { /* NOTE - changes in here should be reflected in gen_next_match() */
char char_map[256];
if ( worry_about_NULs && ! nultrans )
@@ -646,7 +645,7 @@ int worry_about_NULs;
/* Generate the code to make a NUL transition. */
void gen_NUL_trans()
- { /* NOTE - changes in here should be reflected in get_next_match() */
+ { /* NOTE - changes in here should be reflected in gen_next_match() */
int need_backing_up = (num_backing_up > 0 && ! reject);
if ( need_backing_up )
diff --git a/misc.c b/misc.c
index d6831d5..4d98070 100644
--- a/misc.c
+++ b/misc.c
@@ -201,7 +201,7 @@ register char *str;
if ( copy == NULL )
flexfatal( "dynamic memory failure in copy_string()" );
- for ( c = copy; (*c++ = *str++); )
+ for ( c = copy; (*c++ = *str++) != 0; )
;
return copy;
@@ -224,7 +224,7 @@ register Char *str;
copy = allocate_Character_array( c - str + 1 );
- for ( c = copy; (*c++ = *str++); )
+ for ( c = copy; (*c++ = *str++) != 0; )
;
return copy;
@@ -336,6 +336,19 @@ char msg[];
}
+/* htoi - convert a hexadecimal digit string to an integer value */
+
+int htoi( str )
+Char str[];
+ {
+ unsigned int result;
+
+ (void) sscanf( (char *) str, "%x", &result );
+
+ return result;
+ }
+
+
/* lerrif - report an error message formatted with one integer argument */
void lerrif( msg, arg )
@@ -360,45 +373,6 @@ char msg[], arg[];
}
-/* htoi - convert a hexadecimal digit string to an integer value */
-
-int htoi( str )
-Char str[];
- {
- unsigned int result;
-
- (void) sscanf( (char *) str, "%x", &result );
-
- return result;
- }
-
-
-/* is_hex_digit - returns true if a character is a valid hex digit, false
- * otherwise
- */
-
-int is_hex_digit( ch )
-int ch;
- {
- 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;
- }
- }
-
-
/* line_directive_out - spit out a "# line" statement */
void line_directive_out( output_file, do_infile )
@@ -602,7 +576,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 ...
diff --git a/parse.y b/parse.y
index 388b42f..54eb260 100644
--- a/parse.y
+++ b/parse.y
@@ -51,7 +51,11 @@
#ifdef __hpux
void *alloca ();
#else /* not __hpux */
+#ifdef __TURBOC__
+#include <malloc.h>
+#else
char *alloca ();
+#endif /* not __TURBOC__ */
#endif /* not __hpux */
#endif /* not _AIX */
#endif /* not HAVE_ALLOCA_H */
@@ -69,11 +73,6 @@ int trlcontxt, xcluflg, cclsorted, varlength, variable_trail_rule;
int *scon_stk;
int scon_stk_ptr;
-Char clower();
-char *copy_string();
-void build_eof_action();
-void yyerror();
-
static int madeany = false; /* whether we've made the '.' character class */
int previous_continued_action; /* whether the previous rule's action was '|' */
diff --git a/scan.l b/scan.l
index 28e46d5..e1f1aae 100644
--- a/scan.l
+++ b/scan.l
@@ -379,7 +379,7 @@ LEXOPT [aceknopr]
/* Check to see if we've already encountered this
* ccl.
*/
- if ( (cclval = ccllookup( (Char *) nmstr )) )
+ if ( (cclval = ccllookup( (Char *) nmstr )) != 0 )
{
if ( input() != ']' )
synerr( "bad character class" );
@@ -412,7 +412,7 @@ LEXOPT [aceknopr]
strcpy( nmstr, yytext + 1 );
nmstr[yyleng - 2] = '\0'; /* chop trailing brace */
- if ( ! (nmdefptr = ndlookup( nmstr )) )
+ if ( (nmdefptr = ndlookup( nmstr )) == 0 )
format_synerr( "undefined definition {%s}",
nmstr );
diff --git a/sym.c b/sym.c
index bea9263..63dd933 100644
--- a/sym.c
+++ b/sym.c
@@ -77,7 +77,7 @@ int table_size;
if ( new_entry == NULL )
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;