all: compile.c  grammar.g  lang.c  lex.c  lex.h  Makefile  parser.h  show_ast.c   ../check-missing.c  ../generate-compiler.c  ../parser.c  ../regexp-lexer.c  ../regexp-lexer.h  ../symtab.c  ../symtab.h  ../symtab_priv.h  ../takeon.c  ../update_astcode.c
	grep ^//\\\\ lang.c > grammar.g
	ecce grammar.g --command "(v.//\\\\ .s..m,m)0m-0(r0 (v-/ /e-)0 m)0 m-0 (rm,k)0 m-0 (r0v-/;/b,m)0 m-0 (v/B/\m,mr\j,m)0 m0 (m-v/B/\)0 mb;%c" > /dev/null 2>&1
	cc -g -o ./bin/takeon ../takeon.c
	./bin/takeon grammar.g > parser.h
	cc -g -o ./bin/update_astcode    -I. -DINCLUDE="\"parser.h\"" -Wno-format-extra-args ../update_astcode.c
	./bin/update_astcode > lang-new.c
	mv lang.c lang.c.PREV
	mv lang-new.c lang.c
	cc -g -o ./bin/check-missing     -I. -DTABLE="\"parser.h\"" ../check-missing.c
	cc -g -o ./bin/generate-compiler -I. -DTABLE="\"parser.h\"" ../generate-compiler.c
	./bin/generate-compiler > compile.c
	cc -O                   -I. -DLEX_H="\"lex.h\"" -DLEX_C="\"lex.c\"" -DTABLE="\"parser.h\"" -DINCLUDE="\"lang.c\"" -DCOMPILE="\"compile.c\"" -Wno-div-by-zero -o ./bin/parser-opt ../parser.c
	cc -g -DCHECK_INDEXES=1 -I. -DLEX_H="\"lex.h\"" -DLEX_C="\"lex.c\"" -DTABLE="\"parser.h\"" -DINCLUDE="\"lang.c\"" -DCOMPILE="\"compile.c\"" -Wno-div-by-zero -o ./bin/parser     ../parser.c
	#ctohtml compile.c > compile.c.html
	#ctohtml lang.c > lang.c.html
	#ctohtml compile.c > compile.c.html
	#ctohtml lex.c > lex.c.html
	#ctohtml ../parser.c > parser.c.html
	#ctohtml ../regexp-lexer.c > regexp-lexer.c.html
        
clean:
	rm -f *~ bin/* *.[ch].html
