Skip to content

Commit

Permalink
merge with devel
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jun 4, 2021
2 parents de79d6f + 608866c commit da387ae
Show file tree
Hide file tree
Showing 33 changed files with 5,874 additions and 4,295 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
dist/* binary
package-lock.json binary
assets/classDiagram.svg binary
tests/snapshots/* binary
*.xcm binary
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ tests
assets
examples
scripts
benchmarks
*.md
66 changes: 66 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# LIPS Scheme Architecture

Main interpreter data flow.

[![Scheme interpreter diagram](https://github.com/jcubic/lips/blob/devel/assets/Interpreter.svg?raw=true)](https://github.com/jcubic/lips/blob/devel/assets/Interpreter.svg)

Main public function is `exec` that accept string (code) and Environment instance. If environment is not specified it use main user environment (same as lips.env) which is child of global environment.

`exec` use internal `parse` function that is JavaScript generator that parse single S-Expression and `exec` use `evaluate` to evaluate the expression.
`evaluate` use multiple features like handling of Syntax, Macros and it auto resolve promises. `evaluate` may ot may not return a promise. But `exec` always return a promise, so it's easier to use. You can never know which expression return a promise and which don't. `evaluate` also use `apply` function that was inspired by meta circual evaluator (but it was refactored into this state, it was not like this from beginning).

## UML Diagram of all classes

[![Scheme interpreter UML Diagram](https://github.com/jcubic/lips/blob/devel/assets/classDiagram.svg?raw=true)](https://github.com/jcubic/lips/blob/devel/assets/classDiagram.svgg)

## Lexer

Lexer is created as simple state machine with `Lexer._rules` that specify
all the states. The sate change is simple it can change from null to given
state for a given token (e.g. symbol), remain in same state and move from given state to null. The last change produce new token. Rules are dynamic
the parser can be update by syntax extensions so `Lexer.rules` is a getter
that return proper states with dynamic state rules generate from specials
(syntax extensions).

To speed up generating of rules at parse time, the Lexer use caching, that is invalidated
when specials are modified (new syntax is added or removed).

The most interesting methods of `Lexer` are `peek` and `skip` that
can be used with the parser. It also have methods to be used with
I/O ports that can be used to read string and then continue to parse rest of the content. The reason why Lexer have those methods (like `peek_char`) is
that Lexer is used as the only interface in ports functions:
`peek-char` `read-char` and `read`.


## Parser

## Environment

## Interpreter

## Pair

## Symbols

## Numbers

## Strings

## Characters

## Macros

## Formatter

## InputPort

## OutputPort

## Worker

## Values

## Value

## QuotedPromise

28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## 1.0.0-beta.14
### Breaking
* remove `zip` function that just `(map list l1 l2 ...)`
* `raise` now throws object as is (just like JS `throw` keyword)
* `error` now throws LipsError exception as per R7RS
### Features
* R7RS datum labels
* allow to use `set-repr!` on records (record type name is now a class)
* match function return `#f` instead of `nil` when fail to match (so it work in `cond` or `if`)
* new functions `complement`, `always`, `once`, `flip`, `unfold` (inspired by Ramda)
* add codemirror hits for std lib symbols
* experimental compiler to JSON (not 100% ready)
* add support for `exp` on complex numbers
* add R7RS `error-object?`, `error-object-message` and `error-object-irritants`
* make `NaN`, `null` and `undefined` parser constants
* return proper repr of instances of `define-class`
### Bugfix
* fix `set-repr!` on classes
* fix conflict with jQuery plugns in bookmark
* fix swallowing errors when printing values in Node REPL
* fix mixed quoted and normal promises in let binding [#154](https://github.com/jcubic/lips/issues/154)
* fix problem were await affect quoted promise in macros (e.g. `begin`) [#153](https://github.com/jcubic/lips/issues/153)
* typecheck second argument to `set-obj!`
* fix `case` macro (use implementation from R7RS Errata)
* fix async constructor in `define-class`
* fix methods with improper lists in `define-class`
* fix null inside quasiquote

## 1.0.0-beta.12
### Breaking
* `env` and `dir` now returns symbols instead of strings
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
![LIPS - Scheme Based Powerful Lisp Language](https://github.com/jcubic/lips/blob/master/assets/lips.svg?raw=true)
![LIPS - Scheme Based Powerful Lisp Language](https://github.com/jcubic/lips/blob/devel/assets/lips.svg?raw=true)

[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.12-blue.svg)](https://www.npmjs.com/package/@jcubic/lips)
![1.0.0 Complete](https://img.shields.io/github/milestones/progress-percent/jcubic/lips/1?label=1.0.0%20Complete)
[![travis](https://travis-ci.org/jcubic/lips.svg?branch=master&3d83a5452749e79ba3c2b3ff1a4e074e30b7b3e1)](https://travis-ci.org/jcubic/lips)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=master&64ed443d0b922f100bd1e27a5b7039bd)](https://coveralls.io/github/jcubic/lips?branch=master)
[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&bbce271899464f9cdb10e86cc2435b8fe8e48435)](https://travis-ci.org/jcubic/lips)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&25a417d0b61dd73dde71da232355132a)](https://coveralls.io/github/jcubic/lips?branch=devel)
[![Join Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips)
[![GitHub license](https://img.shields.io/github/license/jcubic/lips.svg)](https://github.com/jcubic/lips/blob/master/LICENSE)
![NPM Download Count](https://img.shields.io/npm/dm/@jcubic/lips)
Expand Down Expand Up @@ -145,7 +145,7 @@ npm install -g @jcubic/lips@beta

you can run the interpreter from the terminal:

![LIPS: Scheme interactive terminal](https://github.com/jcubic/lips/blob/master/assets/screencast.gif?raw=true)
![LIPS: Scheme interactive terminal](https://github.com/jcubic/lips/blob/devel/assets/screencast.gif?raw=true)


You can also run code in a string with:
Expand Down Expand Up @@ -192,17 +192,19 @@ Executables also return a S-Expression according to SRFI-176 use `lips --version
### 1.0
- [x] Full support for R5RS
- [ ] Full support for R7RS
- [ ] R7RS libraries (`import`/`export`/`define-library`).
- [ ] Continuations.
- [ ] Tail Call Optimization (TCO).
- [ ] Fully tested Numerical Tower.
- [ ] R7RS libraries (`import`/`export`/`define-library`).
- [ ] All recursive function in JS don't consume stack.
- [ ] Picture language (possibly inspired by ProcessingJS).
- [ ] Finish `syntax-rules` (ignore limitations of current approach).
- [ ] Objects.
- [ ] Vectors.

### 1.1
- [ ] Fully working JSON Compiler (for faster parsing and loading std lib).
- [ ] Allow to use read/port in syntax extensions (similar to CL reader macros).
- [ ] Proper expansion time for both macro system.
- [ ] Fully working and tested R7RS hygienic Macros (`syntax-rules`).

Expand All @@ -226,6 +228,6 @@ Executables also return a S-Expression according to SRFI-176 use `lips --version
## License

Released under [MIT](http://opensource.org/licenses/MIT) license<br/>
Copyright (c) 2018-2021 [Jakub T. Jankiewicz](https://jcubic.pl/jakub-jankiewicz)
Copyright (c) 2018-2021 [Jakub T. Jankiewicz](https://jcubic.pl/me)

[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjcubic%2Flips.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fjcubic%2Flips?ref=badge_large)
Binary file added assets/Interpreter.dia
Binary file not shown.
144 changes: 144 additions & 0 deletions assets/Interpreter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit da387ae

Please sign in to comment.