diff options
| -rw-r--r-- | src/false/false.cr | 39 | ||||
| -rw-r--r-- | src/false/program.cr | 9 | ||||
| -rw-r--r-- | src/flint.cr | 4 |
3 files changed, 52 insertions, 0 deletions
diff --git a/src/false/false.cr b/src/false/false.cr new file mode 100644 index 0000000..e26fd89 --- /dev/null +++ b/src/false/false.cr @@ -0,0 +1,39 @@ +require "big.cr" + +module False + + enum Command + DUP # ( n -- n n ) + DROP # ( n1 n2 -- n1 ) + SWAP # ( n1 n2 -- n2 n1 ) + ROT # ( n1 n2 n3 -- n2 n3 n1 ) + PICK # push the n-th stack item (top of stack is index 0) + ADD # ( n1 n2 -- (n1+n2) ) + SUBTRACT # ( n1 n2 -- (n1-n2) ) + MULTIPLY # ( n1 n2 -- (n1-n2) ) + DIVIDE # ( n1 n2 -- (n1/n2) ) + NEGATE # ( n1 -- (-1*n1) ) + BAND # ( n1 n2 -- (n1&n2) ) + BOR # ( n1 n2 -- (n1|n2) ) + BNOT # invert each bit of top of the stack + GREATER # ( n1 n2 -- (n1>n2) ) + EQUAL # ( n1 n2 -- (n1==n2) ) + EXECUTE # lambda execution + CONDITIONAL # ( cond lambda -- ... ) execute lambda if cond is true, pops both + LOOP # ( cond lambda -- ... ) execute lambda repeatedly until cond is false, then pop both + STORE # ( value reference -- ) stores value at the given variable reference, pops both + FETCH # ( reference -- ) pops the reference and pushes the value stored at the reference + READ # read character from STDIN and push its character code + WRITE_CHAR # pop the stack and print the value's character ("65," prints "A") + WRITE_INT # pop the stack and print the value as an integer ("65." prints "65") + FLUSH # flush input and output buffers + end + + alias PushInt = BigInt # int literal pushes int + alias PushCharCode = Char # char literal ( 'c ) pushes char + alias PushVarRef = Char # variable name pushes its address + alias WriteString = String # string literal prints the string + + alias Operation = Command | PushInt | PushCharCode | PushVarRef | WriteString +end + diff --git a/src/false/program.cr b/src/false/program.cr new file mode 100644 index 0000000..18ce3ef --- /dev/null +++ b/src/false/program.cr @@ -0,0 +1,9 @@ +require "./false.cr" +require "../program.cr" + +struct False::Program < Flint::Program + def interpret : Nil + puts "TODO" + end +end + diff --git a/src/flint.cr b/src/flint.cr index d6de3f4..4fe0ef1 100644 --- a/src/flint.cr +++ b/src/flint.cr @@ -6,6 +6,7 @@ require "./util.cr" require "./program.cr" require "./among_us/*" require "./brainfuck/*" +require "./false/program.cr" require "./thue/*" module Flint @@ -14,6 +15,7 @@ module Flint enum Language AmongUs Brainfuck + False Thue end @@ -93,6 +95,8 @@ module Flint program = case language.not_nil! in Language::AmongUs AmongUs::Program.new(source_io) + in Language::False + False::Program.new(source_io) in Language::Brainfuck begin m_str = language_options[:memory_size]? |
