Fix tons of warnings, convert burg to use Makefile.common system, rename
authorChris Lattner <sabre@nondot.org>
Sun, 22 Sep 2002 02:40:40 +0000 (02:40 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 22 Sep 2002 02:40:40 +0000 (02:40 +0000)
gram.y to gram.yc so that we don't try to turn it into a .cpp file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3874 91177308-0d34-0410-b5e6-96231b3b80d8

20 files changed:
support/tools/Burg/Makefile
support/tools/Burg/b.h
support/tools/Burg/be.c
support/tools/Burg/fe.h
support/tools/Burg/gram.y [deleted file]
support/tools/Burg/gram.yc [new file with mode: 0644]
support/tools/Burg/lex.c
support/tools/Burg/nonterminal.c
support/tools/Burg/plank.c
support/tools/Burg/zalloc.c
utils/Burg/Makefile
utils/Burg/b.h
utils/Burg/be.c
utils/Burg/fe.h
utils/Burg/gram.y [deleted file]
utils/Burg/gram.yc [new file with mode: 0644]
utils/Burg/lex.c
utils/Burg/nonterminal.c
utils/Burg/plank.c
utils/Burg/zalloc.c

index c22bd552e8453178f316504b2e34bd034cd62774..a70f2eaaf9c03c60bef051c81f9e7d0e8bd8c50c 100644 (file)
 # $Id$
-
 LEVEL = ../..
+TOOLNAME = burg
+EXTRASOURCES = gram.tab.c
 
-UNAME := $(shell uname)
-include $(LEVEL)/Makefile.config
-include $(LEVEL)/Makefile.$(UNAME)
-
-TARGET = burg.$(UNAME)
-
-#CFLAGS        =
-#CFLAGS        = -O
-#CFLAGS        = -O -DNOLEX
-CFLAGS = -g -DDEBUG
-#CFLAGS        = -g -DNOLEX -DDEBUG
-
-SRCS = \
-       be.c \
-       burs.c \
-       closure.c \
-       delta.c \
-       fe.c \
-       item.c \
-       lex.c \
-       list.c \
-       main.c \
-       map.c \
-       nonterminal.c \
-       operator.c \
-       pattern.c \
-       plank.c \
-       queue.c \
-       rule.c \
-       string.c \
-       symtab.c \
-       table.c \
-       trim.c \
-       zalloc.c
-
-BU_OBJS = \
-       burs.o \
-       closure.o \
-       delta.o \
-       item.o \
-       list.o \
-       map.o \
-       nonterminal.o \
-       operator.o \
-       pattern.o \
-       queue.o \
-       rule.o \
-       table.o \
-       trim.o \
-       zalloc.o
-
-BU_OBJS := $(addprefix $(UNAME)/,$(BU_OBJS))
-
-FE_OBJS = \
-       be.o \
-       fe.o \
-       lex.o \
-       main.o \
-       plank.o \
-       string.o \
-       symtab.o \
-       y.tab.o
-
-FE_OBJS := $(addprefix $(UNAME)/,$(FE_OBJS))
-
-all: $(TARGET)
-
-
-$(TARGET): $(BU_OBJS) $(FE_OBJS)
-       $(CC) -o $(TARGET) $(CFLAGS) $(BU_OBJS) $(FE_OBJS)
+include $(LEVEL)/Makefile.common
 
-y.tab.c y.tab.h: gram.y
-       yacc -d gram.y
+gram.tab.c gram.tab.h: gram.yc
+       $(VERB) $(BISON) -d $<
+       $(VERB) mv -f gram.tab.cc gram.tab.c
+       $(VERB) mv -f gram.tab.hc gram.tab.h
 
-clean:
-       rm -rf $(UNAME) *.o y.tab.h y.tab.c core burg *.aux *.log *.dvi sample sample.c tmp
+clean::
+       rm -ff y.tab.h y.tab.c core *.aux *.log *.dvi sample sample.c tmp
 
 $(FE_OBJS):    b.h
 $(BU_OBJS):    b.h
 $(FE_OBJS):    fe.h
 
-lex.o: y.tab.h
+$(BUILD_ROOT)/Release/lex.o $(BUILD_ROOT)/Profile/lex.o $(BUILD_ROOT)/Debug/lex.o: gram.tab.h
 
 doc.dvi: doc.tex
        latex doc; latex doc
 
-$(UNAME)/%.o: %.c
-       $(VERB) $(CC) -c -g $< -o $@
 
-test: $(TARGET) sample.gr
-       ./$(TARGET) -I     <sample.gr   >sample.c && cc $(CFLAGS) -o sample sample.c && ./sample
-       ./$(TARGET) -I      sample.gr   >tmp && cmp tmp sample.c
-       ./$(TARGET) -I     <sample.gr -o tmp && cmp tmp sample.c
-       ./$(TARGET) -I      sample.gr -o tmp && cmp tmp sample.c
-       ./$(TARGET) -I -O0 <sample.gr   >tmp && cmp tmp sample.c
-       ./$(TARGET) -I -=  <sample.gr   >tmp && cmp tmp sample.c
+test: $(TOOLEXENAME_G) sample.gr
+       $(TOOLEXENAME_G) -I     <sample.gr   >sample.c && $(CC) $(CFLAGS) -o sample sample.c && ./sample
+       $(TOOLEXENAME_G) -I      sample.gr   >tmp && cmp tmp sample.c
+       $(TOOLEXENAME_G) -I     <sample.gr -o tmp && cmp tmp sample.c
+       $(TOOLEXENAME_G) -I      sample.gr -o tmp && cmp tmp sample.c
+       $(TOOLEXENAME_G) -I -O0 <sample.gr   >tmp && cmp tmp sample.c
+       $(TOOLEXENAME_G) -I -=  <sample.gr   >tmp && cmp tmp sample.c
index f1b33edd9434f347723f2e5e790310ad66ceab34..164325dc976ab80a835b95ce1509649131b7cc8b 100644 (file)
@@ -306,6 +306,6 @@ extern int debugTables;
 
 extern void doStart ARGS((char *));
 extern void exit ARGS((int));
-extern int fatal ARGS((char *, int));
-extern void yyerror ARGS((char *));
-extern void yyerror1 ARGS((char *));
+extern int fatal ARGS((const char *, int));
+extern void yyerror ARGS((const char *));
+extern void yyerror1 ARGS((const char *));
index e7feab8d5ddb56e26d399c7f65232205113abe10..31db211a7006191fa690c660892c305c116ed503 100644 (file)
@@ -8,7 +8,7 @@ char rcsid_be[] = "$Id$";
 #define ERROR_VAL 0
 
 FILE *outfile;
-char *prefix = "burm";
+const char *prefix = "burm";
 
 static void doKids ARGS((RuleAST));
 static void doLabel ARGS((Operator));
@@ -24,7 +24,7 @@ static void printPatternAST_int ARGS((PatternAST));
 static void setVectors ARGS((PatternAST));
 static void trailing_zeroes ARGS((int));
 static int seminal ARGS((int from, int to));
-static void printRule ARGS((RuleAST, char *));
+static void printRule ARGS((RuleAST, const char *));
 
 static void
 doLabel(op) Operator op;
@@ -329,10 +329,10 @@ makeLHSmap()
                        fprintf(outfile, "\t0,\n");
                }
        }
-       fprintf(outfile, "};\n\n", prefix);
+       fprintf(outfile, "};\n\n");
 }
 
-static int seminal(from, to)
+static int seminal(int from, int to)
 {
        return allpairs[from][to].rule ? allpairs[from][to].rule->erulenum : 0;
 
@@ -453,7 +453,7 @@ makeDeltaCostArray()
        for (s = 0; s < states-1; s++) {
                fprintf(outfile, "{ /* state #%d: ", s+1);
                printRepresentative(outfile, sortedStates[s]);
-               fprintf(outfile, " */\n", s+1);
+               fprintf(outfile, " */\n");
                fprintf(outfile, "\t{0},\n");
                for (nt = 1; nt < last_user_nonterminal; nt++) {
                        makeCostVector(1, sortedStates[s]->closed[nt].delta);
@@ -616,7 +616,7 @@ makeNts()
 }
 
 static void
-printRule(r,d) RuleAST r; char *d;
+printRule(RuleAST r, const char *d)
 {
        if (r) {
                fprintf(outfile, "%s: ", r->rule->lhs->name);
index 5cef79bbe1477de93d05ff8fbb0812a03dde4ef8..70e98e22153a73043265ce0e2397b07fe78b2087 100644 (file)
@@ -121,7 +121,7 @@ extern int  max_ruleAST;
 extern List    ruleASTs;
 
 extern FILE    *outfile;
-extern char    *prefix;
+extern const char *prefix;
 extern int     trimflag;
 extern int     speedflag;
 extern int     grammarflag;
diff --git a/support/tools/Burg/gram.y b/support/tools/Burg/gram.y
deleted file mode 100644 (file)
index f6f16fa..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-%{
-char rcsid_gram[] = "$Id$";
-
-#include <stdio.h>
-#include "b.h"
-#include "fe.h"
-%}
-
-%union {
-       int y_int;
-       char *y_string;
-       Arity y_arity;
-       Binding y_binding;
-       PatternAST y_patternAST;
-       RuleAST y_ruleAST;
-       List y_list;
-       IntList y_intlist;
-}
-
-%start full
-
-%term ERROR
-%term K_TERM
-%term K_GRAM
-%term K_START
-%term K_PPERCENT
-%term INT
-%term ID
-
-%token <y_string> ID
-%token <y_int> INT
-
-%type <y_arity> decl
-%type <y_binding> binding
-%type <y_intlist> cost costtail
-%type <y_ruleAST> rule
-%type <y_patternAST> pattern
-%type <y_list> decls rules bindinglist grammarlist
-%%
-
-
-full   : spec
-       | spec K_PPERCENT
-               { yyfinished(); }
-       ;
-
-spec   : decls K_PPERCENT rules
-               = { doSpec($1, $3); }
-       ;
-
-decls  : /* lambda */  = { $$ = 0; }
-       | decls decl    = { $$ = newList($2, $1); }
-       ;
-
-decl   : K_TERM bindinglist    = { $$ = newArity(-1, $2); }
-       | K_GRAM grammarlist    = { $$ = 0; doGram($2); }
-       | K_START ID            = { $$ = 0; doStart($2); }      /* kludge */
-       ;
-
-grammarlist    : /* lambda */          = { $$ = 0; }
-               | grammarlist ID        = { $$ = newList($2, $1); }
-               ;
-
-bindinglist    : /* lambda */          = { $$ = 0; }
-               | bindinglist binding   = { $$ = newList($2, $1); }
-               ;
-
-binding        : ID '=' INT    = { $$ = newBinding($1, $3); }
-       ;
-
-rules  : /* lambda */  = { $$ = 0; }
-       | rules rule    = { $$ = newList($2, $1); }
-       ;
-
-rule   : ID ':' pattern '=' INT cost ';'       = { $$ = newRuleAST($1, $3, $5, $6); }
-               ;
-
-pattern        : ID                                    = { $$ = newPatternAST($1, 0); }
-       | ID '(' pattern ')'                    = { $$ = newPatternAST($1, newList($3,0)); }
-       | ID '(' pattern ',' pattern ')'        = { $$ = newPatternAST($1, newList($3, newList($5, 0))); }
-       ;
-
-cost   : /* lambda */          = { $$ = 0; }
-       | '(' INT costtail ')'  = { $$ = newIntList($2, $3); }
-       ;
-
-costtail       : /* lambda */          = { $$ = 0; }
-               | ',' INT costtail      = { $$ = newIntList($2, $3); }
-               | INT costtail          = { $$ = newIntList($1, $2); }
-               ;
diff --git a/support/tools/Burg/gram.yc b/support/tools/Burg/gram.yc
new file mode 100644 (file)
index 0000000..ec692c3
--- /dev/null
@@ -0,0 +1,91 @@
+%{
+char rcsid_gram[] = "$Id$";
+
+#include <stdio.h>
+#include "b.h"
+#include "fe.h"
+int doGram(List);
+%}
+
+%union {
+       int y_int;
+       char *y_string;
+       Arity y_arity;
+       Binding y_binding;
+       PatternAST y_patternAST;
+       RuleAST y_ruleAST;
+       List y_list;
+       IntList y_intlist;
+}
+
+%start full
+
+%term ERROR
+%term K_TERM
+%term K_GRAM
+%term K_START
+%term K_PPERCENT
+%term INT
+%term ID
+
+%token <y_string> ID
+%token <y_int> INT
+
+%type <y_arity> decl
+%type <y_binding> binding
+%type <y_intlist> cost costtail
+%type <y_ruleAST> rule
+%type <y_patternAST> pattern
+%type <y_list> decls rules bindinglist grammarlist
+%%
+
+
+full   : spec
+       | spec K_PPERCENT
+               { yyfinished(); }
+       ;
+
+spec   : decls K_PPERCENT rules
+               = { doSpec($1, $3); }
+       ;
+
+decls  : /* lambda */  = { $$ = 0; }
+       | decls decl    = { $$ = newList($2, $1); }
+       ;
+
+decl   : K_TERM bindinglist    = { $$ = newArity(-1, $2); }
+       | K_GRAM grammarlist    = { $$ = 0; doGram($2); }
+       | K_START ID            = { $$ = 0; doStart($2); }      /* kludge */
+       ;
+
+grammarlist    : /* lambda */          = { $$ = 0; }
+               | grammarlist ID        = { $$ = newList($2, $1); }
+               ;
+
+bindinglist    : /* lambda */          = { $$ = 0; }
+               | bindinglist binding   = { $$ = newList($2, $1); }
+               ;
+
+binding        : ID '=' INT    = { $$ = newBinding($1, $3); }
+       ;
+
+rules  : /* lambda */  = { $$ = 0; }
+       | rules rule    = { $$ = newList($2, $1); }
+       ;
+
+rule   : ID ':' pattern '=' INT cost ';'       = { $$ = newRuleAST($1, $3, $5, $6); }
+               ;
+
+pattern        : ID                                    = { $$ = newPatternAST($1, 0); }
+       | ID '(' pattern ')'                    = { $$ = newPatternAST($1, newList($3,0)); }
+       | ID '(' pattern ',' pattern ')'        = { $$ = newPatternAST($1, newList($3, newList($5, 0))); }
+       ;
+
+cost   : /* lambda */          = { $$ = 0; }
+       | '(' INT costtail ')'  = { $$ = newIntList($2, $3); }
+       ;
+
+costtail       : /* lambda */          = { $$ = 0; }
+               | ',' INT costtail      = { $$ = newIntList($2, $3); }
+               | INT costtail          = { $$ = newIntList($1, $2); }
+               ;
index 3d6c5af5c48131b1c08ad2689978d1477b533b55..85eb8a738faf8e8f303272c87e00a65244ca854c 100644 (file)
@@ -5,7 +5,7 @@ char rcsid_lex[] = "$Id$";
 #include <string.h>
 #include "b.h"
 #include "fe.h"
-#include "y.tab.h"
+#include "gram.tab.h"
 
 static char buf[BUFSIZ];
 
@@ -245,14 +245,13 @@ yylex()
        return(0);
 }
 
-void
-yyerror1(str) char *str;
+void yyerror1(const char *str)
 {
        fprintf(stderr, "line %d: %s", yyline, str);
 }
 
 void
-yyerror(str) char *str;
+yyerror(const char *str)
 {
        yyerror1(str);
        fprintf(stderr, "\n");
index af88dd61ea9ce5fb3a260ae69ec0c075fa84795b..71fd7d49442c4aff97fecde2bdff35500ec08810 100644 (file)
@@ -2,6 +2,7 @@ char rcsid_nonterminal[] = "$Id$";
 
 #include "b.h"
 #include <stdio.h>
+#include <string.h>
 
 NonTerminal    start;
 NonTerminalNum max_nonterminal = 1;
@@ -29,7 +30,6 @@ int
 nonTerminalName(buf, i) char *buf; int i;
 {
        List l;
-       extern char *strcpy ARGS((char *, char *));
 
        for (l = nonterminals; l; l = l->next) {
                NonTerminal nt = (NonTerminal) l->x;
index 053304eafc30765b9864668a236c542ed2e79a5f..e6ba38ba8075a88fc59862ef560eea4f74b7dd36 100644 (file)
@@ -2,6 +2,7 @@ char rcsid_plank[] = "$Id$";
 
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include "b.h"
 #include "fe.h"
 
@@ -35,7 +36,7 @@ static void purgePlanks ARGS((List));
 static void inToEx ARGS((void));
 static void makePlankRuleMacros ARGS((void));
 static void makePlankRule ARGS((void));
-static void exceptionSwitch ARGS((List, char *, char *, char *, int, char *));
+static void exceptionSwitch ARGS((List, const char *, const char *, const char *, int, const char *));
 static void doPlankLabel ARGS((Operator));
 static void doPlankLabelSafely ARGS((Operator));
 static void doPlankLabelMacrosSafely ARGS((Operator));
@@ -602,7 +603,7 @@ makePlankRule()
 }
 
 static void
-exceptionSwitch(es, sw, pre, post, offset, def) List es; char *sw; char *pre; char *post; int offset; char *def;
+exceptionSwitch(es, sw, pre, post, offset, def) List es; const char *sw; const char *pre; const char *post; int offset; const char *def;
 {
        if (es) {
                fprintf(outfile, "\t\tswitch (%s) {\n", sw);
index bd50217308e1dd5efb1a88d1adffc9c70f627d7a..9128e4280f20b73c6e12418a2d4818d71d1265be 100644 (file)
@@ -9,7 +9,7 @@ extern void free ARGS((void *));
 extern void *malloc ARGS((unsigned));
 
 int
-fatal(name, line) char *name; int line;
+fatal(const char *name, int line)
 {
        fprintf(stderr, "assertion failed: file %s, line %d\n", name, line);
        exit(1);
index c22bd552e8453178f316504b2e34bd034cd62774..a70f2eaaf9c03c60bef051c81f9e7d0e8bd8c50c 100644 (file)
 # $Id$
-
 LEVEL = ../..
+TOOLNAME = burg
+EXTRASOURCES = gram.tab.c
 
-UNAME := $(shell uname)
-include $(LEVEL)/Makefile.config
-include $(LEVEL)/Makefile.$(UNAME)
-
-TARGET = burg.$(UNAME)
-
-#CFLAGS        =
-#CFLAGS        = -O
-#CFLAGS        = -O -DNOLEX
-CFLAGS = -g -DDEBUG
-#CFLAGS        = -g -DNOLEX -DDEBUG
-
-SRCS = \
-       be.c \
-       burs.c \
-       closure.c \
-       delta.c \
-       fe.c \
-       item.c \
-       lex.c \
-       list.c \
-       main.c \
-       map.c \
-       nonterminal.c \
-       operator.c \
-       pattern.c \
-       plank.c \
-       queue.c \
-       rule.c \
-       string.c \
-       symtab.c \
-       table.c \
-       trim.c \
-       zalloc.c
-
-BU_OBJS = \
-       burs.o \
-       closure.o \
-       delta.o \
-       item.o \
-       list.o \
-       map.o \
-       nonterminal.o \
-       operator.o \
-       pattern.o \
-       queue.o \
-       rule.o \
-       table.o \
-       trim.o \
-       zalloc.o
-
-BU_OBJS := $(addprefix $(UNAME)/,$(BU_OBJS))
-
-FE_OBJS = \
-       be.o \
-       fe.o \
-       lex.o \
-       main.o \
-       plank.o \
-       string.o \
-       symtab.o \
-       y.tab.o
-
-FE_OBJS := $(addprefix $(UNAME)/,$(FE_OBJS))
-
-all: $(TARGET)
-
-
-$(TARGET): $(BU_OBJS) $(FE_OBJS)
-       $(CC) -o $(TARGET) $(CFLAGS) $(BU_OBJS) $(FE_OBJS)
+include $(LEVEL)/Makefile.common
 
-y.tab.c y.tab.h: gram.y
-       yacc -d gram.y
+gram.tab.c gram.tab.h: gram.yc
+       $(VERB) $(BISON) -d $<
+       $(VERB) mv -f gram.tab.cc gram.tab.c
+       $(VERB) mv -f gram.tab.hc gram.tab.h
 
-clean:
-       rm -rf $(UNAME) *.o y.tab.h y.tab.c core burg *.aux *.log *.dvi sample sample.c tmp
+clean::
+       rm -ff y.tab.h y.tab.c core *.aux *.log *.dvi sample sample.c tmp
 
 $(FE_OBJS):    b.h
 $(BU_OBJS):    b.h
 $(FE_OBJS):    fe.h
 
-lex.o: y.tab.h
+$(BUILD_ROOT)/Release/lex.o $(BUILD_ROOT)/Profile/lex.o $(BUILD_ROOT)/Debug/lex.o: gram.tab.h
 
 doc.dvi: doc.tex
        latex doc; latex doc
 
-$(UNAME)/%.o: %.c
-       $(VERB) $(CC) -c -g $< -o $@
 
-test: $(TARGET) sample.gr
-       ./$(TARGET) -I     <sample.gr   >sample.c && cc $(CFLAGS) -o sample sample.c && ./sample
-       ./$(TARGET) -I      sample.gr   >tmp && cmp tmp sample.c
-       ./$(TARGET) -I     <sample.gr -o tmp && cmp tmp sample.c
-       ./$(TARGET) -I      sample.gr -o tmp && cmp tmp sample.c
-       ./$(TARGET) -I -O0 <sample.gr   >tmp && cmp tmp sample.c
-       ./$(TARGET) -I -=  <sample.gr   >tmp && cmp tmp sample.c
+test: $(TOOLEXENAME_G) sample.gr
+       $(TOOLEXENAME_G) -I     <sample.gr   >sample.c && $(CC) $(CFLAGS) -o sample sample.c && ./sample
+       $(TOOLEXENAME_G) -I      sample.gr   >tmp && cmp tmp sample.c
+       $(TOOLEXENAME_G) -I     <sample.gr -o tmp && cmp tmp sample.c
+       $(TOOLEXENAME_G) -I      sample.gr -o tmp && cmp tmp sample.c
+       $(TOOLEXENAME_G) -I -O0 <sample.gr   >tmp && cmp tmp sample.c
+       $(TOOLEXENAME_G) -I -=  <sample.gr   >tmp && cmp tmp sample.c
index f1b33edd9434f347723f2e5e790310ad66ceab34..164325dc976ab80a835b95ce1509649131b7cc8b 100644 (file)
@@ -306,6 +306,6 @@ extern int debugTables;
 
 extern void doStart ARGS((char *));
 extern void exit ARGS((int));
-extern int fatal ARGS((char *, int));
-extern void yyerror ARGS((char *));
-extern void yyerror1 ARGS((char *));
+extern int fatal ARGS((const char *, int));
+extern void yyerror ARGS((const char *));
+extern void yyerror1 ARGS((const char *));
index e7feab8d5ddb56e26d399c7f65232205113abe10..31db211a7006191fa690c660892c305c116ed503 100644 (file)
@@ -8,7 +8,7 @@ char rcsid_be[] = "$Id$";
 #define ERROR_VAL 0
 
 FILE *outfile;
-char *prefix = "burm";
+const char *prefix = "burm";
 
 static void doKids ARGS((RuleAST));
 static void doLabel ARGS((Operator));
@@ -24,7 +24,7 @@ static void printPatternAST_int ARGS((PatternAST));
 static void setVectors ARGS((PatternAST));
 static void trailing_zeroes ARGS((int));
 static int seminal ARGS((int from, int to));
-static void printRule ARGS((RuleAST, char *));
+static void printRule ARGS((RuleAST, const char *));
 
 static void
 doLabel(op) Operator op;
@@ -329,10 +329,10 @@ makeLHSmap()
                        fprintf(outfile, "\t0,\n");
                }
        }
-       fprintf(outfile, "};\n\n", prefix);
+       fprintf(outfile, "};\n\n");
 }
 
-static int seminal(from, to)
+static int seminal(int from, int to)
 {
        return allpairs[from][to].rule ? allpairs[from][to].rule->erulenum : 0;
 
@@ -453,7 +453,7 @@ makeDeltaCostArray()
        for (s = 0; s < states-1; s++) {
                fprintf(outfile, "{ /* state #%d: ", s+1);
                printRepresentative(outfile, sortedStates[s]);
-               fprintf(outfile, " */\n", s+1);
+               fprintf(outfile, " */\n");
                fprintf(outfile, "\t{0},\n");
                for (nt = 1; nt < last_user_nonterminal; nt++) {
                        makeCostVector(1, sortedStates[s]->closed[nt].delta);
@@ -616,7 +616,7 @@ makeNts()
 }
 
 static void
-printRule(r,d) RuleAST r; char *d;
+printRule(RuleAST r, const char *d)
 {
        if (r) {
                fprintf(outfile, "%s: ", r->rule->lhs->name);
index 5cef79bbe1477de93d05ff8fbb0812a03dde4ef8..70e98e22153a73043265ce0e2397b07fe78b2087 100644 (file)
@@ -121,7 +121,7 @@ extern int  max_ruleAST;
 extern List    ruleASTs;
 
 extern FILE    *outfile;
-extern char    *prefix;
+extern const char *prefix;
 extern int     trimflag;
 extern int     speedflag;
 extern int     grammarflag;
diff --git a/utils/Burg/gram.y b/utils/Burg/gram.y
deleted file mode 100644 (file)
index f6f16fa..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-%{
-char rcsid_gram[] = "$Id$";
-
-#include <stdio.h>
-#include "b.h"
-#include "fe.h"
-%}
-
-%union {
-       int y_int;
-       char *y_string;
-       Arity y_arity;
-       Binding y_binding;
-       PatternAST y_patternAST;
-       RuleAST y_ruleAST;
-       List y_list;
-       IntList y_intlist;
-}
-
-%start full
-
-%term ERROR
-%term K_TERM
-%term K_GRAM
-%term K_START
-%term K_PPERCENT
-%term INT
-%term ID
-
-%token <y_string> ID
-%token <y_int> INT
-
-%type <y_arity> decl
-%type <y_binding> binding
-%type <y_intlist> cost costtail
-%type <y_ruleAST> rule
-%type <y_patternAST> pattern
-%type <y_list> decls rules bindinglist grammarlist
-%%
-
-
-full   : spec
-       | spec K_PPERCENT
-               { yyfinished(); }
-       ;
-
-spec   : decls K_PPERCENT rules
-               = { doSpec($1, $3); }
-       ;
-
-decls  : /* lambda */  = { $$ = 0; }
-       | decls decl    = { $$ = newList($2, $1); }
-       ;
-
-decl   : K_TERM bindinglist    = { $$ = newArity(-1, $2); }
-       | K_GRAM grammarlist    = { $$ = 0; doGram($2); }
-       | K_START ID            = { $$ = 0; doStart($2); }      /* kludge */
-       ;
-
-grammarlist    : /* lambda */          = { $$ = 0; }
-               | grammarlist ID        = { $$ = newList($2, $1); }
-               ;
-
-bindinglist    : /* lambda */          = { $$ = 0; }
-               | bindinglist binding   = { $$ = newList($2, $1); }
-               ;
-
-binding        : ID '=' INT    = { $$ = newBinding($1, $3); }
-       ;
-
-rules  : /* lambda */  = { $$ = 0; }
-       | rules rule    = { $$ = newList($2, $1); }
-       ;
-
-rule   : ID ':' pattern '=' INT cost ';'       = { $$ = newRuleAST($1, $3, $5, $6); }
-               ;
-
-pattern        : ID                                    = { $$ = newPatternAST($1, 0); }
-       | ID '(' pattern ')'                    = { $$ = newPatternAST($1, newList($3,0)); }
-       | ID '(' pattern ',' pattern ')'        = { $$ = newPatternAST($1, newList($3, newList($5, 0))); }
-       ;
-
-cost   : /* lambda */          = { $$ = 0; }
-       | '(' INT costtail ')'  = { $$ = newIntList($2, $3); }
-       ;
-
-costtail       : /* lambda */          = { $$ = 0; }
-               | ',' INT costtail      = { $$ = newIntList($2, $3); }
-               | INT costtail          = { $$ = newIntList($1, $2); }
-               ;
diff --git a/utils/Burg/gram.yc b/utils/Burg/gram.yc
new file mode 100644 (file)
index 0000000..ec692c3
--- /dev/null
@@ -0,0 +1,91 @@
+%{
+char rcsid_gram[] = "$Id$";
+
+#include <stdio.h>
+#include "b.h"
+#include "fe.h"
+int doGram(List);
+%}
+
+%union {
+       int y_int;
+       char *y_string;
+       Arity y_arity;
+       Binding y_binding;
+       PatternAST y_patternAST;
+       RuleAST y_ruleAST;
+       List y_list;
+       IntList y_intlist;
+}
+
+%start full
+
+%term ERROR
+%term K_TERM
+%term K_GRAM
+%term K_START
+%term K_PPERCENT
+%term INT
+%term ID
+
+%token <y_string> ID
+%token <y_int> INT
+
+%type <y_arity> decl
+%type <y_binding> binding
+%type <y_intlist> cost costtail
+%type <y_ruleAST> rule
+%type <y_patternAST> pattern
+%type <y_list> decls rules bindinglist grammarlist
+%%
+
+
+full   : spec
+       | spec K_PPERCENT
+               { yyfinished(); }
+       ;
+
+spec   : decls K_PPERCENT rules
+               = { doSpec($1, $3); }
+       ;
+
+decls  : /* lambda */  = { $$ = 0; }
+       | decls decl    = { $$ = newList($2, $1); }
+       ;
+
+decl   : K_TERM bindinglist    = { $$ = newArity(-1, $2); }
+       | K_GRAM grammarlist    = { $$ = 0; doGram($2); }
+       | K_START ID            = { $$ = 0; doStart($2); }      /* kludge */
+       ;
+
+grammarlist    : /* lambda */          = { $$ = 0; }
+               | grammarlist ID        = { $$ = newList($2, $1); }
+               ;
+
+bindinglist    : /* lambda */          = { $$ = 0; }
+               | bindinglist binding   = { $$ = newList($2, $1); }
+               ;
+
+binding        : ID '=' INT    = { $$ = newBinding($1, $3); }
+       ;
+
+rules  : /* lambda */  = { $$ = 0; }
+       | rules rule    = { $$ = newList($2, $1); }
+       ;
+
+rule   : ID ':' pattern '=' INT cost ';'       = { $$ = newRuleAST($1, $3, $5, $6); }
+               ;
+
+pattern        : ID                                    = { $$ = newPatternAST($1, 0); }
+       | ID '(' pattern ')'                    = { $$ = newPatternAST($1, newList($3,0)); }
+       | ID '(' pattern ',' pattern ')'        = { $$ = newPatternAST($1, newList($3, newList($5, 0))); }
+       ;
+
+cost   : /* lambda */          = { $$ = 0; }
+       | '(' INT costtail ')'  = { $$ = newIntList($2, $3); }
+       ;
+
+costtail       : /* lambda */          = { $$ = 0; }
+               | ',' INT costtail      = { $$ = newIntList($2, $3); }
+               | INT costtail          = { $$ = newIntList($1, $2); }
+               ;
index 3d6c5af5c48131b1c08ad2689978d1477b533b55..85eb8a738faf8e8f303272c87e00a65244ca854c 100644 (file)
@@ -5,7 +5,7 @@ char rcsid_lex[] = "$Id$";
 #include <string.h>
 #include "b.h"
 #include "fe.h"
-#include "y.tab.h"
+#include "gram.tab.h"
 
 static char buf[BUFSIZ];
 
@@ -245,14 +245,13 @@ yylex()
        return(0);
 }
 
-void
-yyerror1(str) char *str;
+void yyerror1(const char *str)
 {
        fprintf(stderr, "line %d: %s", yyline, str);
 }
 
 void
-yyerror(str) char *str;
+yyerror(const char *str)
 {
        yyerror1(str);
        fprintf(stderr, "\n");
index af88dd61ea9ce5fb3a260ae69ec0c075fa84795b..71fd7d49442c4aff97fecde2bdff35500ec08810 100644 (file)
@@ -2,6 +2,7 @@ char rcsid_nonterminal[] = "$Id$";
 
 #include "b.h"
 #include <stdio.h>
+#include <string.h>
 
 NonTerminal    start;
 NonTerminalNum max_nonterminal = 1;
@@ -29,7 +30,6 @@ int
 nonTerminalName(buf, i) char *buf; int i;
 {
        List l;
-       extern char *strcpy ARGS((char *, char *));
 
        for (l = nonterminals; l; l = l->next) {
                NonTerminal nt = (NonTerminal) l->x;
index 053304eafc30765b9864668a236c542ed2e79a5f..e6ba38ba8075a88fc59862ef560eea4f74b7dd36 100644 (file)
@@ -2,6 +2,7 @@ char rcsid_plank[] = "$Id$";
 
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include "b.h"
 #include "fe.h"
 
@@ -35,7 +36,7 @@ static void purgePlanks ARGS((List));
 static void inToEx ARGS((void));
 static void makePlankRuleMacros ARGS((void));
 static void makePlankRule ARGS((void));
-static void exceptionSwitch ARGS((List, char *, char *, char *, int, char *));
+static void exceptionSwitch ARGS((List, const char *, const char *, const char *, int, const char *));
 static void doPlankLabel ARGS((Operator));
 static void doPlankLabelSafely ARGS((Operator));
 static void doPlankLabelMacrosSafely ARGS((Operator));
@@ -602,7 +603,7 @@ makePlankRule()
 }
 
 static void
-exceptionSwitch(es, sw, pre, post, offset, def) List es; char *sw; char *pre; char *post; int offset; char *def;
+exceptionSwitch(es, sw, pre, post, offset, def) List es; const char *sw; const char *pre; const char *post; int offset; const char *def;
 {
        if (es) {
                fprintf(outfile, "\t\tswitch (%s) {\n", sw);
index bd50217308e1dd5efb1a88d1adffc9c70f627d7a..9128e4280f20b73c6e12418a2d4818d71d1265be 100644 (file)
@@ -9,7 +9,7 @@ extern void free ARGS((void *));
 extern void *malloc ARGS((unsigned));
 
 int
-fatal(name, line) char *name; int line;
+fatal(const char *name, int line)
 {
        fprintf(stderr, "assertion failed: file %s, line %d\n", name, line);
        exit(1);