Top Level Namespace

Defined in:

Constant Summary

CONTEXTS = ["in_function main"]
IPCIN = [] of String
KWS = {"typeof" => ->(x : String, y : Int32) do _typeof_(x, y) end, "print" => ->(x : String, y : Int32) do _print_(x) end, "puts" => ->(x : String, y : Int32) do _puts_(x) end, "p" => ->(x : String, y : Int32) do _p_(x) end, "eval" => ->(x : String, y : Int32) do eval(x) return {"", 0} end, "ceval" => ->(x : String, y : Int32) do ceval(x) return {"", 0} end, "after" => ->(x : String, y : Int32) do _after_(x, y) return {"", 0} end, "def" => ->(x : String, y : Int32) do _def_(x, y) return {"", 0} end, "return" => ->(x : String, y : Int32) do _return_(x, y) return {"", 0} end, "+" => ->(x : String, y : Int32) do r = plus(x, y) return {r, 0} end, "-" => ->(x : String, y : Int32) do r = minus(x, y) return {r, 0} end, "*" => ->(x : String, y : Int32) do r = mul(x, y) return {r, 0} end, "/" => ->(x : String, y : Int32) do r = div(x, y) return {r, 0} end, "inc" => ->(x : String, y : Int32) do inc(x, y) end, "dec" => ->(x : String, y : Int32) do dec(x, y) end, "<" => ->(x : String, y : Int32) do r = Code._lower_(x, y) return {"", r} end, ">" => ->(x : String, y : Int32) do r = _higher_(x, y) return {"", r} end, "if" => ->(x : String, y : Int32) do r = Code._if_(x, y) return {"", r} end, "eq" => ->(x : String, y : Int32) do r = Code._if_(x, y) return {"", r} end, "while" => ->(x : String, y : Int32) do Code._while_(x, y) return {"", 0} end, "end" => ->(x : String, y : Int32) do Code._end_ return {"", 0} end, "every" => ->(x : String, y : Int32) do t = Timer.new r = t.start_timer(x, y) return {"", r} end, "ls" => ->(x : String, y : Int32) do ls(x, y) return {"", 0} end, "vars" => ->(x : String, y : Int32) do ls("vars", 1) return {"", 0} end, "let" => ->(x : String, y : Int32) do let(x, y) return {"", 0} end, "=" => ->(x : String, y : Int32) do let(x, y) return {"nil", 0} end, "delete" => ->(x : String, y : Int32) do _delete_(x) return {"", 0} end, "clear" => ->(x : String, y : Int32) do clear(x) return {"", 0} end, "!" => ->(x : String, y : Int32) do system(x) return {"", 0} end, "now" => ->(x : String, y : Int32) do return {Time.local.to_s("%H:%M:%S.%6N"), 0} end, "date" => ->(x : String, y : Int32) do return {Time.local.to_s("%Y-%m-%d"), 0} end, "test" => ->(x : String, y : Int32) do procloop return {"", 0} end, "sleep" => ->(x : String, y : Int32) do sleep(x.to_f) return {"", 0} end, "pass" => ->(x : String, y : Int32) do pass return {"", 0} end, "cls" => ->(x : String, y : Int32) do print("\ec\e[3J") return {"", 0} end, "load" => ->(x : String, y : Int32) do Code.load(x) return {"", 0} end, "run" => ->(x : String, y : Int32) do Code.current_line = 0 CONTEXTS.clear Code.run(( x)) return {"", 0} end, "split_run" => ->(x : String, y : Int32) do Code.split_run return {"", 0} end, "help" => ->(x : String, y : Int32) do help(x) return {"", 0} end, "debug" => ->(x : String, y : Int32) do Code.debug = !Code.debug return {Code.debug.to_s, 0} end, "singlestep" => ->(x : String, y : Int32) do VARS["singlestep"] = !VARS["singlestep"] return {VARS["singlestep"].to_s, 0} end, "inject" => ->(x : String, y : Int32) do Code.inject = !Code.inject return {Code.inject.to_s, 0} end, "system" => ->(x : String, y : Int32) do _system_(x) end, "exit" => ->(x : String, y : Int32) do exit(0) return {"", 0} end, "Array" => ->(x : String, y : Int32) do _array_(x, y) return {"", 0} end, "append" => ->(x : String, y : Int32) do _append_(x, y) return {"", 0} end, "list" => ->(x : String, y : Int32) do Code.list(x) return {"", 0} end, "log" => ->(x : String, y : Int32) do Tlog.info(check_args(x)) return {"", 0} end, "clear_log" => ->(x : String, y : Int32) do Tlog.clearlog() return {"", 0} end, "insert_line" => ->(x : String, y : Int32) do Code.insert(x, y) return {"", 0} end, "write_line" => ->(x : String, y : Int32) do Code.write(x, y) return {"", 0} end, "delete_line" => ->(x : String, y : Int32) do Code.delete(x) return {"", 0} end, "open_ipc" => ->(x : String, y : Int32) do open_ipc() return {"", 0} end, "send_ipc" => ->(x : String, y : Int32) do send_ipc(x) return {"", 0} end, "receive_ipc" => ->(x : String, y : Int32) do receive_ipc() end, "send_receive_ipc" => ->(x : String, y : Int32) do send_receive_ipc(x) end, "show_ipc_results" => ->(x : String, y : Int32) do show_ipc_results(x) return {"", 0} end, "read_int_var" => ->(x : String, y : Int32) do return {"", Code.functions[Code.cfu][x]} end}
OP = {"eq", "=", "/", "*", "-", "+", "append"}
STACK = [] of Int32
Tlog = Mylog.new
VARS = {"started" => true, "filename" => "", "lines" => 0, "interactive" => true, "STDIN" => STDIN}

Method Summary

Method Detail

def _after_(x : String, y : Int32) #

after() call function after x seconds


[View source]
def _append_(x : String, y : Int32) #

append() to an array "a << b" of type Int32|String|Float64


[View source]
def _array_(x : String, y : Int32) #

construct a new array store the array in function "eval" context Array.new(1,2,3)


[View source]
def _def_(x : String, y : Int32) #

def()= implmement functions


[View source]
def _delete_(x : String) #

delete() delete a var by name in the hash


[View source]
def _higher_(x : String, y : Int32) #

higher ">" operator


[View source]
def _p_(x : String) #

p()=


[View source]
def _print_(x : String) #

print()=


[View source]
def _puts_(x : String) #

puts()=


[View source]
def _return_(x : String, y : Int32) #

return() implement return from interpreted functions


[View source]
def _system_(x : String) #

system() make system call return result as String


[View source]
def _typeof_(x : String, y : Int32) #

typeof()=


[View source]
def add(in1 : Float64, in2 : Float64) #

[View source]
def add(in1 : Int32, in2 : Int32) #

[View source]
def ceval(line) #

eval a line by
passing the line to the crystal binary


[View source]
def check_args(rol, joinchar = "") #

check the rest of line if names can be replaced by values or function results use before printing check_args()=


[View source]
def check_equal(line : String) #

[View source]
def check_fun(word, rol) #

check_fun()=


[View source]
def check_name(arg : String) #

check_name()= check if a var with that name exists and return the value, give an error if not found


[View source]
def check_two_numbers(in1, in2) #

check_two_numbers() for their type and return numbers with the same type


[View source]
def clear(x : String) #

clear all vars in the hashes


[View source]
def dec(x : String, y : Int32) #

dec()
decrement var value works for int32 gives error for float


[View source]
def div(x : String, y : Int32) #

div() div value example: counter/= 3 "counter / = 3" # 4 token "a = b / 1" # 5 token


[View source]
def div(in1 : Float64, in2 : Float64) #

[View source]
def div(in1 : Int32, in2 : Int32) #

[View source]
def eval(line) #

eval()= eval (interactive mode) a line by search for operators and looking up the commands in the keyword hash


[View source]
def eval2(ind) #

eval2()= (scripting mode) a line by search for operators and looking up the commands in the keyword hash


[View source]
def find_args(op : String) #

find_args() find 2 args and the operatpr for math operation


[View source]
def full_split(line) #

full_split()= is only run once per line eval or a fresh loadad file ! split line into words by blank seperate operators from var names returns an array of strings ["a","=","1"]


[View source]
def functions_filtered(d) #

[View source]
def help(arg) #

[View source]
def inc(x : String, y : Int32) #

inc() increment var value works for int32 gives error for float


[View source]
def inside_quotes?(char, line, pos) #

check if a char in a line is quoted argument char defines the quotes used e.g. " or ' or any other char


[View source]
def iterate(res) #

iterate() over simple math operators until a single result is returned


[View source]
def let(x : String, y : Int32) #

let()= set var to result of function set var to a value or set var to other var myintvar> = 7 mystringvar> = "some test" a = b


[View source]
def lookup_var(x : String) #

lookup_var()= check if a var with that name exists and return the value give error when not found


[View source]
def ls(x : String, y : Int32) #

ls()= list VARS and/or functions


[View source]
def method_err(fn, x, y) #

method_err() args: (name,input string,number of args)


[View source]
def minus(x : String, y : Int32) #

minus() sub value example: counter-=3 "counter - = 3" # 4 token "a = b - 1" # 5 token


[View source]
def mul(x : String, y : Int32) #

mul() mul value example: counter*= 3 "counter * = 3" # 4 token "a = b * 1" # 5 token


[View source]
def mul(in1 : Float64, in2 : Float64) #

[View source]
def mul(in1 : Int32, in2 : Int32) #

[View source]
def open_ipc #

open_IPC()


[View source]
def p_time #

[View source]
def pass #

do nothing


[View source]
def plus(x : String, y : Int32) #

plus() add value to a var example: counter+= 3 "counter + = 3" # 4 token "a = b + 1" # 5 token


[View source]
def procloop #

[View source]
def prompt #

[View source]
def quoted_test #

test the quoted functions


[View source]
def read_command #

read line from STDIN


[View source]
def readvar(varname, context = Code.cfu) #

readvar()


[View source]
def receive_ipc #

receive_ipc()


[View source]
def repl #

run interactive if no file given or file not found error handler: print out error message and backtrace


[View source]
def replace_var(x : String) #

replace_var()= check if a var with that name exists and return the value, give no error


[View source]
def replace_vars(rol) #

check the rest of line if names can be replaced by values or function results use before printing replace_vars()=


[View source]
def reset #

[View source]
def run_cmd(cmd, args) #

run cmd as a subprocess and capture the output


[View source]
def run_long_cmd(proc_stdin, proc_stdout) #

run cmd as a long running sub process in a fiber


[View source]
def search_help(arg) #

[View source]
def send_ipc(line) #

send_ipc()


[View source]
def send_receive_ipc(line) #

[View source]
def show_ipc_results(x) #

show_ipc_results() get ipc read result from ipc connection write result to stdout


[View source]
def split_operator_from_var(line, operator) #

quoted_test() split operator of type String by blank


[View source]
def sub(in1 : Float64, in2 : Float64) #

[View source]
def sub(in1 : Int32, in2 : Int32) #

[View source]
def unquote(x : String) #

[View source]
def writevar(varname, value, context = Code.cfu) #

writevar()


[View source]