Browse Source

Updated Makefile and ccmeta to chose to print either the tree the output

master
Nathan R 3 years ago
parent
commit
2eb5d2d26f
2 changed files with 25 additions and 5 deletions
  1. +14
    -2
      Makefile
  2. +11
    -3
      ccmeta.leg

+ 14
- 2
Makefile View File

@ -1,16 +1,27 @@
CFLAGS = -I/opt/local/include -std=gnu99 -Wall -Wno-unused-label -Wno-unused-function -g
LDLIBS = -L/opt/local/lib -lgc -lm
TREE = -t
MAIN = ccmeta
all : $(MAIN)
tree : all .FORCE
./$(MAIN) < $(MAIN)-tree.txt > $(MAIN)-tree.out
./$(MAIN) $(TREE) < $(MAIN)-input.txt > $(MAIN)-tree.out
test : all .FORCE
output : all .FORCE
./$(MAIN) < $(MAIN)-input.txt > $(MAIN)-output.out
diff $(MAIN)-input.txt $(MAIN)-output.out
test : output
./dotest
both : all .FORCE
./$(MAIN) $(TREE) < $(MAIN)-input.txt > $(MAIN)-tree.out
./$(MAIN) < $(MAIN)-input.txt > $(MAIN)-output.out
diff $(MAIN)-input.txt $(MAIN)-output.out
debug : all .FORCE
./$(MAIN) < debug.c > debug.out
gcc -o debug debug.c
@ -27,6 +38,7 @@ $(MAIN) : $(MAIN).c object.c buffer.h
clean : .FORCE
rm -f $(MAIN) $(MAIN).c
rm -f *~ $(MAIN)-output.out
tidy : .FORCE
rm -f *~ $(MAIN)-tree.out

+ 11
- 3
ccmeta.leg View File

@ -3733,7 +3733,6 @@ void outputTree(oop node, int depth)
}
#undef CASE
#undef OUT
//outputTree(map_get(node, comment_symbol), depth); // if we want to print comments
}
void printTree() {
@ -3741,6 +3740,8 @@ void printTree() {
printf("\n");
}
int toPrint = 0;
int main(int argc, char **argv)
{
# if (USE_GC)
@ -3798,13 +3799,19 @@ int main(int argc, char **argv)
#undef _DO
/* Checking arguments */
while (argc-- > 1) {
++argv;
if (!strcmp(*argv, "-t")) toPrint = 1;
}
/* File scope */
pushScope();
inputStackPush(NULL);
while (yyparse()) {
outputNode(yylval);
//printTree();
if (toPrint) printTree();
else outputNode(yylval);
}
popScope();
@ -3818,6 +3825,7 @@ int main(int argc, char **argv)
++argv;
if (!strcmp(*argv, "-g")) ++opt_g;
else if (!strcmp(*argv, "-v")) ++opt_v;
else if (!strcmp(*argv, "-t")) toPrint = 1;
else if (!strcmp(*argv, "-")) {
readEvalPrint(globals, NULL);
repled= 1;

Loading…
Cancel
Save