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