Crafting Interpreters
A simple interpreter that runs in your browser. Powered by RustReference
Builtin Types
- Number - 64 bit float
- Str
- Bool
- Array
- Function
- Nil
Native Functions
In case of errors or invalid arguments, a global error variable named "errString" is set with the error message and the function returns nil. Otherwise, the global error variable is set to nil.-
Clock() -> Number
Returns the current epoch in milliseconds. -
Print(Str)
Prints the given string to the output. -
ReadNumber(String) -> Number
Reads a number from the input, displaying the given string as a prompt. -
ReadString(String) -> Str
Reads a string from the input, displaying the given string as a prompt. -
ReadBool() -> Bool
Reads a boolean from the input. -
TypeOf(Any) -> String
Returns the type of the given value. -
ToString(Any) -> String
Converts the given value to a string. -
ToNumber(String) -> Number
Converts the given string to a number. -
StringAt(String, Number) -> String
Returns the character at the given index in the string. -
StrLen(String) -> Number
Returns the length of the given string. -
ArrLen(String) -> Number
Returns the length of the given array. -
Ceil(Number) -> Number
Returns the smallest integer greater than or equal to the given number. -
Floor(Number) -> Number
Returns the largest integer less than or equal to the given number. -
Abs(Number) -> Number
Returns the absolute value of the given number. -
Rand() -> Number
Returns a 32-bit unsigned integer ( as Number ) -
Sort(Array)
Sorts an arrray of numbers in ascending order. If the array has non-numbers, it's an error. -
IndexOf(Array, Any) -> Number
Returns the index of the given value in the array. If the value is not found, returns the length of the array.
Try a sample:
Output
Ready
Inspired by The Crafting Interpreters Book | Terraria icon by Icons8