Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Python S-expression Intermediate Language

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 psil
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 TODO
Octocat-spinner-32 hello.psil
Octocat-spinner-32 html.psil
Octocat-spinner-32 integ.test
Octocat-spinner-32 psil-lightning-talk.odp
Octocat-spinner-32 psil.py
Octocat-spinner-32 psil.test
Octocat-spinner-32 test.psil
Octocat-spinner-32 test.py
README.md

Psil - Python S-expression Intermediate Language

Greg Hewgill
http://hewgill.com

Psil is a Lisp family language designed for close integration with Python.

Requirements

Psil requires Python 3.1 or later.

Usage

To run a REPL (interactive read-eval-print-loop):

$ python3.1 psil.py
PSIL interactive mode
Use (quit) to exit
> 

To run a Psil script in a file:

$ python3.1 psil.py hello.psil
hello world

or (on Unix-like systems):

$ ./hello.psil
hello world

To run Psil code from within Python:

#!/usr/bin/env python3.1

from psil.interpreter import psil

square = psil("""
    (lambda (x)
        (* x x))
""")

print(square(5))

A slightly more advanced example where the glob=globals() is needed so that the Psil code can see back into the Python module for the fact function:

#!/usr/bin/env python3.1

from psil.interpreter import psil

fact = psil("""
    (lambda (x)
      (if (== x 0)
          1
          (* x (fact (- x 1)))))
""", glob=globals())

print(fact(5))

The psil.test file is a doctest module with many examples including macros. To run the tests:

$ python3.1 psil.py --test
Something went wrong with that request. Please try again.