lox programming language ast-walking interpreter
Note: some differences compared to the original implementation of lox
- strings can be denoted with single quotes
/* multi-line comments (nesting them is not supported) */- escape sequences supported by python are supported on pox as well
- truthiness is implemented with python's bool function (truth testing procedure)
fninstead offunletinstead ofvar- pox has support for else-if (see the examples folder)
- the
printstatement doesn't exist
built-in classes:
listthis is a really thin wrapper around python's list type, see the source code for methods it has
print(value)prints the given value to stdout without a trailing new lineprintln(value)prints the given value to stdout with a trailing new lineinput(prompt)python's input function, returnsnilonEOFErrorchr(int), ord(char)python's chr and ord functions, they both returnnilonTypeErrorstr(object), int(string), float(string)python's str, int and float functions.intandfloatreturnsnilonValueErrorstrlen(string)returns the length of a given string,nilif the passed argument is not a stringstrn(string, n)returns the nth char of a given string,nilif n > len(string) or ifstringis not a stringexit(value)calls sys.exit with the givenvaluetime()returns the time in seconds since the epoch as a floating point numbersleep(secs)suspend execution of the program for the given number of secondspow(a, b)returnsa**b