diff options
| author | Franklin Wei <git@fwei.tk> | 2015-11-21 19:59:55 -0500 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2015-11-21 19:59:55 -0500 |
| commit | f4e82feb2492b0bf466c3921b3e9fc9d056f3ea3 (patch) | |
| tree | ba27876ec89f652e007f36d40eeb645a798acbf4 /README.md | |
| parent | afc3e4b88e193025e49736e545ccb7765b19d1b5 (diff) | |
| download | ducky-f4e82feb2492b0bf466c3921b3e9fc9d056f3ea3.zip ducky-f4e82feb2492b0bf466c3921b3e9fc9d056f3ea3.tar.gz ducky-f4e82feb2492b0bf466c3921b3e9fc9d056f3ea3.tar.bz2 ducky-f4e82feb2492b0bf466c3921b3e9fc9d056f3ea3.tar.xz | |
fix C transcompiler REPEAT
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 49 |
1 files changed, 48 insertions, 1 deletions
@@ -30,6 +30,31 @@ Simple! IF iter < 20; GOTO loop_start LOG Done! +### Prime Counter + + #!/bin/ducky + LOG Counting... + NEWLINE + LET primes=0 + LET MAX=100000 + LET n = 2 + LBL test_number + LET iter = 2 + LET stop = sqrt n + LBL test_loop + IF !(n % iter); GOTO composite + INC iter + IF iter <= stop; GOTO test_loop + INC primes + LBL composite + INC n + IF n < MAX; GOTO test_number + LOG Number of primes below + LOGVAR MAX + LOG : + LOGVAR primes + NEWLINE + ## Building POSIX systems are supported, as are some Rockbox targets. @@ -57,10 +82,32 @@ This will create `a.out`, which contains the bytecode. ducky a.out +## Technical Details + +The program consists of four parts: the interpreter, compiler, bytecode interpreter, and C transcompiler. + +### Interpreter + +Executes ducky directly. + + +### Bytecode Compiler + +Compiles ducky to a stack-machine based bytecode. + +### Bytecode Interpreter + +Executes the bytecode generated by the bytecode compiler. + +### C Transcompiler + +Translates bytecode generated by the bytecode compiler into C. +Depends on labels as values, which is a GCC extension. + ## Future Directions - - Compile to C? - Refactor code + - Input - Add more builtins - Arrays? - Functions? |