From 6c7bb59857fe5c33473fcfd3fb5dfa8126d1f9c4 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 9 Aug 2002 05:22:07 +0000 Subject: [PATCH] Flatten the tools/re2c build. - Moved (by repocopy) main.c to re2c.c - Moved (by repocopy) parser.y to re2c-parser.y - Changed to Makefile.inc's rather than Makefile.am's - Modified all the source file local includes to point to tools/re2c/*.h svn path=/trunk/yasm/; revision=668 --- Makefile.am | 4 +- configure.ac | 2 - tools/Makefile.am | 2 - tools/Makefile.inc | 6 ++ tools/re2c/.cvsignore | 3 - tools/re2c/Makefile.am | 56 ------------ tools/re2c/Makefile.inc | 95 ++++++++++----------- tools/re2c/actions.c | 6 +- tools/re2c/basics.h | 4 + tools/re2c/code.c | 6 +- tools/re2c/dfa.c | 6 +- tools/re2c/dfa.h | 2 +- tools/re2c/globals.h | 2 +- tools/re2c/ins.h | 2 +- tools/re2c/main.c | 55 ------------ tools/re2c/parse.h | 4 +- tools/re2c/parser.y | 178 --------------------------------------- tools/re2c/re.h | 4 +- tools/re2c/re2c-parser.y | 4 +- tools/re2c/re2c.c | 6 +- tools/re2c/scanner.c | 6 +- tools/re2c/scanner.h | 2 +- tools/re2c/scanner.re | 6 +- tools/re2c/substr.c | 2 +- tools/re2c/substr.h | 2 +- tools/re2c/translate.c | 2 +- 26 files changed, 90 insertions(+), 377 deletions(-) delete mode 100644 tools/Makefile.am create mode 100644 tools/Makefile.inc delete mode 100644 tools/re2c/.cvsignore delete mode 100644 tools/re2c/Makefile.am delete mode 100644 tools/re2c/main.c delete mode 100644 tools/re2c/parser.y diff --git a/Makefile.am b/Makefile.am index 4c95259e..b122052d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ # $IdPath$ -SUBDIRS = libltdl tools m4 po +SUBDIRS = libltdl m4 po CFLAGS = @ANSI_CFLAGS@ AM_YFLAGS = -d @@ -23,9 +23,11 @@ BUILT_SOURCES = CLEANFILES = configure.lineno EXTRA_DIST = config/config.rpath \ check/Makefile.inc \ + tools/Makefile.inc \ src/Makefile.inc include check/Makefile.inc +include tools/Makefile.inc include src/Makefile.inc EXTRA_DIST += \ diff --git a/configure.ac b/configure.ac index 8672f18e..8989044a 100644 --- a/configure.ac +++ b/configure.ac @@ -285,8 +285,6 @@ AC_SUBST(LIBLTDL) AC_CONFIG_FILES([Makefile libltdl/Makefile - tools/Makefile - tools/re2c/Makefile m4/Makefile po/Makefile.in ]) diff --git a/tools/Makefile.am b/tools/Makefile.am deleted file mode 100644 index de43148d..00000000 --- a/tools/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -# $IdPath$ -SUBDIRS = re2c diff --git a/tools/Makefile.inc b/tools/Makefile.inc new file mode 100644 index 00000000..f0481edc --- /dev/null +++ b/tools/Makefile.inc @@ -0,0 +1,6 @@ +# $IdPath$ + +EXTRA_DIST += \ + tools/re2c/Makefile.inc + +include tools/re2c/Makefile.inc diff --git a/tools/re2c/.cvsignore b/tools/re2c/.cvsignore deleted file mode 100644 index f5496799..00000000 --- a/tools/re2c/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -parser.c -parser.h -re2c diff --git a/tools/re2c/Makefile.am b/tools/re2c/Makefile.am deleted file mode 100644 index 6c8c5ae1..00000000 --- a/tools/re2c/Makefile.am +++ /dev/null @@ -1,56 +0,0 @@ -# $IdPath$ -AM_YFLAGS = -d - -INCLUDES = -I$(top_srcdir) - -noinst_PROGRAMS = re2c - -re2c_SOURCES = \ - basics.h \ - globals.h \ - ins.h \ - re.h \ - token.h \ - code.c \ - dfa.h \ - dfa.c \ - main.c \ - parse.h \ - parser.y \ - actions.c \ - scanner.h \ - scanner.c \ - substr.h \ - substr.c \ - translate.c - -BUILT_SOURCES = \ - parser.c \ - parser.h - -CLEANFILES = \ - parser.c \ - parser.h - -EXTRA_DIST = \ - CHANGELOG \ - NO_WARRANTY \ - README \ - scanner.re \ - re2c.1 \ - bootstrap/re2c.man \ - bootstrap/scanner.c \ - doc/loplas.ps.gz \ - doc/sample.bib \ - examples/basemmap.c \ - examples/c.re \ - examples/cmmap.re \ - examples/cnokw.re \ - examples/cunroll.re \ - examples/modula.re \ - examples/sample.re \ - examples/simple.re \ - examples/rexx/README \ - examples/rexx/rexx.l \ - examples/rexx/scanio.c \ - cleanup.pl diff --git a/tools/re2c/Makefile.inc b/tools/re2c/Makefile.inc index 6c8c5ae1..25d354d2 100644 --- a/tools/re2c/Makefile.inc +++ b/tools/re2c/Makefile.inc @@ -1,56 +1,53 @@ # $IdPath$ -AM_YFLAGS = -d -INCLUDES = -I$(top_srcdir) - -noinst_PROGRAMS = re2c +noinst_PROGRAMS += re2c re2c_SOURCES = \ - basics.h \ - globals.h \ - ins.h \ - re.h \ - token.h \ - code.c \ - dfa.h \ - dfa.c \ - main.c \ - parse.h \ - parser.y \ - actions.c \ - scanner.h \ - scanner.c \ - substr.h \ - substr.c \ - translate.c + tools/re2c/basics.h \ + tools/re2c/globals.h \ + tools/re2c/ins.h \ + tools/re2c/re.h \ + tools/re2c/token.h \ + tools/re2c/code.c \ + tools/re2c/dfa.h \ + tools/re2c/dfa.c \ + tools/re2c/re2c.c \ + tools/re2c/parse.h \ + tools/re2c/re2c-parser.y \ + tools/re2c/actions.c \ + tools/re2c/scanner.h \ + tools/re2c/scanner.c \ + tools/re2c/substr.h \ + tools/re2c/substr.c \ + tools/re2c/translate.c -BUILT_SOURCES = \ - parser.c \ - parser.h +BUILT_SOURCES += \ + re2c-parser.c \ + re2c-parser.h -CLEANFILES = \ - parser.c \ - parser.h +CLEANFILES += \ + re2c-parser.c \ + re2c-parser.h -EXTRA_DIST = \ - CHANGELOG \ - NO_WARRANTY \ - README \ - scanner.re \ - re2c.1 \ - bootstrap/re2c.man \ - bootstrap/scanner.c \ - doc/loplas.ps.gz \ - doc/sample.bib \ - examples/basemmap.c \ - examples/c.re \ - examples/cmmap.re \ - examples/cnokw.re \ - examples/cunroll.re \ - examples/modula.re \ - examples/sample.re \ - examples/simple.re \ - examples/rexx/README \ - examples/rexx/rexx.l \ - examples/rexx/scanio.c \ - cleanup.pl +EXTRA_DIST += \ + tools/re2c/CHANGELOG \ + tools/re2c/NO_WARRANTY \ + tools/re2c/README \ + tools/re2c/scanner.re \ + tools/re2c/re2c.1 \ + tools/re2c/bootstrap/re2c.man \ + tools/re2c/bootstrap/scanner.c \ + tools/re2c/doc/loplas.ps.gz \ + tools/re2c/doc/sample.bib \ + tools/re2c/examples/basemmap.c \ + tools/re2c/examples/c.re \ + tools/re2c/examples/cmmap.re \ + tools/re2c/examples/cnokw.re \ + tools/re2c/examples/cunroll.re \ + tools/re2c/examples/modula.re \ + tools/re2c/examples/sample.re \ + tools/re2c/examples/simple.re \ + tools/re2c/examples/rexx/README \ + tools/re2c/examples/rexx/rexx.l \ + tools/re2c/examples/rexx/scanio.c \ + tools/re2c/cleanup.pl diff --git a/tools/re2c/actions.c b/tools/re2c/actions.c index 32fdd170..9160e478 100644 --- a/tools/re2c/actions.c +++ b/tools/re2c/actions.c @@ -4,9 +4,9 @@ #include #include -#include "globals.h" -#include "parse.h" -#include "dfa.h" +#include "tools/re2c/globals.h" +#include "tools/re2c/parse.h" +#include "tools/re2c/dfa.h" static Symbol *first = NULL; diff --git a/tools/re2c/basics.h b/tools/re2c/basics.h index f4964a1a..48d07820 100644 --- a/tools/re2c/basics.h +++ b/tools/re2c/basics.h @@ -1,6 +1,10 @@ #ifndef re2c_basics_h #define re2c_basics_h +#if defined(__GNUC__) && !defined(inline) +#define inline __inline__ +#endif + typedef unsigned int uint; typedef unsigned char uchar, byte; typedef unsigned short ushort, word; diff --git a/tools/re2c/code.c b/tools/re2c/code.c index 3a45010b..c3b5b2d4 100644 --- a/tools/re2c/code.c +++ b/tools/re2c/code.c @@ -3,9 +3,9 @@ #include #include #include -#include "substr.h" -#include "globals.h" -#include "dfa.h" +#include "tools/re2c/substr.h" +#include "tools/re2c/globals.h" +#include "tools/re2c/dfa.h" /* there must be at least one span in list; all spans must cover * same range diff --git a/tools/re2c/dfa.c b/tools/re2c/dfa.c index 23fdb9c7..f1ffb3d7 100644 --- a/tools/re2c/dfa.c +++ b/tools/re2c/dfa.c @@ -3,9 +3,9 @@ #include #include #include -#include "globals.h" -#include "substr.h" -#include "dfa.h" +#include "tools/re2c/globals.h" +#include "tools/re2c/substr.h" +#include "tools/re2c/dfa.h" #define octCh(c) ('0' + c%8) diff --git a/tools/re2c/dfa.h b/tools/re2c/dfa.h index 406bcce3..6b4e8be9 100644 --- a/tools/re2c/dfa.h +++ b/tools/re2c/dfa.h @@ -2,7 +2,7 @@ #define re2c_dfa_h #include -#include "re.h" +#include "tools/re2c/re.h" extern void prtCh(FILE *, uchar); extern void printSpan(FILE *, uint, uint); diff --git a/tools/re2c/globals.h b/tools/re2c/globals.h index e0c402c7..f42735cf 100644 --- a/tools/re2c/globals.h +++ b/tools/re2c/globals.h @@ -1,7 +1,7 @@ #ifndef re2c_globals_h #define re2c_globals_h -#include "basics.h" +#include "tools/re2c/basics.h" extern char *fileName; extern int sFlag; diff --git a/tools/re2c/ins.h b/tools/re2c/ins.h index 30d2d178..0fc6ee00 100644 --- a/tools/re2c/ins.h +++ b/tools/re2c/ins.h @@ -1,7 +1,7 @@ #ifndef re2c_ins_h #define re2c_ins_h -#include "basics.h" +#include "tools/re2c/basics.h" #define nChars 256 typedef uchar Char; diff --git a/tools/re2c/main.c b/tools/re2c/main.c deleted file mode 100644 index e571697c..00000000 --- a/tools/re2c/main.c +++ /dev/null @@ -1,55 +0,0 @@ -#include - -#include -#include - -#include "globals.h" -#include "parse.h" -#include "dfa.h" - -char *fileName; -int sFlag = 0; -int bFlag = 0; - -int main(int argc, char *argv[]){ - FILE *f; - - fileName = NULL; - if(argc == 1) - goto usage; - while(--argc > 1){ - char *p = *++argv; - while(*++p != '\0'){ - switch(*p){ - case 'e': - xlat = asc2ebc; - talx = ebc2asc; - break; - case 's': - sFlag = 1; - break; - case 'b': - sFlag = 1; - bFlag = 1; - break; - default: - goto usage; - } - } - } - fileName = *++argv; - if(fileName[0] == '-' && fileName[1] == '\0'){ - fileName = ""; - f = stdin; - } else { - if((f = fopen(fileName, "rt")) < 0){ - fprintf(stderr, "can't open %s\n", fileName); - return 1; - } - } - parse(f, stdout); - return 0; -usage: - fputs("usage: re2c [-esb] name\n", stderr); - return 2; -} diff --git a/tools/re2c/parse.h b/tools/re2c/parse.h index cd7724cb..ffeb4054 100644 --- a/tools/re2c/parse.h +++ b/tools/re2c/parse.h @@ -2,8 +2,8 @@ #define re2c_parse_h #include -#include "scanner.h" -#include "re.h" +#include "tools/re2c/scanner.h" +#include "tools/re2c/re.h" typedef struct Symbol { struct Symbol *next; diff --git a/tools/re2c/parser.y b/tools/re2c/parser.y deleted file mode 100644 index d9701bee..00000000 --- a/tools/re2c/parser.y +++ /dev/null @@ -1,178 +0,0 @@ -%{ -#include - -#include -#include -#include -#include -#include "globals.h" -#include "parse.h" -int yyparse(); -int yylex(); -void yyerror(char*); - -static uint accept; -static RegExp *spec; -static Scanner *in; - -%} - -%start spec - -%union { - Symbol *symbol; - RegExp *regexp; - Token *token; - char op; -} - -%token CLOSE ID CODE RANGE STRING - -%type CLOSE -%type close -%type ID -%type CODE -%type RANGE STRING -%type rule look expr diff term factor primary - -%% - -spec : - { accept = 0; - spec = NULL; } - | spec rule - { spec = spec? mkAlt(spec, $2) : $2; } - | spec decl - ; - -decl : ID '=' expr ';' - { if($1->re) - Scanner_fatal(in, "sym already defined"); - $1->re = $3; } - ; - -rule : expr look CODE - { $$ = RegExp_new_RuleOp($1, $2, $3, accept++); } - ; - -look : - { $$ = RegExp_new_NullOp(); } - | '/' expr - { $$ = $2; } - ; - -expr : diff - { $$ = $1; } - | expr '|' diff - { $$ = mkAlt($1, $3); } - ; - -diff : term - { $$ = $1; } - | diff '\\' term - { $$ = mkDiff($1, $3); - if(!$$) - Scanner_fatal(in, "can only difference char sets"); - } - ; - -term : factor - { $$ = $1; } - | term factor - { $$ = RegExp_new_CatOp($1, $2); } - ; - -factor : primary - { $$ = $1; } - | primary close - { - switch($2){ - case '*': - $$ = mkAlt(RegExp_new_CloseOp($1), RegExp_new_NullOp()); - break; - case '+': - $$ = RegExp_new_CloseOp($1); - break; - case '?': - $$ = mkAlt($1, RegExp_new_NullOp()); - break; - } - } - ; - -close : CLOSE - { $$ = $1; } - | close CLOSE - { $$ = ($1 == $2) ? $1 : '*'; } - ; - -primary : ID - { if(!$1->re) - Scanner_fatal(in, "can't find symbol"); - $$ = $1->re; } - | RANGE - { $$ = $1; } - | STRING - { $$ = $1; } - | '(' expr ')' - { $$ = $2; } - ; - -%% - -void yyerror(char* s){ - Scanner_fatal(in, s); -} - -int yylex(){ - return Scanner_scan(in); -} - -char * -mystrdup(const char *str) -{ - size_t len; - char *copy; - - len = strlen(str) + 1; - copy = malloc(len); - memcpy(copy, str, len); - return (copy); -} - -void parse(FILE *i, FILE *o){ - char * fnamebuf; - char * token; - time_t now; - - time(&now); - - fputs("/* Generated by re2c 0.9.1-C on ", o); - fprintf(o, "%-24s", ctime(&now)); - fputs(" */\n", o); - - in = Scanner_new(i); - - fprintf(o, "#line %u \"", Scanner_line(in)); - if( fileName != NULL ) { - fnamebuf = mystrdup( fileName ); - } else { - fnamebuf = mystrdup( "" ); - } - token = strtok( fnamebuf, "\\" ); - for(;;) { - fprintf(o, "%s", token); - token = strtok( NULL, "\\" ); - if( token == NULL ) break; - fputs("\\\\", o); - } - fputs("\"\n", o); - free( fnamebuf ); - - while(Scanner_echo(in, o)){ - yyparse(); - if(spec) - genCode(o, spec); - fprintf(o, "#line %u\n", Scanner_line(in)); - } -} diff --git a/tools/re2c/re.h b/tools/re2c/re.h index c34cd3ec..6c87d10d 100644 --- a/tools/re2c/re.h +++ b/tools/re2c/re.h @@ -2,8 +2,8 @@ #define re2c_re_h #include -#include "token.h" -#include "ins.h" +#include "tools/re2c/token.h" +#include "tools/re2c/ins.h" typedef struct CharPtn { uint card; diff --git a/tools/re2c/re2c-parser.y b/tools/re2c/re2c-parser.y index d9701bee..c41170f5 100644 --- a/tools/re2c/re2c-parser.y +++ b/tools/re2c/re2c-parser.y @@ -5,8 +5,8 @@ #include #include #include -#include "globals.h" -#include "parse.h" +#include "tools/re2c/globals.h" +#include "tools/re2c/parse.h" int yyparse(); int yylex(); void yyerror(char*); diff --git a/tools/re2c/re2c.c b/tools/re2c/re2c.c index e571697c..469da2d2 100644 --- a/tools/re2c/re2c.c +++ b/tools/re2c/re2c.c @@ -3,9 +3,9 @@ #include #include -#include "globals.h" -#include "parse.h" -#include "dfa.h" +#include "tools/re2c/globals.h" +#include "tools/re2c/parse.h" +#include "tools/re2c/dfa.h" char *fileName; int sFlag = 0; diff --git a/tools/re2c/scanner.c b/tools/re2c/scanner.c index 1ce43d8d..f08bdfaf 100644 --- a/tools/re2c/scanner.c +++ b/tools/re2c/scanner.c @@ -5,9 +5,9 @@ #include #include -#include "scanner.h" -#include "parse.h" -#include "parser.h" +#include "tools/re2c/scanner.h" +#include "tools/re2c/parse.h" +#include "re2c-parser.h" extern YYSTYPE yylval; diff --git a/tools/re2c/scanner.h b/tools/re2c/scanner.h index f27e315b..a76c4dd4 100644 --- a/tools/re2c/scanner.h +++ b/tools/re2c/scanner.h @@ -2,7 +2,7 @@ #define _scanner_h #include -#include "token.h" +#include "tools/re2c/token.h" typedef struct Scanner { FILE *in; diff --git a/tools/re2c/scanner.re b/tools/re2c/scanner.re index cf69c590..a058fe76 100644 --- a/tools/re2c/scanner.re +++ b/tools/re2c/scanner.re @@ -2,9 +2,9 @@ #include #include -#include "scanner.h" -#include "parse.h" -#include "parser.h" +#include "tools/re2c/scanner.h" +#include "tools/re2c/parse.h" +#include "re2c-parser.h" extern YYSTYPE yylval; diff --git a/tools/re2c/substr.c b/tools/re2c/substr.c index c88dcb63..3be3c875 100644 --- a/tools/re2c/substr.c +++ b/tools/re2c/substr.c @@ -1,7 +1,7 @@ #include #include -#include "substr.h" +#include "tools/re2c/substr.h" void SubStr_out(const SubStr *s, FILE *o) diff --git a/tools/re2c/substr.h b/tools/re2c/substr.h index 68017c01..6bf82b44 100644 --- a/tools/re2c/substr.h +++ b/tools/re2c/substr.h @@ -3,7 +3,7 @@ #include #include -#include "basics.h" +#include "tools/re2c/basics.h" struct SubStr { char *str; diff --git a/tools/re2c/translate.c b/tools/re2c/translate.c index d3356b86..17b9adca 100644 --- a/tools/re2c/translate.c +++ b/tools/re2c/translate.c @@ -1,6 +1,6 @@ #include -#include "globals.h" +#include "tools/re2c/globals.h" uchar asc2asc[256] = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, -- 2.40.0