diff options
-rw-r--r-- | examples/interpreter.csx | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/examples/interpreter.csx b/examples/interpreter.csx index 7df8ffc..b82caab 100644 --- a/examples/interpreter.csx +++ b/examples/interpreter.csx @@ -138,7 +138,7 @@ ] num] num] ]] -[set readname [fn [] [output [str [head linep]] newline] +[set readname [fn [] [if [head linep] [if [no [same [head [head linep]] [" " 0]]] [if [no [same [head [head linep]] ["[" 0]]] [if [no [same [head [head linep]] ["]" 0]]] [do [if [same [head [head linep]] ["\\" 0]] [sethead linep [tail [head linep]]]] @@ -158,7 +158,7 @@ ] [sethead linep [tail [head linep]]]]] ]] -[set readobj [fn [] [output [str [head linep]] newline] [if +[set readobj [fn [] [if [same [head [head linep]] ["{" 0]] [do [sethead linep [tail [head linep]]] [readcomment] @@ -210,4 +210,39 @@ ]] [output "-= CSX interpreter loaded =-" newline] +[output "========= Base functions: ========================================" newline] +[output "[set name value] | name will have the value value" newline] +[output "[set? name] | check if name is set as some value" newline] +[output "[sethead p v] | head of p will be changed to the v value" newline] +[output "[settail p v] | head of p will be changed to the v value" newline] +[output "[pair head tail] | creates pair of head and value" newline] +[output "[head pair] | returns head of pair" newline] +[output "[tail pair] | returns tail of pair" newline] +[output "[quote x] | returns unevaluated x" newline] +[output "[same a b] | checks if a and b are the same thing" newline] +[output "[type x] | returns type of x" newline] +[output "[do ...] | runs statements returning value of the last one" newline] +[output "[fn args ...] | creates function" newline] +[output " | you can make vararg function with pairs" newline] +[output "[sx args ...] | same as fn but for macro" newline] +[output "[if a b ... c] | executes b if a (for each a), else c" newline] +[output "[+ ...] | sum of the arguments" newline] +[output "[* ...] | product of the arguments" newline] +[output "[neg a] | negate a" newline] +[output "[div a b] | a / b" newline] +[output "[mod a b] | a % b" newline] +[output "[< ...] | checks if arguments are increasing" newline] +[output "[> ...] | checks if arguments are decreasing" newline] +[output "[out ch] | outputs character with ch code" newline] +[output "[in] | null if input ended, else character code" newline] +[output "[name str] | creates name from str string" newline] +[output "[str obj] | creates str from name or list of codes" newline] +[output "[len obj] | length of list or string" newline] +[output "[run x] | runs the x expression" newline] +[output "[run x context] | runs the x expression in given context" newline] +[output " | returns pair of value and new context" newline] +[output "[context] | returns current context" newline] +[output "[newcontext] | returns new base context" newline] +[output "==================================================================" newline] +[output "Have a good time!" newline] [read [newcontext]] |