2016-05-15 22:07:44 +00:00
|
|
|
.PHONY: all check default
|
2016-07-27 06:49:45 +00:00
|
|
|
CFLAGS:=-std=c99 -O3 -finline-functions
|
2016-10-10 20:55:37 +00:00
|
|
|
#CFLAGS:=-pg -std=c99 -O3 -finline-functions
|
2016-07-27 06:49:45 +00:00
|
|
|
#CFLAGS:=-std=c99 -g
|
|
|
|
|
2016-05-15 22:07:44 +00:00
|
|
|
default: all
|
|
|
|
|
2016-07-18 20:43:16 +00:00
|
|
|
all: mes
|
2016-05-15 22:07:44 +00:00
|
|
|
|
2016-07-09 21:12:25 +00:00
|
|
|
mes: mes.c mes.h
|
|
|
|
|
|
|
|
mes.h: mes.c GNUmakefile
|
2016-07-22 10:23:23 +00:00
|
|
|
( echo '#if MES_C'; echo '#if MES_FULL' 1>&2;\
|
2016-07-11 19:50:59 +00:00
|
|
|
grep -E '^(scm [*])*[a-z0-9_]+ \(.*\)( {|$$)' $< | grep -Ev '\(.*(char |bool |int )' | sed -e 's,^scm [*],,' | sort |\
|
2016-07-09 21:12:25 +00:00
|
|
|
while read f; do\
|
|
|
|
fun=$$(echo $$f | sed -e 's,^scm [*],,' -e 's,{.*,,');\
|
|
|
|
name=$$(echo $$fun | sed -e 's,^scm [\*],,' | grep -o '^[^ ]*');\
|
2016-07-11 08:38:02 +00:00
|
|
|
scm_name=$$(echo $$name | sed -e 's,_to_,->,' -e 's,_p$$,?,' -e 's,_x$$,!,' -e 's,^builtin_,,' -re 's,(.*)_$$,c:\1,' | sed \
|
2016-07-10 10:52:53 +00:00
|
|
|
-e 's,^divide$$,/,'\
|
|
|
|
-e 's,^is?$$,=,'\
|
2016-07-16 11:24:38 +00:00
|
|
|
-e 's,^greater?$$,>,'\
|
2016-07-10 10:52:53 +00:00
|
|
|
-e 's,^less?$$,<,'\
|
|
|
|
-e 's,^minus$$,-,'\
|
|
|
|
-e 's,^multiply$$,*,'\
|
|
|
|
-e 's,^plus$$,+,'\
|
|
|
|
-e 's,_,-,g');\
|
2016-07-09 21:12:25 +00:00
|
|
|
args=$$(echo $$fun | grep -o 'scm [\*]' | wc -l);\
|
2016-07-10 20:43:23 +00:00
|
|
|
[ "$$(echo $$fun | fgrep -o ... )" = "..." ] && args=n;\
|
2016-07-09 21:12:25 +00:00
|
|
|
echo "scm *$$fun;";\
|
|
|
|
echo "scm scm_$$name = {FUNCTION$$args, .name=\"$$scm_name\", .function$$args=&$$name};";\
|
|
|
|
echo "a = add_environment (a, \"$$scm_name\", &scm_$$name);" 1>&2;\
|
|
|
|
done; echo '#endif'; echo '#endif' 1>&2) > $@ 2>environment.i
|
2016-10-08 06:41:30 +00:00
|
|
|
grep -oE '^scm ([a-z_]+) = {SYMBOL,' mes.c | cut -d' ' -f 2 |\
|
|
|
|
while read f; do\
|
|
|
|
echo "symbols = cons (&$$f, symbols);";\
|
|
|
|
done > symbols.i
|
2016-07-09 21:12:25 +00:00
|
|
|
|
2016-10-08 06:38:29 +00:00
|
|
|
check: all guile-check mes-check
|
|
|
|
|
|
|
|
mes-check: all
|
2016-07-25 12:39:56 +00:00
|
|
|
# ./mes.test
|
|
|
|
# ./mes.test ./mes
|
2016-10-08 14:54:59 +00:00
|
|
|
cat base0.mes base0-if.mes base.mes lib/test.mes test/base.test | ./mes
|
|
|
|
cat base0.mes base0-if.mes base.mes lib/test.mes test/closure.test | ./mes
|
|
|
|
cat base0.mes base0-if.mes base.mes quasiquote.mes lib/test.mes test/quasiquote.test | ./mes
|
|
|
|
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes lib/test.mes test/let.test | ./mes
|
|
|
|
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes lib/srfi/srfi-0.scm scm.mes lib/test.mes test/scm.test | ./mes
|
2016-10-10 21:24:44 +00:00
|
|
|
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes lib/srfi/srfi-0.scm scm.mes syntax.mes lib/record.mes lib/record.scm lib/srfi/srfi-9.scm lib/test.mes test/record.test |./mes
|
2016-10-11 16:51:30 +00:00
|
|
|
ifneq ($(SYNTAX),)
|
2016-10-10 20:55:37 +00:00
|
|
|
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes scm.mes syntax.mes let-syntax.mes lib/srfi/srfi-0.scm lib/test.mes test/let-syntax.test | ./mes
|
2016-10-11 16:51:30 +00:00
|
|
|
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes scm.mes syntax.mes let-syntax.mes lib/srfi/srfi-0.scm lib/match.scm lib/test.mes test/match.test | ./mes
|
|
|
|
else
|
|
|
|
@echo skipping slooowwww syntax tests
|
|
|
|
endif
|
2016-07-09 11:23:58 +00:00
|
|
|
|
2016-07-23 13:17:03 +00:00
|
|
|
guile-check:
|
2016-07-25 12:39:56 +00:00
|
|
|
guile -s <(cat base.mes lib/test.mes test/base.test)
|
|
|
|
guile -s <(cat base.mes lib/test.mes test/closure.test)
|
|
|
|
guile -s <(cat base.mes lib/test.mes test/quasiquote.test)
|
|
|
|
guile -s <(cat quasiquote.mes lib/test.mes test/quasiquote.test)
|
2016-07-27 06:49:45 +00:00
|
|
|
# guile -s <(cat base.mes quasiquote.mes let.mes lib/test.mes test/let.test)
|
2016-07-25 12:39:56 +00:00
|
|
|
# guile -s <(cat base.mes let.mes test/foo.test)
|
|
|
|
# exit 1
|
|
|
|
guile -s <(cat lib/test.mes test/base.test)
|
|
|
|
guile -s <(cat lib/test.mes test/quasiquote.test)
|
|
|
|
guile -s <(cat lib/test.mes test/let.test)
|
|
|
|
guile -s <(cat quasiquote.mes lib/test.mes test/base.test)
|
|
|
|
guile -s <(cat quasiquote.mes lib/test.mes test/quasiquote.test)
|
2016-10-10 21:24:44 +00:00
|
|
|
guile -s <(cat lib/test.mes test/record.test)
|
2016-10-11 16:51:30 +00:00
|
|
|
guile -s <(cat lib/test.mes test/let-syntax.test)
|
|
|
|
guile -s <(cat lib/test.mes test/match.test)
|
2016-07-23 13:17:03 +00:00
|
|
|
|
2016-07-09 11:23:58 +00:00
|
|
|
run: all
|
2016-07-09 13:16:30 +00:00
|
|
|
cat scm.mes test.mes | ./mes
|
2016-10-18 20:19:57 +00:00
|
|
|
|
2016-07-23 12:39:33 +00:00
|
|
|
psyntax: all
|
2016-10-08 14:54:59 +00:00
|
|
|
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes psyntax.mes psyntax.pp psyntax2.mes | ./mes
|
2016-07-23 12:39:33 +00:00
|
|
|
|
2016-07-23 22:40:37 +00:00
|
|
|
syntax-case: all
|
2016-10-08 14:54:59 +00:00
|
|
|
cat scm.mes syntax.mes syntax-case-lib.mes syntax-case.mes syntax-case-after.mes syntax-case-test.mes | ./mes
|
2016-07-23 22:40:37 +00:00
|
|
|
|
2016-10-10 21:24:44 +00:00
|
|
|
syntax-case.cat: syntax.mes syntax-case-lib.mes syntax-case.mes syntax-case-after.mes syntax-case-test.mes
|
2016-07-23 22:40:37 +00:00
|
|
|
cat $^ > $@
|
|
|
|
|
2016-10-10 21:24:44 +00:00
|
|
|
guile-syntax-case: syntax-case.cat
|
2016-07-23 22:40:37 +00:00
|
|
|
guile -s $^
|
|
|
|
|
2016-07-23 12:39:33 +00:00
|
|
|
peg: all
|
2016-10-08 14:54:59 +00:00
|
|
|
cat scm.mes syntax.mes syntax-case-lib.mes syntax-case.mes syntax-case-after.mes peg.mes peg/codegen.scm peg/string-peg.scm peg/simplify-tree.scm peg/using-parsers.scm peg/cache.scm peg-test.mes | ./mes
|
2016-07-23 12:39:33 +00:00
|
|
|
|
2016-10-10 21:24:44 +00:00
|
|
|
peg.cat: peg/pmatch.scm peg.mes peg/codegen.scm peg/string-peg.scm peg/simplify-tree.scm peg/using-parsers.scm peg/cache.scm peg-test.mes
|
2016-07-23 12:39:33 +00:00
|
|
|
cat $^ | sed 's,\(;; Packages the results of a parser\),(when (guile?) (set! compile-peg-pattern (@@ (ice-9 peg codegen) compile-peg-pattern)))\n\1,' > $@
|
|
|
|
|
2016-10-10 21:24:44 +00:00
|
|
|
guile-peg: peg.cat
|
2016-07-23 12:39:33 +00:00
|
|
|
# guile -s peg-test.mes
|
|
|
|
# @echo "======================================="
|
|
|
|
guile -s $^
|
|
|
|
|
|
|
|
clean:
|
2016-10-10 21:24:44 +00:00
|
|
|
rm -f mes environment.i symbol.i mes.h *.cat hello.o main.o a.out
|
2016-07-23 22:40:37 +00:00
|
|
|
|
2016-07-24 10:08:21 +00:00
|
|
|
paren: all
|
2016-10-08 14:54:59 +00:00
|
|
|
echo -e 'EOF\n___P((()))' | cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes scm.mes syntax.mes lib/srfi/srfi-0.scm lib/record.mes lib/record.scm lib/srfi/srfi-9.scm lib/lalr.mes lib/lalr.scm paren.scm - | ./mes
|
2016-07-24 10:08:21 +00:00
|
|
|
|
2016-10-10 21:24:44 +00:00
|
|
|
paren.cat: lib/lalr.scm paren.scm
|
2016-07-24 10:08:21 +00:00
|
|
|
cat $^ > $@
|
|
|
|
|
2016-10-10 21:24:44 +00:00
|
|
|
guile-paren: paren.cat
|
2016-07-24 10:08:21 +00:00
|
|
|
echo '___P((()))' | guile -s $^
|
2016-07-24 21:18:53 +00:00
|
|
|
|
2016-07-24 23:12:22 +00:00
|
|
|
mescc: all
|
2016-10-10 20:55:37 +00:00
|
|
|
echo ' EOF ' | cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes scm.mes syntax.mes let-syntax.mes lib/srfi/srfi-0.scm lib/record.mes lib/record.scm lib/srfi/srfi-9.scm lib/lalr.mes lib/lalr.scm lib/rnrs/bytevectors.scm lib/srfi/srfi-1.scm lib/match.scm lib/elf.mes c-lexer.scm mescc.scm - main.c | ./mes > a.out
|
2016-08-12 14:38:59 +00:00
|
|
|
chmod +x a.out
|
2016-07-24 23:12:22 +00:00
|
|
|
|
2016-10-10 21:24:44 +00:00
|
|
|
mescc.cat: lib/lalr.scm lib/rnrs/bytevectors.scm lib/srfi/srfi-1.scm lib/match.scm lib/elf.mes c-lexer.scm mescc.scm
|
2016-07-24 21:18:53 +00:00
|
|
|
cat $^ > $@
|
|
|
|
|
2016-10-10 21:24:44 +00:00
|
|
|
guile-mescc: mescc.cat
|
2016-08-13 23:44:42 +00:00
|
|
|
cat main.c | guile -s $^ > a.out
|
|
|
|
chmod +x a.out
|
2016-07-26 05:30:53 +00:00
|
|
|
|
|
|
|
hello.o: hello.S
|
|
|
|
as --32 -march=i386 -o $@ $^
|
|
|
|
|
|
|
|
hello: hello.o
|
|
|
|
ld -A i386 -m elf_i386 -nostdlib -nodefaultlibs -A i386 -o $@ $^
|
|
|
|
# ld -A i386 -m elf_i386 -A i386 -o $@ $^
|
2016-08-12 14:38:59 +00:00
|
|
|
|
2016-08-13 23:44:42 +00:00
|
|
|
a.out: lib/elf.mes elf.mes GNUmakefile
|
2016-10-08 14:54:59 +00:00
|
|
|
cat base0.mes base0-if.mes base.mes quasiquote.mes let.mes scm.mes lib/rnrs/bytevectors.scm lib/elf.mes elf.mes | ./mes > a.out
|
2016-08-12 14:38:59 +00:00
|
|
|
chmod +x a.out
|