Skip to content

R1c4rdCo5t4/Scripting-Language

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Attempt of a custom scripting language using Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages