cuyl / simple-pl

Implementing a programming language in 20 minutes, also a tutorial for syntax driven parsing with frontend-for-free.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

easylang

Running the code with no dependency but the Python standard library.

See run.py for more details.

exp = parse("""
print(add(1, 2))
k = fun (x, y, z) =>
    {
        if gt(x,  y)
        then add(z, 1)
        else add(z, -1)
    }

print(k(1, 2, 3))
print(k(2, 1, 3))
""", "<unknown file>")

import operator
ctx = {'add': operator.add, 'print': print, 'gt': operator.gt}
exp(ctx)
# 3
# 2
# 4

About the Parser

If you want to modify the parser and generate it again:

fff --trace easylang.gg

You need frontend-for-free installed.

About

Implementing a programming language in 20 minutes, also a tutorial for syntax driven parsing with frontend-for-free.

License:MIT License


Languages

Language:Python 100.0%