# @donothing/lisp-reader

> read lisp expressions for fun and profit

Latest version **1.3.3** (published 2023-02-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install @donothing/lisp-reader
pnpm add @donothing/lisp-reader
yarn add @donothing/lisp-reader
bun add @donothing/lisp-reader
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.3 |
| Published | 2023-02-17 |
| First published | 2022-08-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 31.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | sharkpal |

## Links

- npm: https://www.npmjs.com/package/@donothing/lisp-reader
- npm.io page: https://npm.io/package/@donothing/lisp-reader

## Recent versions

- 1.3.3 (latest) — 2023-02-17
- 1.3.2 — 2022-09-01
- 1.3.0 — 2022-09-01
- 1.2.0 — 2022-08-28
- 1.1.1 — 2022-08-27

## README

# Lisp Reader

Reads a simple lisp-like syntax.

It is intended for educational use and probably isn't especially fast.

## Simplified AST

```js
import { parse } from '@donothing/lisp-reader';

const ast = parse(`
;;; (fact n) calculate n!
(define (fact n)
  (if (< n 2)
      1
      ;; this isn't stack-safe because I have no morals
      (* (fact (- n 1)) n)))
`)

console.log(ast)
```

Will log something like this (I've formatted it to match the input).

```json
["define", ["fact", "n"] 
  , ["if", ["<", "n", 2]
       , 1
       , ["*", ["fact", ["-", "n", 1]]
             , "n"]]]
```

## Concrete tree

The concrete tree includes location information and attaches comments to the nodes that follow them

```js
import { parseConcrete } from '@donothing/lisp-reader';

const ast = parseConcrete(`
;;; (fact n) calculate n!
(define (fact n)
  (if (< n 2)
      1
      ;; this isn't stack-safe because I have no morals
      (* (fact (- n 1)) n)))
`)

console.log(ast)
```

Will log something like this

```
{
  type: 'List',
  value: [
    { type: 'Symbol', value: 'define', meta: [Object] },
    { type: 'List', value: [Array], meta: [Object] },
    { type: 'List', value: [Array], meta: [Object] }
  ],
  meta: {
    location: { start: 27, end: 150 },
    comments: [ ';;; (fact n) calculate n!' ]
  }
}
```

---
_Source: https://npm.io/package/@donothing/lisp-reader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
