Skip to content

Latest commit

 

History

History
29 lines (25 loc) · 2.34 KB

README.md

File metadata and controls

29 lines (25 loc) · 2.34 KB

pox

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)
  • fn instead of fun
  • let instead of var
  • pox has support for else-if (see the examples folder)
  • the print statement doesn't exist

built-in classes:

  • list this is a really thin wrapper around python's list type, see the source code for methods it has

built-in functions:

  • print(value) prints the given value to stdout without a trailing new line
  • println(value) prints the given value to stdout with a trailing new line
  • input(prompt) python's input function, returns nil on EOFError
  • chr(int), ord(char) python's chr and ord functions, they both return nil on TypeError
  • str(object), int(string), float(string) python's str, int and float functions. int and float returns nil on ValueError
  • strlen(string) returns the length of a given string, nil if the passed argument is not a string
  • strn(string, n) returns the nth char of a given string, nil if n > len(string) or if string is not a string
  • exit(value) calls sys.exit with the given value
  • time() returns the time in seconds since the epoch as a floating point number
  • sleep(secs) suspend execution of the program for the given number of seconds
  • pow(a, b) returns a**b