GithubHelp home page GithubHelp logo

parable's Introduction

Parable

Build Status Coverage Status

Parable is a Lisp interpreter, at the moment being bootstrapped from Python. You can take a look at the current development roadmap to learn more about Parable.

To get a REPL, just clone the repository and run ./repl.py.

parable's People

Contributors

elektito avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

parable's Issues

Add a `case` macro.

Add case macro like this:

(case (form)
  (case1 value1)
  (case2 value2)
  (case3 value3)
  [default])

Add macro expressions.

Add a macro expression in this form:

(mac (params) expression)

This can be called exactly like a lambda expression; the only difference is that the arguments are passed to the macro unevaluated.

Add some general information to the README.

Update the README to contain the following:

  • General Lisp properties of Parable (Lisp-1, non-hygienic macros, etc.).
  • Similarities to and differences from other Lisps.
  • Current state.
  • Future plans.

Make #t and #f reader literals instead of special symbols.

#t and #f are, at the moment, special symbols that evaluate to true and false. This means if we need a list of booleans we cannot use '(#f #f #t #f); we can only use (list #f #f #t #f) so that all items are actually evaluated.

Making #t and #f reader literals fixes this. We need to define a Boolean class as the reader's equivalent of bool (like we've done so far for list, int and str). The reader then directly reads a True or False.

eq and atom return a string "t" instead of the symbol t.

eq and atom primitives return a string "t" instead of the symbol t. This has gone unnoticed since in the test cases we check for the result not being nil, which is technically correct but not what we intend it. For now, perhaps we'd better update the tests so that they explicitly check for the symbol t and then fix the problem.

Implement a loader.

A loader, reads all the forms in a file, macro-expands them, and if they become define forms adds them to an environment dictionary. The load returns this dictionary.

define forms are similar to those found in Scheme: (define name value). These add values to the compile-time environment.

Add verbosity levels to the test runner.

Make it so we can either quiet the test runner (nothing displayed), have it run in normal verbosity (perhaps like the python unittest runner which shows a single character for each test) or have it run in verbose mode (where it shows us what tests is just running, what finished running, the status, etc.).

Implement nested backquotes.

The current implementation of backquote does not support nested backquotes. Implement this feature. See issue #4 for more information.

typeof primitive instead of atom.

In a purely symbolic Lisp, that is one with only lists and symbols, the atom primitive can be used to detect the type of a given value. This does not work however in a Lisp like Parable that has other data types, too (numbers and strings). We can replace the atom primitive with a typeof primitive which returns the type of a given value as one of the symbols: symbol, list, str and int. With this primitive available, we can add atom (as well as other type predicates) as a function in stdlib.

Add a `+` function.

Add a + function to stdlib that adds any number of integers passed to it.

Add keyword support.

Symbols that begin with a colon (like :foo) are called keywords. Keywords are self-evaluating.

Extend load.py CLI.

Extend load.py CLI to recognize the following arguments:

  • -l or --load loads one or more files.
  • -e or --eval evaluates the given form after loading whatever is specified with -l flag and prints the result.
  • -m or --macro-expand macro-expands the given expression after loading whatever is specified with the -l flag and prints the result.
  • -t or --test runs one or more test files after loading whatever is specified with the -l flag.

Add lexical scope.

Currently the scope of variables dynamic. Make it lexical (static). To do this, we simply need to store the environment of the body of the function inside the Function object itself at the time it is instantiated. Later when we want to call the function, we use the environment stored in the Function object itself, rather than the current environment. The same must be done for macros, too.

Using colons for function composition.

Make it so that foo:bar (in which foo and bar are symbols both evaluating to functions) evaluates to the composition of the two functions. Any number of functions can be composed this way.

Add a backquote macro.

Add a macro called backquote that excepts one argument and returns it unaltered except for any form (unquote form) in it which will be replaced with the result of evaluating form . Also occurrences of (unquote-list form) forms will result in the evaluation of form (which must be a list) expanded in-place. The unquote and unquote-splicing forms must be searched for and replaced in the passed argument recursively.

`append` with multiple arguments.

At the moment, the append function in stdlib accepts exactly two arguments. Make it so that it can accept any number of arguments like in Common Lisp.

Rename car, cdr and cons to first, rest and prep.

As the current roadmap indicates, a side effect having lists as the primary data structure instead of cons is that first, rest and prep are better names than car, cdr and cons (although I really like those!).

Add a test case for invalid argument lists.

Anything except a Symbol in an argument list should not be allowed (destructuring macro argument lists can contain lists, too, but those must recursively contain either lists or symbols). Add a test case for this.

We need to fix #9 before we can add this test case.

Add an apply primitive.

The apply primitive receives a function and a list and calls the function with the values in the given list as arguments.

Add the shorthand quote notation.

Writing (quote form) is tedious and verbose. All Lisp implementations let's one write it as 'form which is both more readable and easier to type. Add this notation.

We probably need a more advanced reader to add this feature.

Add &rest arguments.

If the last argument of a function or a macro is &rest, it should capture any number of arguments from that point on as a list.

Add commenting support.

Extend the reader so that it accepts comments. Single line comments are sufficient at this point. Anything that appears after a semicolon should be considered a comment.

Add a `-` function.

Add a - function that if passed one integer, negates it, otherwise subtracts any number of integers sequentially.

Add function versions of primitives to stdlib.

Currently, you can't pass primitives as functions; for example (mapf car '((1) (2) (3))) won't work since there is no car function. We can add function versions of these to stdlib. For example:

(defun car (lst)
  (car lst))

Add `=` function to stdlib.

After the typeof primitive (see issue #23) is implemented we can add a polymorphic = function. It must:

  • return true for all atoms for which eq returns true.
  • recursively work on lists and return true if = returns true for all elements.

Implement an `assoc` function.

Implement an assoc function that looks up for an item in an association list. An association list is a list of the form (key1 value1 key2 value2 ... keyn valuen). The assoc function receives a key and returns its associated value. If the key does not exist in the list, an error is raised.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.