Skip to content

Commit

Permalink
Update readme & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Nov 13, 2023
1 parent 098f480 commit cdc6ba0
Show file tree
Hide file tree
Showing 3 changed files with 351 additions and 342 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ import script, { operator, unary, binary, token } from './subscript.js'

// add ~ unary operator with precedence 15
unary('~', 15)
operator('~', a => ~a)
operator('~', a => ctx => ~a)

// add === binary operator with precedence 9
binary('===', 9)
operator('===', (a, b) => a===b)
operator('===', (a, b) => ctx => ctx[a]===ctx[b])

// add boolean literals
token('true', 20, prev => ['',true])
token('false', 20, prev => ['',false])
operator('', boolNode => ctx => boolNode[1]])
operator('', boolNode => ctx => boolNode[1])
```

See [subscript.js](subscript.js) or [justin.js](./justin.js) for examples.
Expand Down
2 changes: 1 addition & 1 deletion test/subscript.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"tst": "../node_modules/tst/tst.js"
}
}</script>
<script type="module" src="./index.js"></script>
<script type="module" src="./subscript.js"></script>
Loading

0 comments on commit cdc6ba0

Please sign in to comment.