Skip to content

Latest commit

 

History

History
69 lines (59 loc) · 1.12 KB

README.md

File metadata and controls

69 lines (59 loc) · 1.12 KB

Scripting Language Python

Custom scripting language using Python (in development)

How to run the interpreter

cd src && python main.py <file>

Features

  • set x = 1
  • let y
  • const z = 1
  • x = 1
  • print
  • math operations and str concatenation
  • for loop
  • comments (# single-line and ### multi-line)
  • functions
  • ternary operator
  • str, int, bool and none types
  • log function for debugging
  • shell mode
  • string formatting
  • while
  • loop 10
  • if-else
  • lists
  • list and str slicing
  • built-in functions (len, sum, enum, max, ...)
  • maps
  • lambda functions
  • list comprehensions
  • classes
  • ...

Example Code

fn my_function[str, n]
    print str, n

const start = 0
const end = start + 10
let x

set step_str = 'two'
x = step_str == 'one' ? 1 : 2

log x

for i from start to end step x
    my_function 'number:', i

Output

x = 2 (int)
number: 0
number: 2
number: 4
number: 6
number: 8
number: 10

Run Tests

cd tests && python -m unittest discover