mirror of
https://github.com/samsonjs/elisp.js.git
synced 2026-04-27 15:07:47 +00:00
Added a longer example
This commit is contained in:
parent
1484ceb268
commit
b2bc59b22a
1 changed files with 27 additions and 3 deletions
30
README
30
README
|
|
@ -46,7 +46,31 @@ el.js.
|
||||||
Running js under rlwrap and then using load('el.js') works just as
|
Running js under rlwrap and then using load('el.js') works just as
|
||||||
well if you don't use Emacs but still want readline. Type EL.repl()
|
well if you don't use Emacs but still want readline. Type EL.repl()
|
||||||
to start the REPL or evaluate one thing with EL.rep,
|
to start the REPL or evaluate one thing with EL.rep,
|
||||||
e.g. El.rep("(* 4 3)")
|
e.g. EL.rep("(* 4 3)")
|
||||||
|
|
||||||
|
or a longer example:
|
||||||
|
|
||||||
|
js> EL.repl()
|
||||||
|
elisp>
|
||||||
|
(defvar *directory* "/Users/sjs" "My home directory")
|
||||||
|
elisp>
|
||||||
|
*directory*
|
||||||
|
["string", "/Users/sjs"]
|
||||||
|
elisp>
|
||||||
|
(setq foo 1 bar 2 baz 3)
|
||||||
|
["number", 3]
|
||||||
|
elisp>
|
||||||
|
(/ (+ foo bar baz) 3)
|
||||||
|
["number", 2]
|
||||||
|
elisp>
|
||||||
|
(string-match "[a-z]lurgh" (symbol-name 'foo-blurgh))
|
||||||
|
["number", 4]
|
||||||
|
elisp>
|
||||||
|
q
|
||||||
|
js>
|
||||||
|
|
||||||
|
(If you know how to print without a trailing newline in SpiderMonkey
|
||||||
|
please let me know.)
|
||||||
|
|
||||||
There are other interfaces into the parser and evaluator besides the
|
There are other interfaces into the parser and evaluator besides the
|
||||||
shortcuts. new EL.Parser([input]) returns a parser object and likewise
|
shortcuts. new EL.Parser([input]) returns a parser object and likewise
|
||||||
|
|
@ -76,9 +100,9 @@ lines.
|
||||||
* expression evaluator
|
* expression evaluator
|
||||||
|
|
||||||
* simple tagged primitive types
|
* simple tagged primitive types
|
||||||
(string, symbol, primitive, function, number)
|
(string, symbol, lambda, number, cons)
|
||||||
|
|
||||||
* special forms for defvar, defun, set, setq, and quote
|
* special forms for defvar, defun, set, setq, if, and quote
|
||||||
|
|
||||||
* eval/apply for atoms, function calls, and a few special forms
|
* eval/apply for atoms, function calls, and a few special forms
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue