Commit Graph

20 Commits (e49be205f299a2f48db384c44fd0c17784bf1eca)

Author SHA1 Message Date
James T. Martin e49be205f2
Remove `letrec` in favor of allowing any `let` expression to be recursive. 2021-03-29 22:53:01 -07:00
James T. Martin b337ecb094
Add arguments to the Ivo interpreter (and shebang support).
The supported options are `-h`, `-V`, `-t`, `-T`, and `-c`.
Additional arguments are files to be loaded.

In the process, these additional changes have been made:

* `:check` has been replaced with `:printTypes`;
  disabling typechecking is no longer possible.

* Ivo programs no longer allow top-level expressions;
  a `main` definition must be used instead.

* Traces and type information are now printed to `STDERR`.

* The interpreter code underwent /some/ cleanup,
  but more is still needed.
2021-03-26 22:58:45 -07:00
James T. Martin 960297e3b5
Name the language Ivo. 2021-03-26 12:31:55 -07:00
James T. Martin ebf093525e
Replace `fix` builtin with `letrec` syntax. 2021-03-22 17:34:51 -07:00
James T. Martin 036c48a902
Make the REPL awesome with readline, declarations, commands, file loading, etc.
* Added line and block comments to the syntax
* Added `:trace`, `:clear`, `:load`, and `:check` commands to the REPL
* Added persistent declarations and a syntax for multi-expression programs

Future ideas:
* `:type` (print the type of an expression)
* `:dump` (dump all definitions to a file)
* auto-complete for commands and variable-names
* list files to load as arguments
* initial `:trace` and `:check` config as arguments
2021-03-18 14:40:04 -07:00
James T. Martin 9e0754daf6
Added support for Hindley-Milner type inference!
I also generalized substitution to *all* expressions (and types),
which itself involved a rewrite of the substitution function I already had.
(In hindsight, I wish I'd done that in a separate commit.)

The last four days have all been working up to this,
so I'm glad I've finally managed to integrate it into this project!
(I wrote the algorithm 4 days ago, but the infrastructure
just wasn't there to add it here.)
2021-03-18 00:00:43 -07:00
James T. Martin 586be18c80
Add support for many data types, pattern matching, and literals.
* Data types: products, sums, naturals, lists, characters
* Literals: naturals, lists, characters, and strings

I also updated the description with examples of how to use all these new features.

The code's a bit messy and will need cleanup, but for now, it works!
2021-03-17 00:20:17 -07:00
James T. Martin 74d2e26646
Make `callcc` into a proper primitive rather than a hardcoded "variable". 2021-03-16 19:03:02 -07:00
James T. Martin d7ae1f1294
Add support for call/cc (though the implementation's kinda hacky). 2021-03-05 23:38:21 -08:00
James T. Martin 59a55acdc6
Make the parser produce a subtly better AST.
This is done by requiring applications to be at least 2 terms,
and making grouping a syntactic feature instead of a feature of applications.

I also made the code a bit more clear by handling whitespace a bit more cleanly;
now, each parser is responsible for its own trailing whitespace,
and whitespace handling is pushed down to the token level
to avoid cluttering high-level definitions with whitespace stuff.

This all also had the effect of improving error messages,
in part due to me labelling many of the parsers.
2020-11-03 15:52:04 -08:00
James T. Martin 79e054700b
Make the printer smarter, separate intermediate AST data type.
* The expression printer now knows how to use `let`, multi-argument lambdas and applications, and block arguments when appropriate.
* There is a separate type, AbstractSyntax, which separates parsing/printing logic from removing/reintroducing the more advanced syntax described above.
* Expression is now its own module because its 'show' depends on AbstractSyntax,
  and I don't want the ast2expr/expr2ast stuff to be in the same module as the real lambda calculus stuff.
2020-11-03 13:43:43 -08:00
James T. Martin 05d5abec6d
Allow defining multiple variables with one `let`. 2020-11-03 11:33:35 -08:00
James T. Martin 3b2dd67fe7
Make the parser more forgiving, re-add `let`, update README. 2020-11-02 15:59:35 -08:00
James T. Martin 0d821ccce1
Updating the README with my new plans for the project (related to A Walk Through PLT). 2020-04-06 15:02:56 -07:00
James T. Martin b9fc08fd72
Update README.md 2020-02-05 15:28:13 -08:00
James T. Martin 807a0cb1ee Massive refactoring. This project is no longer "just an exercise".
* Allows for multiple representations
  * Evaluation strategies
  * Type systems.
* No longer just the untyped lambda calculus.
* No longer "just an experiment".
2019-08-29 20:46:42 -07:00
James T. Martin ec7ad2236b Added `let`, removed `Nil`, replaced `subst` with `Subst` exprs. 2019-08-21 15:18:25 -07:00
James T. Martin 5f87100363 Added nullary applications and generalized eta reductions. 2019-08-19 15:08:45 -07:00
James T. Martin 70b3b7e051 I fixed it! Also deleted some unused code, and refactored a little. 2019-08-15 13:11:17 -07:00
James T. Martin fd98d499fe Initial commit. Some terms are still not evaluated correctly. 2019-08-15 10:42:24 -07:00