Minor improvements to how test programs are built
authorNick Downing <downing.nick@gmail.com>
Fri, 6 Jul 2018 06:41:49 +0000 (16:41 +1000)
committerNick Downing <downing.nick@gmail.com>
Fri, 6 Jul 2018 06:41:49 +0000 (16:41 +1000)
.gitignore
ast.py
tests/Makefile

index c841339..0843d67 100644 (file)
@@ -1,15 +1,9 @@
 __pycache__
+tests/*.c
+tests/*.o
+tests/*.xml
 tests/cal
-tests/cal.l.xml
-tests/cal.y.xml
 tests/flex0
-tests/flex0.c
-tests/flex0.l.xml
 tests/flex1
-tests/flex1.c
-tests/flex1.l.xml
-tests/lex.yy.c.orig
-tests/lex.yy.c
-tests/y.tab.c
 skel/lex.yy.c
 skel/lex.yy.c.orig
diff --git a/ast.py b/ast.py
index 718c80b..265c713 100644 (file)
--- a/ast.py
+++ b/ast.py
@@ -39,6 +39,7 @@ class Item(element.Element):
     raise NotImplementedException
 
 class PLex(element.Element):
+  # internal classes
   class StartCondition(element.Element):
     # GENERATE ELEMENT(str name, bool exclusive, int eof_action) BEGIN
     def __init__(
@@ -108,6 +109,7 @@ class PLex(element.Element):
       return 'ast.PLex.StartCondition({0:s})'.format(', '.join(params))
     # GENERATE END
 
+  # syntax classes
   class Name(element.Element):
     # GENERATE ELEMENT() BEGIN
     def __init__(
index b01e5d0..906dc82 100644 (file)
@@ -1,7 +1,13 @@
 all: cal flex0 flex1
 
-cal: y.tab.c lex.yy.c
-       gcc -o $@ $<
+# cal program
+cal: y.tab.o
+       ${CC} -o $@ $<
+
+y.tab.o: y.tab.c lex.yy.c
+
+y.tab.c: cal.y
+       ../../bootstrap_bison.git/src/bison -y $< 2>$<.xml
 
 lex.yy.c: cal.l
        ../../bootstrap_flex.git/src/flex -o /dev/null $< 2>$<.xml
@@ -10,19 +16,26 @@ lex.yy.c: cal.l
        #cp $@ $@.orig
        #patch $@ <$@.patch
 
-y.tab.c: cal.y
-       ../../bootstrap_bison.git/src/bison -y $< 2>$<.xml
-
-flex0: flex0.c
+# flex0 program
+flex0: flex0.o
        gcc -o $@ $< -ll
 
+flex0.o: flex0.c
+
 flex0.c: flex0.l
        ../../bootstrap_flex.git/src/flex -o /dev/null $< 2>$<.xml
        ../bootstrap_plex.py -o $@ $<.xml
 
-flex1: flex1.c
+# flex1 program
+flex1: flex1.o
        gcc -o $@ $< -ll
 
+flex1.o: flex1.c
+
 flex1.c: flex1.l
        ../../bootstrap_flex.git/src/flex -o /dev/null $< 2>$<.xml
        ../bootstrap_plex.py -o $@ $<.xml
+
+# other
+clean:
+       rm -f *.c *.o *.xml cal flex0 flex1