aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2015-11-21 19:59:55 -0500
committerFranklin Wei <git@fwei.tk>2015-11-21 19:59:55 -0500
commitf4e82feb2492b0bf466c3921b3e9fc9d056f3ea3 (patch)
treeba27876ec89f652e007f36d40eeb645a798acbf4 /README.md
parentafc3e4b88e193025e49736e545ccb7765b19d1b5 (diff)
downloadducky-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.md49
1 files changed, 48 insertions, 1 deletions
diff --git a/README.md b/README.md
index eba809a..c2e67fa 100644
--- a/README.md
+++ b/README.md
@@ -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?