COMPILER CAN COMPILE ITSELF. RESULTING COMPILER PASSES ALL TESTS.
This commit is contained in:
parent
2d18187413
commit
97bb506b54
5 changed files with 23 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,5 +2,6 @@
|
|||
*.o
|
||||
*.a
|
||||
bin/tamsin-*
|
||||
bin/bootstrapped-*
|
||||
bin/micro-tamsin
|
||||
tmp/
|
||||
|
|
|
@ -5,5 +5,6 @@ syntax: glob
|
|||
*.a
|
||||
|
||||
bin/tamsin-*
|
||||
bin/bootstrapped-*
|
||||
bin/micro-tamsin
|
||||
tmp/
|
||||
|
|
9
fixture/bootstrapped.markdown
Normal file
9
fixture/bootstrapped.markdown
Normal file
|
@ -0,0 +1,9 @@
|
|||
|
||||
-> Functionality "Intepret Tamsin program" is implemented by
|
||||
-> shell command
|
||||
-> "bin/bootstrapped-compiler <%(test-body-file) >tmp/foo.c && gcc -Werror -Ic_src -Lc_src tmp/foo.c -o tmp/foo -ltamsin && tmp/foo <%(test-input-file)"
|
||||
|
||||
-> Functionality "Intepret Tamsin program (pre- & post-processed)"
|
||||
-> is implemented by
|
||||
-> shell command "bin/bootstrapped-compiler <%(test-body-file) >tmp/foo.c && gcc -Werror -Ic_src -Lc_src tmp/foo.c -o tmp/foo -ltamsin && cat %(test-input-file) | bin/inhex | tmp/foo | bin/hexout"
|
||||
|
|
@ -13,7 +13,9 @@
|
|||
main = tamsin_parser:parse → AST & tamsin_scanner:skippable & eof &
|
||||
tamsin_analyzer:desugar(AST) → AST &
|
||||
tamsin_analyzer:analyze(nil, AST) → AST &
|
||||
compile(AST).
|
||||
tamsin_compiler:compile(AST).
|
||||
|
||||
tamsin_compiler {
|
||||
|
||||
prelude = $:emit('
|
||||
/*
|
||||
|
@ -628,10 +630,13 @@ escaped_r = A ← '' &
|
|||
"\\" & A ← A + '\\\\'
|
||||
| "\"" & A ← A + '\\"'
|
||||
| "\n" & A ← A + '\\n'
|
||||
| digit → B & (many_format_octal @ B) → B & A ← A + B
|
||||
| $:alnum → B & A ← A + B
|
||||
| any → B & (many_format_octal @ B) → B & A ← A + B
|
||||
} & A.
|
||||
|
||||
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9".
|
||||
|
||||
many_format_octal =
|
||||
S ← '' &
|
||||
{any → B & $:format_octal(B) → B & S ← S + '\\' + B} using $:byte &
|
||||
|
@ -684,3 +689,5 @@ emit_restore_state_locals(list(H,T)) =
|
|||
emit(H) &
|
||||
emitln(';') &
|
||||
emit_restore_state_locals(T).
|
||||
|
||||
}
|
||||
|
|
9
test.sh
9
test.sh
|
@ -156,12 +156,11 @@ elif [ x$1 = xtcompiler ]; then
|
|||
elif [ x$1 = xbootstrap ]; then
|
||||
echo "*** Compiling Bootstrapped Tamsin-in-Tamsin compiler..."
|
||||
./build.sh
|
||||
#bin/tamsin-compiler lib/list.tamsin lib/tamsin_scanner.tamsin \
|
||||
# lib/tamsin_parser.tamsin lib/tamsin_analyzer.tamsin \
|
||||
# mains/compiler.tamsin > tmp/foo.c && \
|
||||
bin/tamsin-compiler mains/compiler.tamsin > tmp/foo.c && \
|
||||
bin/tamsin-compiler lib/list.tamsin lib/tamsin_scanner.tamsin \
|
||||
lib/tamsin_parser.tamsin lib/tamsin_analyzer.tamsin \
|
||||
mains/compiler.tamsin > tmp/foo.c && \
|
||||
gcc -g -ansi -Werror \
|
||||
-Ic_src -Lc_src tmp/foo.c -o bin/boostrapped-compiler -ltamsin || exit 1
|
||||
-Ic_src -Lc_src tmp/foo.c -o bin/bootstrapped-compiler -ltamsin || exit 1
|
||||
echo "*** Testing Bootstrapped Tamsin-in-Tamsin compiler..."
|
||||
falderal $VERBOSE --substring-error fixture/bootstrapped.markdown $FILES
|
||||
elif [ x$1 = xmicro ]; then
|
||||
|
|
Loading…
Add table
Reference in a new issue