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
-
_after_(x : String, y : Int32)
after() call function after x seconds
-
_append_(x : String, y : Int32)
append() to an array "a << b" of type Int32|String|Float64
-
_array_(x : String, y : Int32)
construct a new array store the array in function "eval" context Array.new(1,2,3)
-
_def_(x : String, y : Int32)
def()= implmement functions
-
_delete_(x : String)
delete() delete a var by name in the hash
-
_higher_(x : String, y : Int32)
higher ">" operator
-
_p_(x : String)
p()=
-
_print_(x : String)
print()=
-
_puts_(x : String)
puts()=
-
_return_(x : String, y : Int32)
return() implement return
from interpreted functions -
_system_(x : String)
system() make system call return result as String
-
_typeof_(x : String, y : Int32)
typeof()=
- add(in1 : Float64, in2 : Float64)
- add(in1 : Int32, in2 : Int32)
-
ceval(line)
eval a line by passing the line to the crystal binary
-
check_args(rol, joinchar = "")
check the rest of line if names can be replaced by values or function results use before printing check_args()=
- check_equal(line : String)
-
check_fun(word, rol)
check_fun()=
-
check_name(arg : String)
check_name()= check if a var with that name exists and return the value, give an error if not found
-
check_two_numbers(in1, in2)
check_two_numbers() for their type and return numbers with the same type
-
clear(x : String)
clear all vars in the hashes
-
dec(x : String, y : Int32)
dec() decrement var value works for int32 gives error for float
-
div(x : String, y : Int32)
div() div value example: counter/= 3 "counter / = 3" # 4 token "a = b / 1" # 5 token
- div(in1 : Float64, in2 : Float64)
- div(in1 : Int32, in2 : Int32)
-
eval(line)
eval()= eval (interactive mode) a line by search for operators and looking up the commands in the keyword hash
-
eval2(ind)
eval2()= (scripting mode) a line by search for operators and looking up the commands in the keyword hash
-
find_args(op : String)
find_args() find 2 args and the operatpr for math operation
-
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"]
- functions_filtered(d)
- help(arg)
-
inc(x : String, y : Int32)
inc() increment var value works for int32 gives error for float
-
inside_quotes?(char, line, pos)
check if a char in a line is quoted argument char defines the quotes used e.g.
-
iterate(res)
iterate() over simple math operators until a single result is returned
-
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
-
lookup_var(x : String)
lookup_var()= check if a var with that name exists and return the value give error when not found
-
ls(x : String, y : Int32)
ls()= list VARS and/or functions
-
method_err(fn, x, y)
method_err() args: (name,input string,number of args)
-
minus(x : String, y : Int32)
minus() sub value example: counter-=3 "counter - = 3" # 4 token "a = b - 1" # 5 token
-
mul(x : String, y : Int32)
mul() mul value example: counter*= 3 "counter * = 3" # 4 token "a = b * 1" # 5 token
- mul(in1 : Float64, in2 : Float64)
- mul(in1 : Int32, in2 : Int32)
-
open_ipc
open_IPC()
- p_time
-
pass
do nothing
-
plus(x : String, y : Int32)
plus() add value to a var example: counter+= 3 "counter + = 3" # 4 token "a = b + 1" # 5 token
- procloop
- prompt
-
quoted_test
test the quoted functions
-
read_command
read line from STDIN
-
readvar(varname, context = Code.cfu)
readvar()
-
receive_ipc
receive_ipc()
-
repl
run interactive if no file given or file not found error handler: print out error message and backtrace
-
replace_var(x : String)
replace_var()= check if a var with that name exists and return the value, give no error
-
replace_vars(rol)
check the rest of line if names can be replaced by values or function results use before printing replace_vars()=
- reset
-
run_cmd(cmd, args)
run cmd as a subprocess and capture the output
-
run_long_cmd(proc_stdin, proc_stdout)
run cmd as a long running sub process in a fiber
- search_help(arg)
-
send_ipc(line)
send_ipc()
- send_receive_ipc(line)
-
show_ipc_results(x)
show_ipc_results() get ipc read result from ipc connection write result to stdout
-
split_operator_from_var(line, operator)
quoted_test() split operator of type String by blank
- sub(in1 : Float64, in2 : Float64)
- sub(in1 : Int32, in2 : Int32)
- unquote(x : String)
-
writevar(varname, value, context = Code.cfu)
writevar()
Method Detail
append() to an array "a << b" of type Int32|String|Float64
construct a new array store the array in function "eval" context Array.new(1,2,3)
return()
implement return
check the rest of line if names can be replaced by values or function results use before printing check_args()=
check_name()= check if a var with that name exists and return the value, give an error if not found
check_two_numbers() for their type and return numbers with the same type
dec()
decrement var value
works for int32
gives error for float
div() div value example: counter/= 3 "counter / = 3" # 4 token "a = b / 1" # 5 token
eval()= eval (interactive mode) a line by search for operators and looking up the commands in the keyword hash
eval2()= (scripting mode) a line by search for operators and looking up the commands in the keyword hash
find_args() find 2 args and the operatpr for math operation
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"]
inc() increment var value works for int32 gives error for float
check if a char in a line is quoted argument char defines the quotes used e.g. " or ' or any other char
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
lookup_var()= check if a var with that name exists and return the value give error when not found
minus() sub value example: counter-=3 "counter - = 3" # 4 token "a = b - 1" # 5 token
mul() mul value example: counter*= 3 "counter * = 3" # 4 token "a = b * 1" # 5 token
plus() add value to a var example: counter+= 3 "counter + = 3" # 4 token "a = b + 1" # 5 token
run interactive if no file given or file not found error handler: print out error message and backtrace
replace_var()= check if a var with that name exists and return the value, give no error
check the rest of line if names can be replaced by values or function results use before printing replace_vars()=
show_ipc_results() get ipc read result from ipc connection write result to stdout