# YYDEBUG=-t
YYDEBUG=-v
CFLAGS = -DYYDEBUG=1

all: lextest yacctest

ex1 : y.tab.o lex.yy.o
	cc $(CFALGS) -g -o ex1 y.tab.o lex.yy.o -ll

y.tab.h y.tab.c :	ex.y
	yacc -d $(YYDEBUG) ex.y	
	cp y.tab.h small.h
lex.yy.c : 	ex.l y.tab.h
	lex ex.l

test: ex1
	./ex1 < exex.c

lextest:  small.l lextest.c y.tab.h lextest_yy.h
	lex small.l
	cc $(CFLAGS) -o lextest lextest.c lex.yy.c -ll

lextest_yy.h : y.tab.h
	perl gen_lextest.pl small.h > lextest_yy.h

yacctest: lextest small.y
	yacc -d $(YYDEBUG) small.y
	cc $(CFLAGS) -o yacctest y.tab.c lex.yy.c -ll

clean:
	rm -f y.tab.h y.tab.c lex.yy.c *.o lextest yacctest lextest_yy.h
