├── scratch ├── labels │ ├── labels.lisp │ ├── main.js │ └── main.lisp ├── generators │ ├── generators.js │ ├── index.html │ ├── main.lisp │ ├── main.js │ └── generators.lisp └── do │ ├── main.js │ └── main.lisp ├── .gitignore ├── examples ├── noderepl │ ├── noderepl │ ├── utils.lisp │ ├── run.js │ └── repl.lisp ├── scripts │ ├── example1.lisp │ ├── example2.lisp │ ├── example2.html │ └── example1.html ├── jquery │ ├── ui-lightness │ │ └── images │ │ │ ├── ui-icons_222222_256x240.png │ │ │ ├── ui-icons_228ef1_256x240.png │ │ │ ├── ui-icons_ef8c08_256x240.png │ │ │ ├── ui-icons_ffd27a_256x240.png │ │ │ ├── ui-icons_ffffff_256x240.png │ │ │ ├── ui-bg_flat_10_000000_40x100.png │ │ │ ├── ui-bg_glass_100_f6f6f6_1x400.png │ │ │ ├── ui-bg_glass_100_fdf5ce_1x400.png │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ ├── ui-bg_gloss-wave_35_f6a828_500x100.png │ │ │ ├── ui-bg_highlight-soft_75_ffe45c_1x100.png │ │ │ ├── ui-bg_diagonals-thick_18_b81900_40x40.png │ │ │ ├── ui-bg_diagonals-thick_20_666666_40x40.png │ │ │ └── ui-bg_highlight-soft_100_eeeeee_1x100.png │ └── ui.lisp ├── defaults │ ├── example1.lisp │ └── example1.html ├── lambdas │ ├── example1.lisp │ └── example1.html ├── paip │ ├── README.md │ ├── utils.lisp │ └── new-account │ │ └── index.html ├── dom │ ├── example1.lisp │ └── example1.html ├── pcl │ └── ch3 │ │ ├── cds.db │ │ └── main.lisp ├── math │ ├── example1.lisp │ └── example1.html └── repl │ ├── index.html │ ├── style.css │ └── script.lisp ├── support ├── bin │ ├── jsdoc-toolkit │ │ ├── app │ │ │ ├── test │ │ │ │ ├── shared2.js │ │ │ │ ├── scripts │ │ │ │ │ ├── code.js │ │ │ │ │ └── notcode.txt │ │ │ │ ├── encoding_other.js │ │ │ │ ├── public.js │ │ │ │ ├── encoding.js │ │ │ │ ├── prototype_nested.js │ │ │ │ ├── global.js │ │ │ │ ├── ignore.js │ │ │ │ ├── nocode.js │ │ │ │ ├── anon_inner.js │ │ │ │ ├── params_optional.js │ │ │ │ ├── prototype_oblit.js │ │ │ │ ├── static_this.js │ │ │ │ ├── variable_redefine.js │ │ │ │ ├── inner.js │ │ │ │ ├── exports.js │ │ │ │ ├── oblit_anon.js │ │ │ │ ├── prototype.js │ │ │ │ ├── name.js │ │ │ │ ├── module.js │ │ │ │ ├── memberof_constructor.js │ │ │ │ ├── shortcuts.js │ │ │ │ ├── namespace_nested.js │ │ │ │ ├── borrows2.js │ │ │ │ ├── memberof.js │ │ │ │ ├── tosource.js │ │ │ │ ├── augments2.js │ │ │ │ ├── constructs.js │ │ │ │ ├── addon.js │ │ │ │ ├── augments.js │ │ │ │ ├── overview.js │ │ │ │ ├── prototype_oblit_constructor.js │ │ │ │ ├── synonyms.js │ │ │ │ ├── config.js │ │ │ │ ├── globals.js │ │ │ │ ├── lend.js │ │ │ │ ├── shared.js │ │ │ │ ├── functions_anon.js │ │ │ │ ├── param_inline.js │ │ │ │ ├── functions_nested.js │ │ │ │ ├── borrows.js │ │ │ │ └── event.js │ │ │ ├── frame │ │ │ │ ├── Namespace.js │ │ │ │ ├── Reflection.js │ │ │ │ ├── Hash.js │ │ │ │ ├── String.js │ │ │ │ ├── Chain.js │ │ │ │ ├── Opt.js │ │ │ │ ├── Testrun.js │ │ │ │ ├── Dumper.js │ │ │ │ └── Link.js │ │ │ ├── plugins │ │ │ │ ├── symbolLink.js │ │ │ │ ├── functionCall.js │ │ │ │ ├── commentSrcJson.js │ │ │ │ ├── frameworkPrototype.js │ │ │ │ ├── tagParamConfig.js │ │ │ │ ├── tagSynonyms.js │ │ │ │ └── publishSrcHilite.js │ │ │ ├── t │ │ │ │ ├── runner.js │ │ │ │ └── TestDoc.js │ │ │ ├── lib │ │ │ │ ├── JSDOC │ │ │ │ │ ├── Token.js │ │ │ │ │ ├── TextStream.js │ │ │ │ │ ├── Util.js │ │ │ │ │ ├── PluginManager.js │ │ │ │ │ ├── TokenStream.js │ │ │ │ │ ├── Lang.js │ │ │ │ │ ├── JsDoc.js │ │ │ │ │ └── JsPlate.js │ │ │ │ └── JSDOC.js │ │ │ ├── handlers │ │ │ │ ├── XMLDOC │ │ │ │ │ ├── XMLDoc.js │ │ │ │ │ └── DomReader.js │ │ │ │ ├── XMLDOC.js │ │ │ │ └── FOODOC.js │ │ │ ├── frame.js │ │ │ └── main.js │ │ ├── templates │ │ │ ├── jsdoc │ │ │ │ ├── static │ │ │ │ │ ├── header.html │ │ │ │ │ ├── index.html │ │ │ │ │ └── default.css │ │ │ │ ├── allclasses.tmpl │ │ │ │ ├── symbol.tmpl │ │ │ │ ├── index.tmpl │ │ │ │ └── allfiles.tmpl │ │ │ └── codeview │ │ │ │ ├── static │ │ │ │ ├── header.html │ │ │ │ └── index.html │ │ │ │ ├── allclasses.tmpl │ │ │ │ ├── symbol.tmpl │ │ │ │ ├── index.tmpl │ │ │ │ └── allfiles.tmpl │ │ ├── jsrun.jar │ │ ├── jsdebug.jar │ │ ├── java │ │ │ ├── classes │ │ │ │ └── js.jar │ │ │ ├── src │ │ │ │ ├── JsRun.java │ │ │ │ └── JsDebugRun.java │ │ │ ├── build.xml │ │ │ └── build_1.4.xml │ │ ├── conf │ │ │ └── sample.conf │ │ └── jsrun.sh │ ├── jsl │ └── watch.py ├── assets │ └── chrome-extension │ │ └── manifest.json └── vendor │ └── Class.js ├── docs ├── readme │ ├── repl1.png │ ├── repl2.png │ ├── repl3.png │ └── repl4.png ├── port │ ├── run.lisp │ ├── template.js │ ├── utils.lisp │ ├── style.css │ └── index.html ├── ideas │ └── typed-arguments.md ├── files.html └── index.html ├── .gitmodules ├── src ├── javascript │ ├── lisp │ │ ├── Keyword.js │ │ ├── Symbol.js │ │ ├── Macro.js │ │ ├── Env.js │ │ └── utils.js │ ├── parse │ │ └── utils.js │ ├── utils │ │ ├── tolisp.js │ │ ├── stream.js │ │ ├── json.js │ │ └── utils.js │ ├── config.js │ ├── wrapper │ │ ├── _footer.js │ │ └── _header.js │ └── lisp.js └── lisp │ ├── lib │ └── path.lisp │ └── core │ ├── macros.lisp │ └── functions.lisp ├── tests ├── node-tests.js ├── index.html └── tests.js ├── noderun.js ├── index.html └── Rakefile /scratch/labels/labels.lisp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scratch/generators/generators.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scratch/generators/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | \#*# 3 | .#* 4 | build/lisp.min.js 5 | -------------------------------------------------------------------------------- /examples/noderepl/noderepl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rlwrap node run.js $@ 3 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/shared2.js: -------------------------------------------------------------------------------- 1 | startOver = function(){ 2 | } -------------------------------------------------------------------------------- /support/bin/jsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/support/bin/jsl -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/jsdoc/static/header.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/readme/repl1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/docs/readme/repl1.png -------------------------------------------------------------------------------- /docs/readme/repl2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/docs/readme/repl2.png -------------------------------------------------------------------------------- /docs/readme/repl3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/docs/readme/repl3.png -------------------------------------------------------------------------------- /docs/readme/repl4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/docs/readme/repl4.png -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/codeview/static/header.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scratch/generators/main.lisp: -------------------------------------------------------------------------------- 1 | (for (i (xrange 10)) 2 | (format t "%s bottles of beer on the wall" i)) 3 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/scripts/code.js: -------------------------------------------------------------------------------- 1 | /** 2 | @class 3 | */ 4 | function thisiscode() { 5 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/scripts/notcode.txt: -------------------------------------------------------------------------------- 1 | (This is not code) 2 | function foo(){{{{ 3 | ( 4 | ! 5 | @ -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/jsrun.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/support/bin/jsdoc-toolkit/jsrun.jar -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/jsdebug.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/support/bin/jsdoc-toolkit/jsdebug.jar -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "support/vendor/JSTest"] 2 | path = support/vendor/JSTest 3 | url = git@ssh.github.com:willurd/JSTest.git 4 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/java/classes/js.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/support/bin/jsdoc-toolkit/java/classes/js.jar -------------------------------------------------------------------------------- /examples/scripts/example1.lisp: -------------------------------------------------------------------------------- 1 | (defun window.onload (e) 2 | (print "hello") 3 | (print (document.getElementsByTagName "h1")) 4 | (print "success")) 5 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/encoding_other.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/support/bin/jsdoc-toolkit/app/test/encoding_other.js -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-icons_228ef1_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-icons_228ef1_256x240.png -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-icons_ef8c08_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-icons_ef8c08_256x240.png -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-icons_ffd27a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-icons_ffd27a_256x240.png -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-bg_flat_10_000000_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-bg_flat_10_000000_40x100.png -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/public.js: -------------------------------------------------------------------------------- 1 | /**@constructor*/ 2 | function Foo() { 3 | /** 4 | @public 5 | @static 6 | @field 7 | */ 8 | var bar = function(x) { 9 | } 10 | } -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/encoding.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @Constructor 4 | * @desc 配置文件 5 | * @class 什么也不返回 6 | */ 7 | function Test(conf) { 8 | // do something; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png -------------------------------------------------------------------------------- /examples/jquery/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/willurd/js-lisp/HEAD/examples/jquery/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png -------------------------------------------------------------------------------- /src/javascript/lisp/Keyword.js: -------------------------------------------------------------------------------- 1 | var Keyword = Class.extend({ 2 | init: function (value) { 3 | this.value = value; 4 | }, 5 | 6 | toString: function () { 7 | return this.value; 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /src/javascript/lisp/Symbol.js: -------------------------------------------------------------------------------- 1 | var Symbol = Class.extend({ 2 | init: function (value) { 3 | this.value = value; 4 | }, 5 | 6 | toString: function () { 7 | return this.value; 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/prototype_nested.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Word() { 3 | } 4 | 5 | Word.prototype.reverse = function() { 6 | } 7 | 8 | Word.prototype.reverse.utf8 = function() { 9 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/global.js: -------------------------------------------------------------------------------- 1 | /** ecks */ 2 | var x = [1, 2, 4]; 3 | 4 | var y = { 5 | foo: function(){ 6 | } 7 | } 8 | 9 | bar = function() { 10 | } 11 | 12 | function zop() { 13 | } 14 | -------------------------------------------------------------------------------- /examples/defaults/example1.lisp: -------------------------------------------------------------------------------- 1 | (defun window.onload (e) 2 | (print "t:" t) 3 | (print "true:" true) 4 | (print "false:" false) 5 | (print "nil:" nil) 6 | (print "null:" null) 7 | (print "undefined:" undefined)) 8 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/ignore.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A test constructor. 3 | * @constructor 4 | * @ignore 5 | */ 6 | function Ignored() { 7 | /** a method */ 8 | this.bar = function() { 9 | } 10 | } -------------------------------------------------------------------------------- /examples/scripts/example2.lisp: -------------------------------------------------------------------------------- 1 | (defun say-hi (id) 2 | (let ((element (document.getElementById id))) 3 | (element.appendChild (document.createTextNode "hi!")))) 4 | 5 | (defun window.onload () 6 | (say-hi "test-results")) 7 | -------------------------------------------------------------------------------- /examples/lambdas/example1.lisp: -------------------------------------------------------------------------------- 1 | (print "js-lisp Lambdas - Example 1") 2 | 3 | (setq window.onload 4 | (lambda (e g) 5 | (print "Inside a lambda") 6 | (print "Printing an arg: " e) 7 | (print "And printing an undefined arg: " g))) 8 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/nocode.js: -------------------------------------------------------------------------------- 1 | /**#nocode+*/ 2 | /** 3 | @name star 4 | @function 5 | */ 6 | function blahblah() { 7 | 8 | } 9 | /**#nocode-*/ 10 | 11 | function yaddayadda() { 12 | 13 | } -------------------------------------------------------------------------------- /examples/paip/README.md: -------------------------------------------------------------------------------- 1 | # Examples from *Paradigms of Artificial Intelligence Programming* 2 | 3 | This folder contains examples from the book *Paradigms of Artificial Intelligence Programming* that are running in js-lisp (with little-to-no modifications). 4 | -------------------------------------------------------------------------------- /examples/dom/example1.lisp: -------------------------------------------------------------------------------- 1 | (defun window.onload (e) 2 | "Updates an HTML element using the DOM" 3 | (let ((div (document.getElementById "thediv"))) 4 | (print "before:" div.textContent) 5 | (setq div.textContent "it works!") 6 | (print "after:" div.textContent))) 7 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/frame/Namespace.js: -------------------------------------------------------------------------------- 1 | _global_ = this; 2 | 3 | function Namespace(name, f) { 4 | var n = name.split("."); 5 | for (var o = _global_, i = 0, l = n.length; i < l; i++) { 6 | o = o[n[i]] = o[n[i]] || {}; 7 | } 8 | 9 | if (f) f(); 10 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/anon_inner.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @name bar 3 | * @namespace 4 | */ 5 | 6 | new function() { 7 | /** 8 | * @name bar-foo 9 | * @function 10 | * @param {number} x 11 | */ 12 | function foo(x) { 13 | } 14 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/params_optional.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @param {Page[]} pages 4 | * @param {number} [id] Specifies the id, if applicable. 5 | * @param {String} [title = This is untitled.] Specifies the title. 6 | */ 7 | function Document(pages, id, title){ 8 | } -------------------------------------------------------------------------------- /examples/noderepl/utils.lisp: -------------------------------------------------------------------------------- 1 | (defun clear () 2 | "Clears the screen and returns the cursor to the home position." 3 | ;; Clear the entire screen 4 | (process.stdout.write "\x1b[2J") 5 | ;; Move the cursor the the top-left of the screen 6 | (process.stdout.write "\x1b[H")) 7 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/prototype_oblit.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Article() { 3 | } 4 | 5 | Article.prototype = { 6 | /** instance get title */ 7 | getTitle: function(){ 8 | } 9 | } 10 | 11 | /** static get title */ 12 | Article.getTitle = function(){ 13 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/static_this.js: -------------------------------------------------------------------------------- 1 | /** the parent */ 2 | var box = {}; 3 | 4 | /** @namespace */ 5 | box.holder = {} 6 | 7 | box.holder.foo = function() { 8 | /** the counter */ 9 | this.counter = 1; 10 | } 11 | 12 | box.holder.foo(); 13 | print(box.holder.counter); 14 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/variable_redefine.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Foo() { 3 | var bar = 1; 4 | bar = 2; // redefining a private 5 | 6 | this.baz = 1; 7 | baz = 2; // global 8 | 9 | /** a private */ 10 | var blap = { 11 | /** in here */ 12 | tada: 1 13 | } 14 | } -------------------------------------------------------------------------------- /scratch/do/main.js: -------------------------------------------------------------------------------- 1 | require.paths.unshift(__dirname); 2 | 3 | var sys = require("sys"), 4 | path = require("path"), 5 | lisp = require("../../build/lisp"), 6 | Script = process.binding('evals').Script; 7 | 8 | lisp.env.set("lisp", lisp); 9 | 10 | lisp.load("../../build/core.lisp"); 11 | lisp.load("main.lisp"); 12 | -------------------------------------------------------------------------------- /scratch/do/main.lisp: -------------------------------------------------------------------------------- 1 | (print "------- 1 -------") 2 | 3 | (do ((i 0 (1+ i))) 4 | ((>= i 4)) 5 | (print i)) 6 | 7 | (print "------- 2 -------") 8 | 9 | (dotimes (i 4) 10 | (print i) 11 | (inc i)) 12 | 13 | (print "------- 3 -------") 14 | 15 | (dolist (item '(:one :two :three)) 16 | (format t "%l" item)) 17 | -------------------------------------------------------------------------------- /support/assets/chrome-extension/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Lisp Scripting", 3 | "version": "0.0.1", 4 | "description": "A Lisp interpreter for the browser.", 5 | "content_scripts": [ 6 | { 7 | "matches": ["http://*/*", "https://*/*", "file:///*"], 8 | "js": ["lisp.js"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/javascript/parse/utils.js: -------------------------------------------------------------------------------- 1 | function validateInput (input) { 2 | if (typeof(input) != "string" && 3 | !(input instanceof StringStream)) { 4 | throw new parse.ParserException("Invalid input: " + input); 5 | } 6 | if (input instanceof StringStream) { 7 | return input; 8 | } 9 | return new StringStream(input); 10 | } 11 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/inner.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @constructor 3 | */ 4 | function Outer() { 5 | /** 6 | * @constructor 7 | */ 8 | function Inner(name) { 9 | /** The name of this. */ 10 | this.name = name; 11 | } 12 | 13 | this.open = function(name) { 14 | return (new Inner(name)); 15 | } 16 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/plugins/symbolLink.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.symbolLink", 3 | { 4 | onSymbolLink: function(link) { 5 | // modify link.linkPath (the href part of the link) 6 | // or link.linkText (the text displayed) 7 | // or link.linkInner (the #name part of the link) 8 | } 9 | } 10 | ); -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/exports.js: -------------------------------------------------------------------------------- 1 | /** @namespace */ 2 | var mxn = {}; 3 | 4 | (function(){ 5 | /** @exports Map as mxn.Map */ 6 | var Map = 7 | /** @constructor */ 8 | mxn.Map = function() { 9 | }; 10 | 11 | /** A method. */ 12 | Map.prototype.doThings = function() { 13 | }; 14 | })(); -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/plugins/functionCall.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.functionCall", 3 | { 4 | onFunctionCall: function(functionCall) { 5 | if (functionCall.name == "dojo.define" && functionCall.arg1) { 6 | functionCall.doc = "/** @lends "+eval(functionCall.arg1)+".prototype */"; 7 | } 8 | } 9 | } 10 | ); -------------------------------------------------------------------------------- /scratch/labels/main.js: -------------------------------------------------------------------------------- 1 | require.paths.unshift(__dirname); 2 | 3 | var sys = require("sys"), 4 | path = require("path"), 5 | lisp = require("../../build/lisp"), 6 | Script = process.binding('evals').Script; 7 | 8 | lisp.env.set("lisp", lisp); 9 | 10 | lisp.load("../../build/core.lisp"); 11 | lisp.load("labels.lisp"); 12 | lisp.load("main.lisp"); 13 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/oblit_anon.js: -------------------------------------------------------------------------------- 1 | /** the options */ 2 | opt = Opt.get( 3 | arguments, 4 | { 5 | d: "directory", 6 | c: "conf", 7 | "D[]": "define" 8 | } 9 | ); 10 | 11 | /** configuration */ 12 | opt.conf = { 13 | /** keep */ 14 | keep: true, 15 | /** base */ 16 | base: getBase(this, {p: properties}) 17 | } 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /scratch/generators/main.js: -------------------------------------------------------------------------------- 1 | require.paths.unshift(__dirname); 2 | 3 | var sys = require("sys"), 4 | path = require("path"), 5 | lisp = require("../../build/lisp"), 6 | Script = process.binding('evals').Script; 7 | 8 | lisp.env.set("lisp", lisp); 9 | 10 | lisp.load("../../build/core.lisp"); 11 | lisp.load("generators.lisp"); 12 | lisp.load("main.lisp"); 13 | -------------------------------------------------------------------------------- /src/javascript/lisp/Macro.js: -------------------------------------------------------------------------------- 1 | var _inMacro = false; // So we can have expressions that only work inside macros 2 | var Macro = Class.extend({ 3 | init: function (callable) { 4 | /** @ignore */ 5 | this.callable = function () { 6 | _inMacro = true; 7 | var ret = callable.apply(null, arguments); 8 | _inMacro = false; 9 | return ret; 10 | }; 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/prototype.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Article() { 3 | } 4 | 5 | Article.prototype.init = function(title) { 6 | /** the instance title */ 7 | this.title = title; 8 | 9 | /** the static counter */ 10 | Article.counter = 1; 11 | } 12 | 13 | a = new Article(); 14 | a.Init("my title"); 15 | 16 | print(a.title); 17 | print(Article.counter); -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/name.js: -------------------------------------------------------------------------------- 1 | /** 2 | @name Response 3 | @class 4 | */ 5 | 6 | Response.prototype = { 7 | /** 8 | @name Response#text 9 | @function 10 | @description 11 | Gets the body of the response as plain text 12 | @returns {String} 13 | Response as text 14 | */ 15 | 16 | text: function() { 17 | return this.nativeResponse.responseText; 18 | } 19 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/module.js: -------------------------------------------------------------------------------- 1 | /** @namespace */ 2 | myProject = myProject || {}; 3 | 4 | /** @namespace */ 5 | myProject.myModule = (function () { 6 | /** describe myPrivateVar here */ 7 | var myPrivateVar = ""; 8 | 9 | var myPrivateMethod = function () { 10 | } 11 | 12 | /** @scope myProject.myModule */ 13 | return { 14 | myPublicMethod: function () { 15 | } 16 | }; 17 | })(); -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/memberof_constructor.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Circle(){} 3 | 4 | /** 5 | @constructor 6 | @memberOf Circle# 7 | */ 8 | Circle.prototype.Tangent = function(){}; 9 | 10 | // renaming Circle#Tangent to Circle#Circle#Tangent 11 | 12 | /** 13 | @memberOf Circle#Tangent# 14 | */ 15 | Circle.prototype.Tangent.prototype.getDiameter = function(){}; 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/pcl/ch3/cds.db: -------------------------------------------------------------------------------- 1 | ((:title "Lyle Lovett" :artist "Lyle Lovett" :rating 9 :ripped t) 2 | (:title "Give Us a Break" :artist "Limpopo" :rating 10 :ripped t) 3 | (:title "Rockin' the Suburbs" :artist "Ben Folds" :rating 6 :ripped f) 4 | (:title "Home" :artist "Dixie Chicks" :rating 9 :ripped t) 5 | (:title "Fly" :artist "Dixie Chicks" :rating 8 :ripped t) 6 | (:title "Roses" :artist "Kathy Mattea" :rating 9 :ripped f)) 7 | -------------------------------------------------------------------------------- /src/lisp/lib/path.lisp: -------------------------------------------------------------------------------- 1 | (defobject path 2 | :sep "/" 3 | 4 | :remove-sep (lambda (p) 5 | "Removes path.sep from the end of the given path if 6 | it is there." 7 | (if (ends-with p utils.path.sep) 8 | (p.slice 0 (1- p.length)) 9 | p)) 10 | 11 | :join (lambda (& paths) 12 | "Joins the given paths together with path.sep." 13 | (join utils.path.sep (map utils.path.remove-sep paths)))) 14 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/codeview/allclasses.tmpl: -------------------------------------------------------------------------------- 1 |
{+new Link().toFile("index.html").withText("Class Index")+} | {+new Link().toFile("files.html").withText("File Index")+}
2 | 3 |

Classes

4 | 5 | 12 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/shortcuts.js: -------------------------------------------------------------------------------- 1 | // /**#=+ 2 | // * { 3 | // * 'D': 'Date.prototype', 4 | // * '$N': 'Number' 5 | // * } 6 | // */ 7 | // var D = Date.prototype, 8 | // $N = Number; 9 | // 10 | // D.locale = function(){ 11 | // }; 12 | // 13 | // /** 14 | // @return {string} The cardinal number string. 15 | // */ 16 | // $N.nth = function(n){ 17 | // }; 18 | // 19 | // LOAD.file = function(){ 20 | // } 21 | // 22 | // /**#=-*/ -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/t/runner.js: -------------------------------------------------------------------------------- 1 | // try: java -jar ../../jsrun.jar runner.js 2 | 3 | load("TestDoc.js"); 4 | 5 | TestDoc.prove("../frame/Opt.js"); 6 | TestDoc.prove("../lib/JSDOC.js"); 7 | TestDoc.prove("../frame/String.js"); 8 | TestDoc.prove("../lib/JSDOC/DocTag.js"); 9 | TestDoc.prove("../lib/JSDOC/DocComment.js"); 10 | TestDoc.prove("../lib/JSDOC/TokenReader.js"); 11 | TestDoc.prove("../lib/JSDOC/Symbol.js"); 12 | 13 | TestDoc.report(); 14 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/namespace_nested.js: -------------------------------------------------------------------------------- 1 | /** 2 | @namespace This is the first namespace. 3 | */ 4 | ns1 = {}; 5 | 6 | /** 7 | This is the second namespace. 8 | @namespace 9 | */ 10 | ns1.ns2 = {}; 11 | 12 | /** 13 | This part of ns1.ns2 14 | @constructor 15 | */ 16 | ns1.ns2.Function1 = function() { 17 | }; 18 | 19 | ns1.staticFunction = function() { 20 | }; 21 | 22 | /** A static field in a namespace. */ 23 | ns1.ns2.staticField = 1; 24 | -------------------------------------------------------------------------------- /examples/paip/utils.lisp: -------------------------------------------------------------------------------- 1 | (setq ArgumentError lisp.exception.ArgumentError) 2 | 3 | (defmacro test (name & plist) 4 | "This is just a nicer syntax for defining a JSTest test case." 5 | `(JSTest.TestCase (object 6 | :name ,name 7 | ,@plist))) 8 | 9 | (defmacro divider (name) 10 | `(JSTest.Divider ,name)) 11 | 12 | (defun arg-name-part (argname:lisp.Symbol) 13 | (let ((argname (to-string argname))) 14 | (to-symbol (first (argname.split ":"))))) 15 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/borrows2.js: -------------------------------------------------------------------------------- 1 | // testing circular borrows 2 | 3 | /** 4 | @class 5 | @borrows Bar#zop as this.my_zop 6 | */ 7 | function Foo() { 8 | /** this is a zip. */ 9 | this.zip = function() {} 10 | 11 | this.my_zop = new Bar().zop; 12 | } 13 | 14 | /** 15 | @class 16 | @borrows Foo#zip as this.my_zip 17 | */ 18 | function Bar() { 19 | /** this is a zop. */ 20 | this.zop = function() {} 21 | 22 | this.my_zip = new Foo().zip; 23 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/memberof.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | pack = function() { 3 | this.init = function(){} 4 | function config(){} 5 | } 6 | 7 | pack.build = function(task) {}; 8 | 9 | /** @memberOf pack */ 10 | pack.install = function() {} 11 | 12 | /** @memberOf pack */ 13 | pack.install.overwrite = function() {} 14 | 15 | /** @memberOf pack */ 16 | clean = function() {} 17 | 18 | /** @memberOf pack-config */ 19 | install = function() {}; 20 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/tosource.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {Object} object 3 | * @return {string} 4 | */ 5 | function valueOf(object) {} 6 | 7 | /** 8 | * @param {Object} object 9 | * @return {string} 10 | */ 11 | function toString(object) {} 12 | 13 | /** 14 | * @param {Object} object 15 | * @return {string} 16 | */ 17 | function toSource(object) {} 18 | 19 | /** 20 | * @param {Object} object 21 | * @return {string} 22 | */ 23 | function constructor(object) {} -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/augments2.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | */ 4 | function LibraryItem() { 5 | this.reserve = function() { 6 | } 7 | } 8 | 9 | /** 10 | @constructor 11 | */ 12 | function Junkmail() { 13 | this.annoy = function() { 14 | } 15 | } 16 | 17 | /** 18 | @inherits Junkmail.prototype.annoy as pester 19 | @augments ThreeColumnPage 20 | @augments LibraryItem 21 | @constructor 22 | */ 23 | function NewsletterPage() { 24 | this.getHeadline = function() { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/math/example1.lisp: -------------------------------------------------------------------------------- 1 | (defun window.onload (e) 2 | (let ((lst (document.getElementById "list")) 3 | (add-li (lambda (text) 4 | (let ((li (document.createElement "li"))) 5 | (li.appendChild (document.createTextNode text)) 6 | (lst.appendChild li))))) 7 | (add-li (join " " (list "(/ 10 2)" "=" (/ 10 2)))) 8 | (add-li (join " " (list "(/ 20 2 3)" "=" (/ 20 (to-number "2") (to-string 3))))) 9 | (add-li (join " " (list "(+ (* 2 3) (* 4 5))" "=" (+ (* 2 3) (* 4 (1+ 4)))))))) 10 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/lib/JSDOC/Token.js: -------------------------------------------------------------------------------- 1 | if (typeof JSDOC == "undefined") JSDOC = {}; 2 | 3 | /** 4 | @constructor 5 | */ 6 | JSDOC.Token = function(data, type, name) { 7 | this.data = data; 8 | this.type = type; 9 | this.name = name; 10 | } 11 | 12 | JSDOC.Token.prototype.toString = function() { 13 | return "<"+this.type+" name=\""+this.name+"\">"+this.data+""; 14 | } 15 | 16 | JSDOC.Token.prototype.is = function(what) { 17 | return this.name === what || this.type === what; 18 | } -------------------------------------------------------------------------------- /tests/node-tests.js: -------------------------------------------------------------------------------- 1 | var sys = require("sys"), 2 | fs = require("fs"), 3 | JSTest = require("../support/vendor/JSTest/src/jstest"), 4 | lisp = require("../build/lisp"); 5 | 6 | const JS_TESTS = "./tests"; 7 | const LISP_TESTS = "tests.lisp"; 8 | 9 | // Include our javascript tests 10 | require(JS_TESTS); 11 | 12 | // Eval our lisp tests 13 | lisp.env.set("JSTest", JSTest); 14 | lisp.eval(fs.readFileSync(LISP_TESTS)); 15 | 16 | with (JSTest) { 17 | run(false, handlers.NodeJSHandler); 18 | } 19 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/constructs.js: -------------------------------------------------------------------------------- 1 | var Person = makeClass( 2 | /** 3 | @scope Person 4 | */ 5 | { 6 | /** 7 | This is just another way to define a constructor. 8 | @constructs 9 | @param {string} name The name of the person. 10 | */ 11 | initialize: function(name) { 12 | this.name = name; 13 | }, 14 | say: function(message) { 15 | return this.name + " says: " + message; 16 | } 17 | } 18 | ); -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/addon.js: -------------------------------------------------------------------------------- 1 | String.prototype.reverse = function() { 2 | } 3 | 4 | String.prototype.reverse.utf8 = function() { 5 | } 6 | 7 | Function.count = function() { 8 | } 9 | 10 | /** @memberOf Function */ 11 | Function.count.reset = function() { 12 | } 13 | 14 | /** @memberOf Function */ 15 | count.getValue = function() { 16 | } 17 | 18 | /** @memberOf Function.prototype */ 19 | getSig = function() { 20 | } 21 | 22 | /** @memberOf Function.prototype */ 23 | Function.prototype.getProps = function() { 24 | } 25 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/augments.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | */ 4 | function Layout(p) { 5 | this.init = function(p) { 6 | } 7 | 8 | this.getId = function() { 9 | } 10 | 11 | /** @type Page */ 12 | this.orientation = "landscape"; 13 | } 14 | 15 | /** 16 | @constructor 17 | @augments Layout 18 | */ 19 | function Page() { 20 | this.reset = function(b) { 21 | } 22 | } 23 | 24 | /** 25 | @extends Page 26 | @constructor 27 | */ 28 | function ThreeColumnPage() { 29 | this.init = function(resetCode) { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/overview.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @overview This "library" contains a 3 | * lot of classes and functions. 4 | * @example 5 |
 6 | 	var x (x < 1);
 7 | 	alert("This 'is' \"code\"");
 8 |  
9 | * @name My Cool Library 10 | * @author Joe Smith jsmith@company.com 11 | * @version 0.1 12 | */ 13 | 14 | /** 15 | * Gets the current foo 16 | * @param {String} fooId The unique identifier for the foo. 17 | * @return {Object} Returns the current foo. 18 | */ 19 | function getFoo(fooID){ 20 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl: -------------------------------------------------------------------------------- 1 |
{+new Link().toFile("index.html").withText("Class Index")+} 2 | | {+new Link().toFile("files.html").withText("File Index")+}
3 |
4 |

Classes

5 | 17 |
-------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/prototype_oblit_constructor.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Article() { 3 | } 4 | 5 | Article.prototype = { 6 | /** @constructor */ 7 | Title: function(title) { 8 | /** the value of the Title instance */ 9 | this.title = title; 10 | }, 11 | 12 | init: function(pages) { 13 | /** the value of the pages of the Article instance */ 14 | this.pages = pages; 15 | } 16 | } 17 | 18 | f = new Article(); 19 | f.init("one two three"); 20 | 21 | t = new f.Title("my title"); 22 | 23 | print(f.pages); 24 | print(t.title); -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js: -------------------------------------------------------------------------------- 1 | LOG.inform("XMLDOC.symbolize loaded"); 2 | 3 | /** 4 | * Convert the source file to a set of symbols 5 | */ 6 | XMLDOC.symbolize = function(srcFile, src) { 7 | 8 | LOG.inform("Symbolizing file '" + srcFile + "'"); 9 | 10 | // XML files already have a defined structure, so we don't need to 11 | // do anything but parse them. The DOM reader can create a symbol 12 | // table from the parsed XML. 13 | var dr = new XMLDOC.DomReader(XMLDOC.Parser.parse(src)); 14 | return dr.getSymbols(srcFile); 15 | 16 | }; 17 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/plugins/commentSrcJson.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.commentSrcJson", 3 | { 4 | onDocCommentSrc: function(comment) { 5 | var json; 6 | if (/^\s*@json\b/.test(comment)) { 7 | comment.src = new String(comment.src).replace("@json", ""); 8 | 9 | eval("json = "+comment.src); 10 | var tagged = ""; 11 | for (var i in json) { 12 | var tag = json[i]; 13 | // todo handle cases where tag is an object 14 | tagged += "@"+i+" "+tag+"\n"; 15 | } 16 | comment.src = tagged; 17 | } 18 | } 19 | } 20 | ); -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/plugins/frameworkPrototype.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.frameworkPrototype", 3 | { 4 | onPrototypeClassCreate: function(classCreator) { 5 | var desc = ""; 6 | if (classCreator.comment) { 7 | desc = classCreator.comment; 8 | } 9 | var insert = desc+"/** @name "+classCreator.name+"\n@constructor\n@scope "+classCreator.name+".prototype */" 10 | 11 | insert = insert.replace(/\*\/\/\*\*/g, "\n"); 12 | /*DEBUG*///print("insert is "+insert); 13 | classCreator.addComment.data = insert; 14 | } 15 | } 16 | ); 17 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/synonyms.js: -------------------------------------------------------------------------------- 1 | /** 2 | @class 3 | @inherits Bar#zop as #my_zop 4 | */ 5 | function Foo() { 6 | /** this is a zip. */ 7 | this.zip = function() {} 8 | 9 | /** from Bar */ 10 | this.my_zop = new Bar().zop; 11 | } 12 | 13 | /** 14 | @class 15 | @borrows Foo#zip as this.my_zip 16 | */ 17 | function Bar() { 18 | /** this is a zop. */ 19 | this.zop = function() {} 20 | 21 | /** from Foo */ 22 | this.my_zip = new Foo().zip; 23 | } 24 | 25 | /** @namespace */ 26 | var myObject = { 27 | /** 28 | @type function 29 | */ 30 | myFunc: getFunction() 31 | } -------------------------------------------------------------------------------- /src/javascript/utils/tolisp.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns a lispy string representation of the given value. 3 | */ 4 | function toLisp (object) { 5 | if (object === null) { 6 | return "nil"; 7 | } 8 | if (object === true) { 9 | return "t"; 10 | } 11 | if (object === false) { 12 | return "f"; 13 | } 14 | if (object instanceof Symbol) { 15 | return String(object); 16 | } 17 | if (object instanceof Keyword) { 18 | return ":" + String(object); 19 | } 20 | if (object instanceof Array) { 21 | return "(" + object.map(toLisp).join(" ") + ")"; 22 | } 23 | return toJSON(object, true); 24 | } 25 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/handlers/XMLDOC.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This is the main container for the XMLDOC handler. 3 | * @namespace 4 | * @author Brett Fattori (bfattori@fry.com) 5 | * @version $Revision: 498 $ 6 | */ 7 | XMLDOC = { 8 | 9 | }; 10 | 11 | /** The current version string of this application. */ 12 | XMLDOC.VERSION = "1.0"; 13 | 14 | /** Include the library necessary to handle XML files */ 15 | IO.includeDir("handlers/XMLDOC/"); 16 | 17 | /** 18 | * @type Symbol[] 19 | */ 20 | XMLDOC.handle = function(srcFile, src) { 21 | 22 | }; 23 | 24 | XMLDOC.publish = function(symbolgroup) { 25 | 26 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @constructor 3 | * @param person The person. 4 | * @param {string} person.name The person's name. 5 | * @config {integer} age The person's age. 6 | * @config [id=1] Optional id number to use. 7 | * @param connection 8 | */ 9 | function Contact(person, connection) { 10 | 11 | } 12 | 13 | /** 14 | * @constructor 15 | * @param persons 16 | * @config {string} Father The paternal person. 17 | * @config {string} Mother The maternal person. 18 | * @config {string[]} Children And the rest. 19 | */ 20 | function Family(/**Object*/persons) { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /examples/scripts/example2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | js-lisp Scripts - Example 2 5 | 7 | 8 | 11 | 12 | 13 | 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/handlers/FOODOC.js: -------------------------------------------------------------------------------- 1 | /** 2 | This is the main container for the FOODOC handler. 3 | @namespace 4 | */ 5 | FOODOC = { 6 | }; 7 | 8 | /** The current version string of this application. */ 9 | FOODOC.VERSION = "1.0"; 10 | 11 | FOODOC.handle = function(srcFile, src) { 12 | LOG.inform("Handling file '" + srcFile + "'"); 13 | 14 | return [ 15 | new JSDOC.Symbol( 16 | "foo", 17 | [], 18 | "VIRTUAL", 19 | new JSDOC.DocComment("/** This is a foo. */") 20 | ) 21 | ]; 22 | }; 23 | 24 | FOODOC.publish = function(symbolgroup) { 25 | LOG.inform("Publishing symbolgroup."); 26 | }; 27 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/globals.js: -------------------------------------------------------------------------------- 1 | function example(/**Circle*/a, b) { 2 | /** a global defined in function */ 3 | var number = a; 4 | 5 | var hideNumber = function(){ 6 | } 7 | 8 | setNumber = function(){ 9 | } 10 | alert('You have chosen: ' + b); 11 | } 12 | 13 | function initPage() { 14 | var supported = document.createElement && document.getElementsByTagName; 15 | if (!supported) return; 16 | // start of DOM script 17 | var x = document.getElementById('writeroot'); 18 | // etc. 19 | } 20 | 21 | /** an example var */ 22 | var document = new Document(x, y); 23 | 24 | var getNumber = function(){ 25 | } -------------------------------------------------------------------------------- /examples/lambdas/example1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | js-lisp Lambdas - Example 1 5 | 7 | 8 | 11 | 12 | 13 | 17 |
(output in console)
18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/scripts/example1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | js-lisp Scripts - Example 1 5 | 7 | 8 | 11 | 12 | 13 | 17 |
(output in console)
18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/defaults/example1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | js-lisp Defaults - Example 1 5 | 7 | 8 | 11 | 12 | 13 | 17 |
(output in console)
18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/math/example1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | js-lisp Math - Example 1 5 | 7 | 8 | 11 | 12 | 13 | 17 |
18 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/lend.js: -------------------------------------------------------------------------------- 1 | /** @class */ 2 | var Person = Class.create( 3 | /** 4 | @lends Person.prototype 5 | */ 6 | { 7 | initialize: function(name) { 8 | this.name = name; 9 | }, 10 | say: function(message) { 11 | return this.name + ': ' + message; 12 | } 13 | } 14 | ); 15 | 16 | /** @lends Person.prototype */ 17 | { 18 | /** like say but more musical */ 19 | sing: function(song) { 20 | } 21 | } 22 | 23 | /** @lends Person */ 24 | { 25 | getCount: function() { 26 | } 27 | } 28 | 29 | /** @lends Unknown.prototype */ 30 | { 31 | notok: function() { 32 | } 33 | } -------------------------------------------------------------------------------- /scratch/generators/generators.lisp: -------------------------------------------------------------------------------- 1 | (defmacro generator (arglist & body) 2 | `(new lisp.Generator (lambda ,arglist 3 | (let ((stop-iteration (lambda () 4 | (throw (new lisp.exception.StopIteration))))) 5 | ,@body)))) 6 | 7 | (defun xrange (a::number &opt b::number step::number) 8 | ;; Sanatize the input 9 | (when (is-undefined b) 10 | (setq b a) 11 | (setq a 0)) 12 | (when (is-undefined step) 13 | (setq step 1)) 14 | ;; Return the generator 15 | (let ((last a)) 16 | (generator () 17 | (let ((ret last)) 18 | (setq last (+ last step)) 19 | (if (> ret b) 20 | (stop-iteration) 21 | ret))))) 22 | -------------------------------------------------------------------------------- /examples/dom/example1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | js-lisp DOM Scripting - Example 1 5 | 7 | 8 | 11 | 12 | 13 | 17 |
18 |
it didn't work :(
19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /support/bin/watch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Note: this script totally sucks, but it works (for the most part) 4 | 5 | def main (): 6 | import subprocess 7 | import time 8 | try: 9 | last = None 10 | while True: 11 | output = subprocess.Popen('ls -lctTR src/'.split(), 12 | stdout=subprocess.PIPE).stdout.read() 13 | if last is None: 14 | last = output 15 | if output != last: 16 | print 'Files under src/ have changed, reloading...' 17 | print subprocess.Popen('rake build'.split(), 18 | stdout=subprocess.PIPE).stdout.read() 19 | last = output 20 | time.sleep(0.1) 21 | except KeyboardInterrupt: 22 | pass 23 | 24 | if __name__ == '__main__': 25 | main() 26 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/shared.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Builtin object. 4 | * @class 5 | * @name Array 6 | */ 7 | 8 | /**#@+ 9 | * Extension to builtin array. 10 | * @memberOf Array 11 | * @method 12 | */ 13 | 14 | /** 15 | * @returns Boolen if some array members... 16 | */ 17 | Array.prototype.some = function(){}; 18 | 19 | /** 20 | * Change every element of an array. 21 | * @returns Filtered array copy. 22 | */ 23 | Array.prototype.filter = function(){}; 24 | 25 | /**#@-*/ 26 | 27 | 28 | /** 29 | * A first in, first out data structure. 30 | * @constructor 31 | */ 32 | Queue = function(){}; 33 | 34 | /**#@+ 35 | * Extension to Queue. 36 | * @memberOf Queue 37 | */ 38 | 39 | rewind = function(){ 40 | } 41 | 42 | // should close automatically here. -------------------------------------------------------------------------------- /docs/port/run.lisp: -------------------------------------------------------------------------------- 1 | ;; This will run when the page finishes loading. 2 | ($ (lambda () 3 | ;; Add all the symbols to the page 4 | (setup-symbols) 5 | 6 | ;; Count all of the finished and unfinished symbols and place 7 | ;; their counts in the page header. 8 | (let ((done ($ ".done")) 9 | (not-done ($ ".notDone")) 10 | (done-label ($ "#done-count")) 11 | (not-done-label ($ "#not-done-count")) 12 | (tool-non-planned ($ "#tool-non-planned"))) 13 | ;; Set the labels for the done/not done counts 14 | (done-label.html done.length) 15 | (not-done-label.html not-done.length) 16 | 17 | ;; Initialize the "non-planned" toggler and do the initial toggle 18 | (tool-non-planned.click toggle-non-planned-items) 19 | (toggle-non-planned-items)))) 20 | -------------------------------------------------------------------------------- /examples/repl/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | js-lisp REPL 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/jsdoc/static/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Generated Javascript Documentation 7 | 8 | 9 | 10 | 11 | 12 | <body> 13 | <p> 14 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 15 | </p> 16 | </body> 17 | 18 | 19 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/codeview/static/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Generated Javascript Documentation 7 | 8 | 9 | 10 | 11 | 12 | <body> 13 | <p> 14 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 15 | </p> 16 | </body> 17 | 18 | 19 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/functions_anon.js: -------------------------------------------------------------------------------- 1 | /** an anonymous constructor executed inline */ 2 | a = new function() { 3 | /** a.b*/ 4 | this.b = 1; 5 | /** a.f */ 6 | this.f = function() { 7 | /** a.c */ 8 | this.c = 2; 9 | } 10 | } 11 | 12 | 13 | /** 14 | named function executed inline 15 | */ 16 | bar1 = function Zoola1() { 17 | /** property of global */ 18 | this.g = 1; 19 | }(); 20 | 21 | /** 22 | named constructor executed inline 23 | */ 24 | bar2 = new function Zoola2() { 25 | /** property of bar */ 26 | this.p = 1; 27 | }; 28 | 29 | /** module pattern */ 30 | module = (function () { 31 | /** won't appear in documentation */ 32 | var priv = 1; 33 | 34 | /** @scope module */ 35 | return { 36 | /** will appear as a property of module */ 37 | pub: 1 38 | } 39 | })(); 40 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/param_inline.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | @param columns The number of columns. 4 | */ 5 | function Layout(/**int*/columns){ 6 | /** 7 | @param [id] The id of the element. 8 | @param elName The name of the element. 9 | */ 10 | this.getElement = function( 11 | /** string */ elName, 12 | /** number|string */ id 13 | ) { 14 | }; 15 | 16 | /** 17 | @constructor 18 | */ 19 | this.Canvas = function(top, left, /**int*/width, height) { 20 | /** Is it initiated yet? */ 21 | this.initiated = true; 22 | } 23 | 24 | this.rotate = function(/**nothing*/) { 25 | } 26 | 27 | /** 28 | @param x 29 | @param y 30 | @param {zoppler} z*/ 31 | this.init = function(x, y, /**abbler*/z) { 32 | /** The xyz. */ 33 | this.xyz = x+y+z; 34 | this.getXyz = function() { 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/frame/Reflection.js: -------------------------------------------------------------------------------- 1 | /**@constructor*/ 2 | function Reflection(obj) { 3 | this.obj = obj; 4 | } 5 | 6 | Reflection.prototype.getConstructorName = function() { 7 | if (this.obj.constructor.name) return this.obj.constructor.name; 8 | var src = this.obj.constructor.toSource(); 9 | var name = src.substring(name.indexOf("function")+8, src.indexOf('(')).replace(/ /g,''); 10 | return name; 11 | } 12 | 13 | Reflection.prototype.getMethod = function(name) { 14 | for (var p in this.obj) { 15 | if (p == name && typeof(this.obj[p]) == "function") return this.obj[p]; 16 | } 17 | return null; 18 | } 19 | 20 | Reflection.prototype.getParameterNames = function() { 21 | var src = this.obj.toSource(); 22 | src = src.substring( 23 | src.indexOf("(", 8)+1, src.indexOf(")") 24 | ); 25 | return src.split(/, ?/); 26 | } 27 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/java/src/JsRun.java: -------------------------------------------------------------------------------- 1 | /** 2 | * A trivial bootstrap class that simply adds the path to the 3 | * .js file as an argument to the Rhino call. This little hack 4 | * allows the code in the .js file to have access to it's own 5 | * path via the Rhino arguments object. This is necessary to 6 | * allow the .js code to find resource files in a location 7 | * relative to itself. 8 | * 9 | * USAGE: java -jar jsrun.jar path/to/file.js 10 | */ 11 | public class JsRun { 12 | public static void main(String[] args) { 13 | String[] jsargs = {"-j="+args[0]}; 14 | 15 | String[] allArgs = new String[jsargs.length + args.length]; 16 | System.arraycopy(args, 0, allArgs, 0, args.length); 17 | System.arraycopy(jsargs, 0, allArgs, args.length ,jsargs.length); 18 | 19 | org.mozilla.javascript.tools.shell.Main.main(allArgs); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/javascript/config.js: -------------------------------------------------------------------------------- 1 | var WHITESPACE = " \t\n\r"; 2 | 3 | var ROOT_ENV = new Env(new Env(null, global), { 4 | "t": true, 5 | "true": true, 6 | "f": false, 7 | "false": false, 8 | "nil": null, 9 | "null": null, 10 | "undefined": undefined, 11 | "NaN": NaN, 12 | 13 | /** 14 | * This is here because values defined in the lisp env clobber the 15 | * global namespace (this is on purpose, so those values can be used 16 | * by other JavaScript code). Howver, one thing we definitely don't 17 | * want to do is clobber standard JavaScript functions, like eval. 18 | * 19 | * TODO: Test me 20 | */ 21 | "eval": function (expression) { 22 | // Input validation 23 | assert(arguments.length === 1, "(eval) requires 1 argument (got " + 24 | arguments.length + ")"); 25 | 26 | return resolve(expression); 27 | }, 28 | 29 | "*features*": [_K("notmuch")] 30 | }); 31 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/java/src/JsDebugRun.java: -------------------------------------------------------------------------------- 1 | /** 2 | * A trivial bootstrap class that simply adds the path to the 3 | * .js file as an argument to the Rhino call. This little hack 4 | * allows the code in the .js file to have access to it's own 5 | * path via the Rhino arguments object. This is necessary to 6 | * allow the .js code to find resource files in a location 7 | * relative to itself. 8 | * 9 | * USAGE: java -jar jsdebug.jar path/to/file.js 10 | */ 11 | public class JsDebugRun { 12 | public static void main(String[] args) { 13 | String[] jsargs = {"-j="+args[0]}; 14 | 15 | String[] allArgs = new String[jsargs.length + args.length]; 16 | System.arraycopy(args, 0, allArgs, 0, args.length); 17 | System.arraycopy(jsargs, 0, allArgs, args.length ,jsargs.length); 18 | 19 | org.mozilla.javascript.tools.debugger.Main.main(allArgs); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/functions_nested.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Zop() { 3 | } 4 | 5 | /** 6 | @class 7 | */ 8 | Foo = function(id) { 9 | // this is a bit twisted, but if you call Foo() you will then 10 | // modify Foo(). This is kinda, sorta non-insane, because you 11 | // would have to call Foo() 100% of the time to use Foo's methods 12 | Foo.prototype.methodOne = function(bar) { 13 | alert(bar); 14 | }; 15 | 16 | // same again 17 | Foo.prototype.methodTwo = function(bar2) { 18 | alert(bar2); 19 | }; 20 | 21 | // and these are only executed if the enclosing function is actually called 22 | // and who knows if that will ever happen? 23 | Bar = function(pez) { 24 | alert(pez); 25 | }; 26 | Zop.prototype.zap = function(p){ 27 | alert(p); 28 | }; 29 | 30 | // but this is only visible inside Foo 31 | function inner() { 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/plugins/tagParamConfig.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.tagParamConfig", 3 | { 4 | onDocCommentTags: function(comment) { 5 | var currentParam = null; 6 | var tags = comment.tags; 7 | for (var i = 0, l = tags.length; i < l; i++) { 8 | 9 | if (tags[i].title == "param") { 10 | if (tags[i].name.indexOf(".") == -1) { 11 | currentParam = i; 12 | } 13 | } 14 | else if (tags[i].title == "config") { 15 | tags[i].title = "param"; 16 | if (currentParam == null) { 17 | tags[i].name = "arguments"+"."+tags[i].name; 18 | } 19 | else if (tags[i].name.indexOf(tags[currentParam].name+".") != 0) { 20 | tags[i].name = tags[currentParam].name+"."+tags[i].name; 21 | } 22 | currentParam != null 23 | //tags[currentParam].properties.push(tags[i]); 24 | } 25 | else { 26 | currentParam = null; 27 | } 28 | } 29 | } 30 | } 31 | ); 32 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/borrows.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | */ 4 | function Layout(p) { 5 | /** initilize 1 */ 6 | this.init = function(p) { 7 | } 8 | 9 | /** get the id */ 10 | this.getId = function() { 11 | } 12 | 13 | /** @type string */ 14 | this.orientation = "landscape"; 15 | 16 | function getInnerElements(elementSecretId){ 17 | } 18 | } 19 | 20 | /** A static method. */ 21 | Layout.units = function() { 22 | } 23 | 24 | /** 25 | @constructor 26 | @borrows Layout#orientation 27 | @borrows Layout-getInnerElements 28 | @borrows Layout.units 29 | */ 30 | function Page() { 31 | /** reset the page */ 32 | this.reset = function(b) { 33 | } 34 | } 35 | 36 | /** 37 | @constructor 38 | @borrows Layout.prototype.orientation as this.orientation 39 | @borrows Layout.prototype.init as #init 40 | @inherits Page.prototype.reset as #reset 41 | */ 42 | function ThreeColumnPage() { 43 | /** initilize 2 */ 44 | this.init = function(p) { 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/frame.js: -------------------------------------------------------------------------------- 1 | IO.include("frame/Opt.js"); 2 | IO.include("frame/Chain.js"); 3 | IO.include("frame/Link.js"); 4 | IO.include("frame/String.js"); 5 | IO.include("frame/Hash.js"); 6 | IO.include("frame/Namespace.js"); 7 | //IO.include("frame/Reflection.js"); 8 | 9 | /** A few helper functions to make life a little easier. */ 10 | 11 | function defined(o) { 12 | return (o !== undefined); 13 | } 14 | 15 | function copy(o) { // todo check for circular refs 16 | if (o == null || typeof(o) != 'object') return o; 17 | var c = new o.constructor(); 18 | for(var p in o) c[p] = copy(o[p]); 19 | return c; 20 | } 21 | 22 | function isUnique(arr) { 23 | var l = arr.length; 24 | for(var i = 0; i < l; i++ ) { 25 | if (arr.lastIndexOf(arr[i]) > i) return false; 26 | } 27 | return true; 28 | } 29 | 30 | /** Returns the given string with all regex meta characters backslashed. */ 31 | RegExp.escapeMeta = function(str) { 32 | return str.replace(/([$^\\\/()|?+*\[\]{}.-])/g, "\\$1"); 33 | } 34 | -------------------------------------------------------------------------------- /noderun.js: -------------------------------------------------------------------------------- 1 | require.paths.unshift(__dirname); 2 | 3 | var sys = require("sys"), 4 | path = require("path"), 5 | lisp = require("build/lisp"), 6 | exec = require("child_process").exec; 7 | 8 | function usage () { 9 | command = process.argv.slice(0, 2).join(" "); 10 | sys.puts("Usage: " + command + " script.lisp"); 11 | process.exit(1); 12 | } 13 | 14 | function strip (string) { 15 | return string.replace(/(^\s+|\s+$)/ig, ""); 16 | } 17 | 18 | exec("pwd", function (error, stdout, stderr) { 19 | require.paths.unshift(strip(stdout)); 20 | 21 | if (process.argv.length > 3) { 22 | sys.puts("Too many arguments"); 23 | usage(); 24 | } else if (process.argv.length === 3) { 25 | lisp.env.set("lisp", lisp); 26 | lisp.env.set("require", require); 27 | lisp.load("build/core.lisp"); 28 | lisp.load("build/lib/path.lisp"); 29 | // Load the given script. 30 | var filename = process.argv[2]; 31 | lisp.load(filename); 32 | } else { 33 | sys.puts("Too few arguments"); 34 | usage(); 35 | } 36 | }); 37 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/lib/JSDOC/TextStream.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | @constructor 4 | */ 5 | JSDOC.TextStream = function(text) { 6 | if (typeof(text) == "undefined") text = ""; 7 | text = ""+text; 8 | this.text = text; 9 | this.cursor = 0; 10 | } 11 | 12 | JSDOC.TextStream.prototype.look = function(n) { 13 | if (typeof n == "undefined") n = 0; 14 | 15 | if (this.cursor+n < 0 || this.cursor+n >= this.text.length) { 16 | var result = new String(""); 17 | result.eof = true; 18 | return result; 19 | } 20 | return this.text.charAt(this.cursor+n); 21 | } 22 | 23 | JSDOC.TextStream.prototype.next = function(n) { 24 | if (typeof n == "undefined") n = 1; 25 | if (n < 1) return null; 26 | 27 | var pulled = ""; 28 | for (var i = 0; i < n; i++) { 29 | if (this.cursor+i < this.text.length) { 30 | pulled += this.text.charAt(this.cursor+i); 31 | } 32 | else { 33 | var result = new String(""); 34 | result.eof = true; 35 | return result; 36 | } 37 | } 38 | 39 | this.cursor += n; 40 | return pulled; 41 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/conf/sample.conf: -------------------------------------------------------------------------------- 1 | /* 2 | This is an example of one way you could set up a configuration file to more 3 | conveniently define some commandline options. You might like to do this if 4 | you frequently reuse the same options. Note that you don't need to define 5 | every option in this file, you can combine a configuration file with 6 | additional options on the commandline if your wish. 7 | 8 | You would include this configuration file by running JsDoc Toolkit like so: 9 | java -jar jsrun.jar app/run.js -c=conf/sample.conf 10 | 11 | */ 12 | 13 | { 14 | // source files to use 15 | _: ['app/test/jsdoc_test.js'], 16 | 17 | // document all functions, even uncommented ones 18 | a: true, 19 | 20 | // including those marked @private 21 | p: true, 22 | 23 | // some extra variables I want to include 24 | D: {generatedBy: "Michael Mathews", copyright: "2008"}, 25 | 26 | // use this directory as the output directory 27 | d: "docs", 28 | 29 | // use this template 30 | t: "templates/jsdoc" 31 | } -------------------------------------------------------------------------------- /scratch/labels/main.lisp: -------------------------------------------------------------------------------- 1 | (let ((i 0)) 2 | (labels 3 | (:one 4 | (print i) 5 | (when (> i 2) 6 | (goto :three))) 7 | (:two 8 | (setq i (1+ i)) 9 | (goto :one)) 10 | (:three 11 | (print "Done!"))) 12 | (assert (== i 3) (concat "i is not three, it's " i))) 13 | 14 | ;; The Art of Computer Programming Volume 2, Page 145 15 | (defun shuffle! (lst) 16 | (let ((j) 17 | (u) ;; Random number between 0 and 1 18 | (k)) ;; Random number between 1 and j 19 | (labels 20 | (:p1 ;; Initialize 21 | (setq j (1- (length lst)))) 22 | (:p2 ;; Generate 23 | (setq u (Math.random))) 24 | (:p3 ;; Exchange 25 | (setq k (Math.round (* u j))) 26 | (let ((temp (nth lst k))) 27 | (setkey lst k (nth lst j)) 28 | (setkey lst j temp))) 29 | (:p4 ;; Decrease 30 | (setq j (1- j)) 31 | (when (> j 1) 32 | (goto :p2))))) 33 | lst) 34 | 35 | (let ((lst '(1 2 3 4 5 6 7 8 9))) 36 | (format t "%l" lst) 37 | (format t "%l" (shuffle! lst))) 38 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/lib/JSDOC/Util.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @namespace 3 | * @deprecated Use {@link FilePath} instead. 4 | */ 5 | JSDOC.Util = { 6 | } 7 | 8 | /** 9 | * @deprecated Use {@link FilePath.fileName} instead. 10 | */ 11 | JSDOC.Util.fileName = function(path) { 12 | LOG.warn("JSDOC.Util.fileName is deprecated. Use FilePath.fileName instead."); 13 | var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0); 14 | return path.substring(nameStart); 15 | } 16 | 17 | /** 18 | * @deprecated Use {@link FilePath.fileExtension} instead. 19 | */ 20 | JSDOC.Util.fileExtension = function(filename) { 21 | LOG.warn("JSDOC.Util.fileExtension is deprecated. Use FilePath.fileExtension instead."); 22 | return filename.split(".").pop().toLowerCase(); 23 | }; 24 | 25 | /** 26 | * @deprecated Use {@link FilePath.dir} instead. 27 | */ 28 | JSDOC.Util.dir = function(path) { 29 | LOG.warn("JSDOC.Util.dir is deprecated. Use FilePath.dir instead."); 30 | var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0); 31 | return path.substring(0, nameStart-1); 32 | } 33 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/test/event.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @name Kitchen 3 | * @constructor 4 | * @fires Bakery#event:donutOrdered 5 | */ 6 | 7 | /** 8 | * Fired when some cake is eaten. 9 | * @name Kitchen#event:cakeEaten 10 | * @function 11 | * @param {Number} pieces The number of pieces eaten. 12 | */ 13 | 14 | /** 15 | * Find out if cake was eaten. 16 | * @name Kitchen#cakeEaten 17 | * @function 18 | * @param {Boolean} wasEaten 19 | */ 20 | 21 | /** 22 | * @name getDesert 23 | * @function 24 | * @fires Kitchen#event:cakeEaten 25 | */ 26 | 27 | /** 28 | * @name Bakery 29 | * @constructor 30 | * @extends Kitchen 31 | */ 32 | 33 | /** 34 | * Fired when a donut order is made. 35 | * @name Bakery#event:donutOrdered 36 | * @event 37 | * @param {Event} e The event object. 38 | * @param {String} [e.topping] Optional sprinkles. 39 | */ 40 | 41 | /** 42 | * @constructor 43 | * @borrows Bakery#event:donutOrdered as this.event:cakeOrdered 44 | */ 45 | function CakeShop() { 46 | } 47 | 48 | /** @event */ 49 | CakeShop.prototype.icingReady = function(isPink) { 50 | } 51 | 52 | /** @event */ 53 | function amHungry(/**Boolean*/enoughToEatAHorse) { 54 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/jsdoc/symbol.tmpl: -------------------------------------------------------------------------------- 1 | 2 | {+data.name+} 3 | {+data.memberOf+} 4 | {+data.isStatic+} 5 | {+data.isa+} 6 | {+data.desc+} 7 | {+data.classDesc+} 8 | 9 | 10 | 11 | {+method.name+} 12 | {+method.memberOf+} 13 | {+method.isStatic+} 14 | {+method.desc+} 15 | 16 | 17 | {+param.type+} 18 | {+param.name+} 19 | {+param.desc+} 20 | {+param.defaultValue+} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | {+property.name+} 29 | {+property.memberOf+} 30 | {+property.isStatic+} 31 | {+property.desc+} 32 | {+property.type+} 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/codeview/symbol.tmpl: -------------------------------------------------------------------------------- 1 | 2 | {+data.name+} 3 | {+data.memberOf+} 4 | {+data.isStatic+} 5 | {+data.isa+} 6 | {+data.desc+} 7 | {+data.classDesc+} 8 | 9 | 10 | 11 | {+method.name+} 12 | {+method.memberOf+} 13 | {+method.isStatic+} 14 | {+method.desc+} 15 | 16 | 17 | {+param.type+} 18 | {+param.name+} 19 | {+param.desc+} 20 | {+param.defaultValue+} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | {+property.name+} 29 | {+property.memberOf+} 30 | {+property.isStatic+} 31 | {+property.desc+} 32 | {+property.type+} 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js: -------------------------------------------------------------------------------- 1 | /** 2 | @namespace Holds functionality related to running plugins. 3 | */ 4 | JSDOC.PluginManager = { 5 | } 6 | 7 | /** 8 | @param name A unique name that identifies that plugin. 9 | @param handlers A collection of named functions. The names correspond to hooks in the core code. 10 | */ 11 | JSDOC.PluginManager.registerPlugin = function(/**String*/name, /**Object*/handlers) { 12 | if (!defined(JSDOC.PluginManager.plugins)) 13 | /** The collection of all plugins. Requires a unique name for each. 14 | */ 15 | JSDOC.PluginManager.plugins = {}; 16 | 17 | 18 | JSDOC.PluginManager.plugins[name] = handlers; 19 | } 20 | 21 | /** 22 | @param hook The name of the hook that is being caught. 23 | @param target Any object. This will be passed as the only argument to the handler whose 24 | name matches the hook name. Handlers cannot return a value, so must modify the target 25 | object to have an effect. 26 | */ 27 | JSDOC.PluginManager.run = function(/**String*/hook, /**Mixed*/target) { 28 | for (var name in JSDOC.PluginManager.plugins) { 29 | if (defined(JSDOC.PluginManager.plugins[name][hook])) { 30 | JSDOC.PluginManager.plugins[name][hook](target); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/java/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /examples/pcl/ch3/main.lisp: -------------------------------------------------------------------------------- 1 | ;; js-lisp/node implementation of http://www.gigamonkeys.com/book/practical-a-simple-database.html 2 | 3 | (setq defvar setq) 4 | 5 | (defvar sys (require "sys")) 6 | (defvar fs (require "fs")) 7 | 8 | (defvar *db* (list)) 9 | (defvar *db-filename* "cds.db") 10 | 11 | (defmacro with-open-file ((fd-name flags filename) & body) 12 | (when (not fs) 13 | (setq fs (require "fs"))) 14 | `(let ((,fd-name (fs.openSync ,filename ,flags))) 15 | ,@body 16 | (fs.close ,fd-name))) 17 | 18 | (defun make-cd (title artist rating ripped) 19 | (list :title title :artist artist :rating rating :ripped ripped)) 20 | 21 | (defun add-record (cd) 22 | (push *db* cd)) 23 | 24 | (defun dump-db () 25 | (dolist (cd *db*) 26 | (print "-------------------------") 27 | (dotimes (i (length cd)) 28 | (let ((key (nth cd i)) 29 | (value (nth cd (inc i)))) 30 | (format t "%8s: %s" key value))) 31 | (print ""))) 32 | 33 | (defun write (& rest) 34 | (rest.unshift nil) 35 | (process.stdout.write (apply #'format rest))) 36 | 37 | (defun save-db () 38 | (with-open-file (fd "w" *db-filename*) 39 | (fs.writeSync fd (format nil "%l\n" *db*)))) 40 | 41 | (defun load-db () 42 | (setq *db* (eval-string (concat "'" (fs.readFileSync *db-filename*))))) 43 | 44 | (load-db) 45 | (dump-db) 46 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/jsdoc/index.tmpl: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | JsDoc Reference - Index 8 | 9 | 10 | 13 | 14 | 15 | 16 | {+include("static/header.html")+} 17 | 18 |
19 | {+publish.classesIndex+} 20 |
21 | 22 |
23 |

Class Index

24 | 25 | 26 |
27 |

{+(new Link().toSymbol(thisClass.alias))+}

28 | {+resolveLinks(summarize(thisClass.classDesc))+} 29 |
30 |
31 |
32 | 33 |
34 |
35 | ©{+JSDOC.opt.D.copyright+}
36 | Documentation generated by JsDoc Toolkit {+JSDOC.VERSION+} on {+new Date()+} 37 |
38 | 39 | -------------------------------------------------------------------------------- /docs/port/template.js: -------------------------------------------------------------------------------- 1 | // Simple JavaScript Templating 2 | // John Resig - http://ejohn.org/ - MIT Licensed 3 | // From: http://ejohn.org/blog/javascript-micro-templating/ 4 | (function(){ 5 | var cache = {}; 6 | 7 | this.tmpl = function tmpl (str, data){ 8 | // Figure out if we're getting a template, or if we need to 9 | // load the template - and be sure to cache the result. 10 | var fn = !/\W/.test(str) ? 11 | cache[str] = cache[str] || 12 | tmpl(document.getElementById(str).innerHTML) : 13 | 14 | // Generate a reusable function that will serve as a template 15 | // generator (and which will be cached). 16 | new Function("obj", 17 | "var p=[],print=function(){p.push.apply(p,arguments);};" + 18 | 19 | // Introduce the data as local variables using with(){} 20 | "with(obj){p.push('" + 21 | 22 | // Convert the template into pure JavaScript 23 | str 24 | .replace(/[\r\t\n]/g, " ") 25 | .split("<%").join("\t") 26 | .replace(/((^|%>)[^\t]*)'/g, "$1\r") 27 | .replace(/\t=(.*?)%>/g, "',$1,'") 28 | .split("\t").join("');") 29 | .split("%>").join("p.push('") 30 | .split("\r").join("\\'") 31 | + "');}return p.join('');"); 32 | 33 | return fn(data || {}); 34 | }; 35 | })(); 36 | -------------------------------------------------------------------------------- /examples/noderepl/run.js: -------------------------------------------------------------------------------- 1 | require.paths.unshift(__dirname); 2 | 3 | var sys = require("sys"), 4 | path = require("path"), 5 | lisp = require("../../build/lisp"); 6 | 7 | function usage () { 8 | command = process.argv.slice(0, 2).join(" "); 9 | sys.puts("Usage: " + command + " [script.lisp]"); 10 | process.exit(1); 11 | } 12 | 13 | function loadLispCore () { 14 | lisp.load("../../build/core.lisp"); 15 | lisp.load("../../build/lib/path.lisp"); 16 | } 17 | 18 | if (process.argv.length > 3) { 19 | sys.puts("Too many arguments"); 20 | usage(); 21 | } else if (process.argv.length === 3) { 22 | // Load the given script. 23 | var filename = process.argv[2]; 24 | loadLispCore(); 25 | lisp.load(filename); 26 | } else { 27 | var stdin = process.openStdin(); 28 | 29 | // Setup the lisp environment 30 | lisp.env.set("lisp", lisp); 31 | loadLispCore(); 32 | lisp.load("utils.lisp"); 33 | lisp.load("repl.lisp"); 34 | 35 | // Print the welcome message 36 | sys.puts("Welcome to the js-lisp REPL\n" + 37 | "Type ^C or ^D to exit"); 38 | 39 | // Setup the repl 40 | var Repl = lisp.env.get("Repl"); 41 | var repl = new Repl(); 42 | 43 | // Setup the stdin listeners 44 | stdin.addListener('data', function (data) { 45 | repl.handleData(data); 46 | return true; 47 | }); 48 | stdin.addListener('end', function () { 49 | sys.puts(""); 50 | }); 51 | } 52 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/java/build_1.4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/plugins/tagSynonyms.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.tagSynonyms", 3 | { 4 | onDocCommentSrc: function(comment) { 5 | comment.src = comment.src.replace(/@methodOf\b/i, "@function\n@memberOf"); 6 | comment.src = comment.src.replace(/@fieldOf\b/i, "@field\n@memberOf"); 7 | }, 8 | 9 | onDocCommentTags: function(comment) { 10 | for (var i = 0, l = comment.tags.length; i < l; i++) { 11 | var title = comment.tags[i].title.toLowerCase(); 12 | var syn; 13 | if ((syn = JSDOC.tagSynonyms.synonyms["="+title])) { 14 | comment.tags[i].title = syn; 15 | } 16 | } 17 | } 18 | } 19 | ); 20 | 21 | new Namespace( 22 | "JSDOC.tagSynonyms", 23 | function() { 24 | JSDOC.tagSynonyms.synonyms = { 25 | "=member": "memberOf", 26 | "=memberof": "memberOf", 27 | "=description": "desc", 28 | "=exception": "throws", 29 | "=argument": "param", 30 | "=returns": "return", 31 | "=classdescription": "class", 32 | "=fileoverview": "overview", 33 | "=extends": "augments", 34 | "=base": "augments", 35 | "=projectdescription": "overview", 36 | "=classdescription": "class", 37 | "=link": "see", 38 | "=borrows": "inherits", 39 | "=scope": "lends", 40 | "=construct": "constructor" 41 | } 42 | } 43 | ); -------------------------------------------------------------------------------- /docs/port/utils.lisp: -------------------------------------------------------------------------------- 1 | (defun toggle-non-planned-items () 2 | (let ((items ($ ".noPlans")) 3 | (first (first items)) 4 | (tool-non-planned ($ "#tool-non-planned"))) 5 | (if (== first.style.display "none") 6 | (progn 7 | (items.show) 8 | (tool-non-planned.html "Hide non-planned items")) 9 | (items.hide) 10 | (tool-non-planned.html "Show non-planned items"))) 11 | ;; This is so the browser won't actually change to the url of 12 | ;; the link that was clicked to call this function. 13 | false) 14 | 15 | (defmacro object-from-plist (plist) 16 | `(object @,,plist)) 17 | 18 | (defun setup-symbols () 19 | (dolist (set symbols) 20 | (let ((body (document.getElementById "body")) 21 | (name (first set)) 22 | (syms (rest set)) 23 | (html "") 24 | (div (document.createElement "div"))) 25 | ;; Make a div to put all the html into. 26 | (div.setAttribute "class" "symbolSet") 27 | ;; Loop over each symbol and add the evaluated symbol-template to html. 28 | (dolist (sym syms) 29 | (let ((data (object-from-plist sym))) 30 | (setq data.class (cond ((starts-with data.type "function") "functions") 31 | ((starts-with data.type "macro") "macros") 32 | ((starts-with data.type "special form") "specialforms") 33 | (t "unknown"))) 34 | (setq html (concat html (tmpl symbol-template data))))) 35 | ;; Evaluate the set-template. 36 | (setq div.innerHTML (tmpl set-template (object :setname name :symbols html))) 37 | (body.appendChild div)))) 38 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | js-lisp Documentation and Examples 5 | 7 | 12 | 13 | 14 | 18 |
19 |

Test Suite

20 | 21 |

REPL

22 | 23 |

Documentation

24 | 30 | 31 |

Examples

32 | 41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /src/javascript/wrapper/_footer.js: -------------------------------------------------------------------------------- 1 | })((typeof(window) != "undefined") ? window : global); // For compatibility with node.js 2 | 3 | // Set this library up to work with node.js 4 | if ((typeof(window) == "undefined") && 5 | (typeof(global) == "object") && global && // Make sure it isn't null 6 | (typeof(require) == "function") && 7 | (typeof(exports) == "object") && exports) { 8 | // We are probably running in node.js now. 9 | // FIXME: Find a better way to tell we're running in node.js 10 | 11 | var sys = require("sys"), 12 | fs = require("fs"), 13 | path = require("path"); 14 | 15 | lisp.log = sys.puts; 16 | 17 | function FileNotFound (message) { 18 | this.toString = function () { 19 | return "FileNotFound: " + message; 20 | }; 21 | } 22 | 23 | lisp.load = function (filepath, paths) { 24 | paths = paths || require.paths; 25 | paths.unshift(""); // A way to check filepath on it's own (with the 26 | // least amount of extra code). 27 | for (var i = 0; i < paths.length; i++) { 28 | var p = path.normalize(path.join(paths[i], filepath)); 29 | var contents = null; 30 | try { 31 | contents = fs.readFileSync(p); 32 | } catch (e) { 33 | if (e instanceof FileNotFound) { 34 | throw e; 35 | } 36 | } 37 | if (contents) { 38 | return lisp.eval(contents); 39 | } 40 | } 41 | throw new FileNotFound("File '" + filepath + "' not found"); 42 | }; 43 | 44 | for (var key in lisp) { 45 | if (lisp.hasOwnProperty(key)) { 46 | exports[key] = lisp[key]; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/codeview/index.tmpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | js-lisp Documentation - Index 6 | 7 | 8 | 9 | 10 | 11 | {+include("static/header.html")+} 12 | 13 |
14 | 17 | 18 |
19 | ©{+JSDOC.opt.D.copyright+}
20 | Generated by JsDoc Toolkit {+JSDOC.VERSION+} on {+new Date()+}
21 | HTML template: Codeview 22 |
23 |
24 | 25 |
26 |
27 |

Class Index

28 | 29 | 37 |
38 |
39 | 40 | -------------------------------------------------------------------------------- /examples/jquery/ui.lisp: -------------------------------------------------------------------------------- 1 | ($ (lambda () 2 | ;; Initialize the UI elements 3 | (let ((accordion ($ "#accordion")) 4 | (tabs ($ "#tabs")) 5 | (dialog ($ "#dialog")) 6 | (dialog-link ($ "#dialog_link")) 7 | (datepicker ($ "#datepicker")) 8 | (slider ($ "#slider")) 9 | (progressbar ($ "#progressbar")) 10 | (static-widgets ($ "#dialog_link, ul#icons li"))) 11 | ;; Accordion 12 | (accordion.accordion (object :header "h3")) 13 | ;; Tabs 14 | (tabs.tabs) 15 | ;; Dialog 16 | (let ((close (lambda () 17 | (funcall ($ this) :dialog "close")))) 18 | (dialog.dialog (object 19 | :autoOpen false 20 | :width 600 21 | :buttons (object 22 | "Ok" close 23 | "Cancel" close)))) 24 | (dialog-link.click (lambda () 25 | (dialog.dialog "open") 26 | false)) 27 | ;; Slider 28 | (slider.slider (object 29 | :range t 30 | :values (array 17 64))) 31 | ;; Date Picker 32 | (datepicker.datepicker (object :inline t)) 33 | ;; Progress Bar 34 | (progressbar.progressbar (object 35 | :value 20)) 36 | ;; "hover states on the static widgets" 37 | (static-widgets.hover 38 | (lambda () 39 | (funcall ($ this) :addClass "ui-state-hover")) 40 | (lambda () 41 | (funcall ($ this) :removeClass "ui-state-hover")))))) 42 | 43 | ($ (lambda () 44 | (let ((update-progressbar (lambda () 45 | (let ((progressbar ($ "#progressbar"))) 46 | (progressbar.progressbar (object 47 | :value (% (1+ (progressbar.progressbar "option" "value")) 100)))) 48 | (setTimeout #'update-progressbar 100)))) 49 | (update-progressbar)))) 50 | -------------------------------------------------------------------------------- /src/javascript/wrapper/_header.js: -------------------------------------------------------------------------------- 1 | // ================================================================================ 2 | // js-lisp: A, 100% JavaScript, lisp interpreter for browser scripting 3 | // 4 | // Disclaimer: DO NOT attempt to use this project for any production code 5 | // whatsoever. This project is still VERY young; if there were such a thing 6 | // as negative version numbers, it would have one. For now, this is a toy 7 | // project. It is my hope that js-lisp will one day grow up to become a solid 8 | // library devs around the world can use to sefely get their Lisp fix while 9 | // they get their JavaScript fix, but until that time, DO NOT use this in 10 | // production code (and if you do, I'm not responsible for the craziness that 11 | // will most certainly ensue thereafter). 12 | // 13 | // This program is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU General Public License as published by 15 | // the Free Software Foundation, either version 3 of the License, or 16 | // (at your option) any later version. 17 | // 18 | // This program is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU General Public License 24 | // along with this program. If not, see . 25 | // 26 | // Author: William Bowers 27 | // ================================================================================ 28 | 29 | /** 30 | * @namespace 31 | */ 32 | var lisp = (function (global) { 33 | -------------------------------------------------------------------------------- /examples/repl/style.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | background: #333; 3 | height: 100%; 4 | margin: 0px; 5 | overflow: hidden; 6 | padding: 0px; 7 | } 8 | 9 | #console { 10 | font-size: 14px; 11 | height: 100%; 12 | margin: 0px; 13 | overflow: auto; 14 | padding: 0px; 15 | top: 0px; 16 | } 17 | 18 | #console .jquery-console-inner { 19 | margin: 0px; 20 | padding: 10px; 21 | white-space: pre; 22 | } 23 | 24 | * html #console .jquery-console-inner { 25 | height: 100%; 26 | } 27 | 28 | #console .jquery-console-welcome { 29 | background: #000; 30 | color: #fff; 31 | font: normal 16pt verdana; 32 | margin: -10px -10px 10px; 33 | padding: 10px; 34 | } 35 | 36 | #console .jquery-console-prompt-box { 37 | color: #fff; 38 | font-family: monospace; 39 | } 40 | 41 | #console .jquery-console-focus .jquery-console-cursor { 42 | background: #fefefe; 43 | color: #333; 44 | font-weight: bold; 45 | } 46 | 47 | #console .jquery-console-message-error { 48 | color: #ef0505; 49 | font-family: sans-serif; 50 | font-weight: bold; 51 | padding: 0.1em; 52 | } 53 | 54 | #console .jquery-console-message-value { 55 | color: #1ad027; 56 | font-family: monospace; 57 | padding: 0.1em; 58 | } 59 | 60 | #console .jquery-console-message-type { 61 | color: #52666f; 62 | font-family: monospace; 63 | padding: 0.1em; 64 | } 65 | 66 | #console .jquery-console-prompt-label { 67 | font-weight: bold; 68 | } 69 | 70 | #console .jquery-console-stdout { 71 | background: #444; 72 | color: #ccc; 73 | font-size: 0.9em; 74 | font-family: monospace; 75 | margin: 3px 0px; 76 | padding: 0.2em 0.3em; 77 | } 78 | 79 | #console .notice { 80 | background: #373737; 81 | color: #656565; 82 | margin: 10px; 83 | padding: 2px 5px; 84 | } 85 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | js-lisp Test Runner 5 | 7 | 8 | 9 | 10 | 14 | 20 | 21 | 22 | 50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /docs/port/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: verdana, arial, helvetica, sans-serif; 3 | font-size: small !important; 4 | margin: 0px; 5 | padding: 0px; 6 | } 7 | 8 | .clear { 9 | clear: both; 10 | } 11 | 12 | #header { 13 | background: #000; 14 | margin: 0px 0px 10px; 15 | padding: 10px; 16 | } 17 | 18 | h1 { 19 | color: #fff; 20 | float: left; 21 | font-size: 16pt; 22 | font-weight: normal; 23 | margin: 0px; 24 | } 25 | 26 | h3 { 27 | font-size: 14pt; 28 | margin: 30px 2px 10px; 29 | } 30 | 31 | #counts { 32 | color: #ccc !important; 33 | float: right; 34 | font-size: 10px; 35 | font-weight: normal; 36 | width: auto !important; 37 | } 38 | 39 | #counts td { 40 | border-style: none !important; 41 | } 42 | 43 | #done-count { 44 | color: #00ed06; 45 | } 46 | 47 | #not-done-count { 48 | color: #f00; 49 | } 50 | 51 | .count { 52 | text-align: right; 53 | } 54 | 55 | #body { 56 | margin: 0px 10px 10px; 57 | } 58 | 59 | #controls { 60 | 61 | } 62 | 63 | #controls nav { 64 | float: left; 65 | font-weight: bold; 66 | margin: 0px 0px 10px; 67 | } 68 | 69 | #controls #tools { 70 | float: right; 71 | } 72 | 73 | table { 74 | border-collapse: collapse; 75 | width: 100%; 76 | } 77 | 78 | td { 79 | border: 1px solid #fff; 80 | padding: 3px 5px; 81 | } 82 | 83 | td.symbol { 84 | width: 250px; 85 | } 86 | 87 | td.type { 88 | width: 300px; 89 | } 90 | 91 | .notDone { 92 | background: #F6B6B3; 93 | color: #781A15; 94 | } 95 | 96 | .notDone a { 97 | color: #781A15; 98 | } 99 | 100 | .done { 101 | background: #B0F3C8; 102 | color: #227836; 103 | } 104 | 105 | .done a { 106 | color: #227836; 107 | } 108 | 109 | .noPlans, .noPlans a { 110 | background: #e5e5e5; 111 | color: #aaa !important; 112 | } 113 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/jsrun.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | # launcher script for jsdoc 4 | # Author: Avi Deitcher 5 | # 6 | # This program is released under the MIT License as follows: 7 | 8 | # Copyright (c) 2008-2009 Atomic Inc 9 | # 10 | #Permission is hereby granted, free of charge, to any person 11 | #obtaining a copy of this software and associated documentation 12 | #files (the "Software"), to deal in the Software without 13 | #restriction, including without limitation the rights to use, 14 | #copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | #copies of the Software, and to permit persons to whom the 16 | #Software is furnished to do so, subject to the following 17 | #conditions: 18 | ## 19 | #The above copyright notice and this permission notice shall be 20 | #included in all copies or substantial portions of the Software. 21 | # 22 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | #EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 24 | #OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | #NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 26 | #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 27 | #WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | #FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 29 | #OTHER DEALINGS IN THE SOFTWARE. 30 | # 31 | 32 | 33 | if [[ -n "$JSDOCDIR" ]]; then 34 | _DOCDIR="-Djsdoc.dir=$JSDOCDIR" 35 | _APPDIR="$JSDOCDIR/app" 36 | _BASEDIR="$JSDOCDIR" 37 | else 38 | _DOCDIR="" 39 | _APPDIR="./app" 40 | _BASEDIR="." 41 | fi 42 | 43 | if [[ -n "$JSDOCTEMPLATEDIR" ]]; then 44 | _TDIR="-Djsdoc.template.dir=$JSDOCTEMPLATEDIR" 45 | else 46 | _TDIR="" 47 | fi 48 | 49 | CMD="java $_DOCDIR $_TDIR -jar $_BASEDIR/jsrun.jar $_APPDIR/run.js $@" 50 | echo $CMD 51 | $CMD 52 | 53 | -------------------------------------------------------------------------------- /examples/paip/new-account/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Examples - PAIP - (new-account) 5 | 7 | 8 | 9 | 10 | 15 | 21 | 22 | 23 | 51 |
52 | 53 | 54 | -------------------------------------------------------------------------------- /docs/ideas/typed-arguments.md: -------------------------------------------------------------------------------- 1 | # Ideas for typed arguments in functions and macros 2 | 3 | If given a single atom, the argument must match that atom. If given a list of atoms, the argument must match one of them. The atoms can be one of two things, a Symbol or a Keyword. If the atom is a Symbol, the match is performed as such: typeof(argument) == atom.toString(). If the atom is a Keyword, the match is performed like so: (argument instanceof lisp.env.get(atom.toString())). If a given atom is neither a Symbol nor a Keyword an error will be thrown ("Argument type specification must be a Symbol or Keyword"). If any given argument during a function (or macro) call does not match the required argument type (again, only if a required type is specified) an error will be thrown ("Argument " + toLisp(argument) + " does not match the required type " + toLisp(type), or "Argument " + toLisp(argument) + " does not match one of the required types " + toLisp(types)). 4 | 5 | (defun first (seq:Array) 6 | (nth 0 lst)) 7 | 8 | (defun push (seq:Array item) ; seq must be an Array, whereas item can be anything 9 | (seq.push item)) 10 | 11 | (defun starts-with (str:String pattern:(String RegExp) &opt start::number end::number) 12 | (when (is-regexp pattern) 13 | (setq pattern pattern.source)) 14 | (!! (str.match (new RegExp (concat "^" pattern))))) 15 | 16 | (defun request (url &key method callback:function) 17 | ...) 18 | 19 | (request "google.com" :method "GET" :callback (lambda (req:XMLHttpRequest) (print e.responseText))) 20 | 21 | (defun starts-with ((str String) (pattern (String RegExp)) 22 | &opt ((start :number) 0) ((end :number) -1)) 23 | ...) 24 | 25 | (defun starts-with ([str String]) ...) 26 | 27 | (defun starts-with (str->String) ...) 28 | 29 | (defun starts-with (str) ...) 30 | (defun starts-with (str<:number>) ...) 31 | (defun starts-with (str) ...) 32 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/plugins/publishSrcHilite.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.publishSrcHilite", 3 | { 4 | onPublishSrc: function(src) { 5 | if (src.path in JsHilite.cache) { 6 | return; // already generated src code 7 | } 8 | else JsHilite.cache[src.path] = true; 9 | 10 | try { 11 | var sourceCode = IO.readFile(src.path); 12 | } 13 | catch(e) { 14 | print(e.message); 15 | quit(); 16 | } 17 | 18 | var hiliter = new JsHilite(sourceCode, src.charset); 19 | src.hilited = hiliter.hilite(); 20 | } 21 | } 22 | ); 23 | 24 | function JsHilite(src, charset) { 25 | 26 | var tr = new JSDOC.TokenReader(); 27 | 28 | tr.keepComments = true; 29 | tr.keepDocs = true; 30 | tr.keepWhite = true; 31 | 32 | this.tokens = tr.tokenize(new JSDOC.TextStream(src)); 33 | 34 | // TODO is redefining toString() the best way? 35 | JSDOC.Token.prototype.toString = function() { 36 | return ""+this.data.replace(/"; 37 | } 38 | 39 | if (!charset) charset = "utf-8"; 40 | 41 | this.header = ' '+ 42 | "
";
50 | 	this.footer = "
"; 51 | this.showLinenumbers = true; 52 | } 53 | 54 | JsHilite.cache = {}; 55 | 56 | JsHilite.prototype.hilite = function() { 57 | var hilited = this.tokens.join(""); 58 | var line = 1; 59 | if (this.showLinenumbers) hilited = hilited.replace(/(^|\n)/g, function(m){return m+""+((line<10)? " ":"")+((line<100)? " ":"")+(line++)+" "}); 60 | 61 | return this.header+hilited+this.footer; 62 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/frame/Hash.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | @example 4 | var _index = new Hash(); 5 | _index.set("a", "apple"); 6 | _index.set("b", "blue"); 7 | _index.set("c", "coffee"); 8 | 9 | for (var p = _index.first(); p; p = _index.next()) { 10 | print(p.key+" is for "+p.value); 11 | } 12 | 13 | */ 14 | var Hash = function() { 15 | this._map = {}; 16 | this._keys = []; 17 | this._vals = []; 18 | this.reset(); 19 | } 20 | 21 | Hash.prototype.set = function(k, v) { 22 | if (k != "") { 23 | this._keys.push(k); 24 | this._map["="+k] = this._vals.length; 25 | this._vals.push(v); 26 | } 27 | } 28 | 29 | Hash.prototype.replace = function(k, k2, v) { 30 | if (k == k2) return; 31 | 32 | var offset = this._map["="+k]; 33 | this._keys[offset] = k2; 34 | if (typeof v != "undefined") this._vals[offset] = v; 35 | this._map["="+k2] = offset; 36 | delete(this._map["="+k]); 37 | } 38 | 39 | Hash.prototype.drop = function(k) { 40 | if (k != "") { 41 | var offset = this._map["="+k]; 42 | this._keys.splice(offset, 1); 43 | this._vals.splice(offset, 1); 44 | delete(this._map["="+k]); 45 | for (var p in this._map) { 46 | if (this._map[p] >= offset) this._map[p]--; 47 | } 48 | if (this._cursor >= offset && this._cursor > 0) this._cursor--; 49 | } 50 | } 51 | 52 | Hash.prototype.get = function(k) { 53 | if (k != "") { 54 | return this._vals[this._map["="+k]]; 55 | } 56 | } 57 | 58 | Hash.prototype.keys = function() { 59 | return this._keys; 60 | } 61 | 62 | Hash.prototype.hasKey = function(k) { 63 | if (k != "") { 64 | return (typeof this._map["="+k] != "undefined"); 65 | } 66 | } 67 | 68 | Hash.prototype.values = function() { 69 | return this._vals; 70 | } 71 | 72 | Hash.prototype.reset = function() { 73 | this._cursor = 0; 74 | } 75 | 76 | Hash.prototype.first = function() { 77 | this.reset(); 78 | return this.next(); 79 | } 80 | 81 | Hash.prototype.next = function() { 82 | if (this._cursor++ < this._keys.length) 83 | return {key: this._keys[this._cursor-1], value: this._vals[this._cursor-1]}; 84 | } -------------------------------------------------------------------------------- /docs/port/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Status of the CL language port 5 | 6 | 7 | 8 | 9 | 15 | 16 | 17 | 31 | 32 |
33 |
34 | 61 | 62 |
63 | 64 |
65 | 66 |
67 |
68 |
69 | 70 | 71 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | {! Link.base = ""; /* all generated links will be relative to this */ !} 7 | JsDoc Reference - File Index 8 | 9 | 10 | 13 | 14 | 15 | 16 | {+include("static/header.html")+} 17 | 18 |
19 | {+publish.classesIndex+} 20 |
21 | 22 |
23 |

File Index

24 | 25 | 26 |
27 |

{+new Link().toSrc(item.alias).withText(item.name)+}

28 | {+resolveLinks(item.desc)+} 29 |
30 | 31 |
Author:
32 |
{+item.author+}
33 |
34 | 35 |
Version:
36 |
{+item.version+}
37 |
38 | {! var locations = item.comment.getTag('location').map(function($){return $.toString().replace(/(^\$ ?| ?\$$)/g, '').replace(/^HeadURL: https:/g, 'http:');}) !} 39 | 40 |
Location:
41 | 42 |
{+location+}
43 |
44 |
45 |
46 |
47 |
48 |
49 | 50 |
51 |
52 | ©{+JSDOC.opt.D.copyright+}
53 | Documentation generated by JsDoc Toolkit {+JSDOC.VERSION+} on {+new Date()+} 54 |
55 | 56 | -------------------------------------------------------------------------------- /src/lisp/core/macros.lisp: -------------------------------------------------------------------------------- 1 | (setq case switch) ;; Adds an alias to switch for case 2 | 3 | 4 | (defmacro defclass (name & params) 5 | "Creates a new class, using lisp.Class, passing in the given 6 | arguments as a plist to lisp.Class.extend()." 7 | ;; Check for the existence of a doc string 8 | (when (and (== (% (length params) 2) 1) 9 | (is-string (first params))) 10 | (params.shift)) 11 | `(setq ,name (lisp.Class.extend (object ,@params)))) 12 | 13 | 14 | (defmacro defobject (name & props) 15 | "Creates an object from the given arguments (after name) as 16 | a plist." 17 | ;; Check for the existence of a doc string 18 | (when (and (== (% (length props) 2) 1) 19 | (is-string (first props))) 20 | (props.shift)) 21 | `(setq ,name (object ,@props))) 22 | 23 | 24 | (defmacro dotimes ((name count) & body) 25 | `(do ((,name 0 (1+ ,name))) 26 | ((>= ,name ,count)) 27 | ,@body)) 28 | 29 | 30 | (defmacro dolist ((name lst) & body) 31 | (let ((indexname (gensym))) 32 | `(do ((,indexname 0 (1+ ,indexname)) 33 | (,name (nth ,lst ,indexname))) 34 | ((>= ,indexname (length ,lst))) 35 | ,@body))) 36 | 37 | 38 | (defmacro collect ((item-name lst) & body) 39 | "Creates a list of (key value) pairs from `object', iterates over 40 | each one, evaluating all of the expressions in `body' for every 41 | iteration, and collecting into a list every item where the last 42 | `body' expression evaluates to true." 43 | ;; Input validation 44 | (let ((basemsg "(collect) expects arguments in the form: ((item-name lst) & body).")) 45 | (assert (is-symbol item-name) 46 | (format nil "%s item-name must be a symbol (got %s)" basemsg item-name))) 47 | `(let ((set (list))) 48 | (foreach (,item-name ,lst) 49 | (when (progn ,@body) 50 | (push set ,item-name))) 51 | set)) 52 | 53 | 54 | (defmacro generator (arglist & body) 55 | "A shortcut for defining a new generator. The new generator 56 | closes over a shortcut function for throwing a StopIteration." 57 | `(let ((stop-iteration (lambda () 58 | (throw (new lisp.exception.StopIteration))))) 59 | (new lisp.Generator (lambda ,arglist 60 | ,@body)))) 61 | -------------------------------------------------------------------------------- /src/javascript/utils/stream.js: -------------------------------------------------------------------------------- 1 | var StreamException = Class.extend({ 2 | init: function (message) { 3 | this.message = message; 4 | }, 5 | toString: function () { 6 | return "StreamException: " + this.message; 7 | } 8 | }); 9 | 10 | var StreamEOFException = StreamException.extend({ 11 | init: function (message) { 12 | this.message = message; 13 | }, 14 | toString: function () { 15 | return "StreamEOFException: " + this.message; 16 | } 17 | }); 18 | 19 | var StringStream = Class.extend({ 20 | init: function (data) { 21 | assert(typeof(data) === "string", "Invalid object as " + 22 | "StringStream input: " + data); 23 | 24 | this.data = data; 25 | this.length = data.length; 26 | this.position = 0; 27 | }, 28 | 29 | slice: function () { 30 | return this.data.slice.apply(this.data, arguments); 31 | }, 32 | 33 | rest: function (from) { 34 | from = from || this.position; 35 | return this.slice(from, this.data.length); 36 | }, 37 | 38 | bof: function () { 39 | return this.position < 0; 40 | }, 41 | 42 | eof: function () { 43 | return this.position >= this.length; 44 | }, 45 | 46 | peek: function (distance) { 47 | distance = distance || 0; 48 | return this.charAt(this.position + distance); 49 | }, 50 | 51 | charAt: function (index) { 52 | return this.data.charAt(index); 53 | }, 54 | 55 | next: function (count) { 56 | if (this.eof()) { 57 | throw new StreamEOFException("EOF reached in StringStream"); 58 | } 59 | 60 | count = count || 1; 61 | 62 | var slice = this.slice(this.position, this.position+count); 63 | this.position += count; 64 | return slice; 65 | }, 66 | 67 | prev: function (count) { 68 | count = count || 1; 69 | this.position -= count; 70 | 71 | assert(!this.bof(), "Cannot access character at position " + 72 | this.position + " of StringStream"); 73 | 74 | return this.charAt(this.position); 75 | }, 76 | 77 | swallowWhitespace: function () { 78 | while (WHITESPACE.indexOf(this.peek()) != -1 && !this.eof()) { 79 | this.position++; 80 | } 81 | }, 82 | 83 | line: function () { 84 | var substr = this.data.slice(0, this.position); 85 | var matches = substr.match(/\n/g); 86 | return matches ? matches.length+1 : 1; 87 | } 88 | }); 89 | -------------------------------------------------------------------------------- /docs/files.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | js-lisp Documentation - File Index 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 |
16 | 40 | 41 |
42 | 43 | Generated by JsDoc Toolkit 2.3.2 on Tue Jul 13 2010 12:33:47 GMT-0700 (PDT)
44 | HTML template: Codeview 45 |
46 |
47 | 48 |
49 |
50 |

File Index

51 | 52 |
    53 | 54 |
  • 55 |

    build/lisp.js

    56 | 57 | 58 | 59 |
    60 | 61 | 62 | 63 | 64 | 65 | 66 |
    67 |
  • 68 | 69 |
70 |
71 |
72 | 73 | -------------------------------------------------------------------------------- /examples/noderepl/repl.lisp: -------------------------------------------------------------------------------- 1 | (defclass Repl 2 | "A \"read-eval-print loop\" written in lisp, for lisp." 3 | :init (lambda (&opt props) 4 | "Initializes the repl with the given properties, or the defaults." 5 | (||= props (object)) 6 | (setq this.ps1 (|| props.ps1 ">> ")) 7 | (setq this.ps2 (|| props.ps2 ".. ")) 8 | (setq this.ps3 (|| props.ps3 "=> ")) 9 | (setq this.multilineCommand false) 10 | (setq this.data "") 11 | (this.newCommand)) 12 | 13 | :handleError (lambda (error) 14 | "Prints the given error and a new prompt." 15 | (print error) 16 | (this.newCommand)) 17 | 18 | :newCommand (lambda () 19 | "Prints a new prompt." 20 | (let ((prompt (if this.multilineCommand 21 | this.ps2 22 | this.ps1))) 23 | (process.stdout.write prompt))) 24 | 25 | :handleData (lambda (data) 26 | "Handles data from stdin." 27 | (setq this.data (concat this.data (to-string data))) 28 | (if (== data "\n") 29 | (progn 30 | (when (not this.multilineCommand) 31 | (setq this.data "")) 32 | (this.newCommand)) 33 | (try 34 | (let ((expressions (lisp.parse.script this.data)) 35 | (ret nil) 36 | (str nil)) 37 | (when (> (length expressions) 1) 38 | (format t "** evaluating %s expressions **" (length expressions))) 39 | (dolist (expression expressions) 40 | (setq str (lisp-string expression)) 41 | (when (> expressions.length 1) 42 | (this.newCommand) 43 | (print str)) 44 | (try 45 | (setq ret (lisp-string (eval-string str))) 46 | (format t "%s%s" this.ps3 ret) 47 | (:catch (e) 48 | (cond ((instanceof e lisp.exception.StreamEOFException) (throw e)) 49 | (t (print e))))))) 50 | (setq this.multilineCommand false) 51 | (setq this.data "") 52 | (this.newCommand) 53 | (:catch (e) 54 | (cond ((instanceof e lisp.exception.StreamEOFException) 55 | (setq this.multilineCommand true) 56 | (this.newCommand)) 57 | (t (setq this.multilineCommand false) 58 | (setq this.data "") 59 | (this.handleError e)))))))) 60 | -------------------------------------------------------------------------------- /src/javascript/lisp/Env.js: -------------------------------------------------------------------------------- 1 | var Env = Class.extend({ 2 | init: function (parent, symbols) { 3 | this.parent = parent || null; 4 | this.symbols = symbols || {}; 5 | }, 6 | 7 | has: function (symbol) { 8 | if (symbol instanceof Symbol) { 9 | symbol = symbol.value; 10 | } 11 | 12 | if (this.symbols.hasOwnProperty(symbol)) { 13 | return true; 14 | } else if (!this.parent) { 15 | return false; 16 | } else { 17 | if (this.parent instanceof Env) { 18 | return this.parent.has(symbol); 19 | } else { 20 | return this.parent[symbol] != undefined; 21 | } 22 | } 23 | }, 24 | 25 | get: function (symbol) { 26 | symbol = String(symbol); 27 | 28 | var parts = symbol.split("."); 29 | var value; 30 | symbol = parts[0]; 31 | parts = parts.slice(1); 32 | 33 | if (this.symbols.hasOwnProperty(symbol) || this.symbols[symbol]) { 34 | value = this.symbols[symbol]; 35 | } else if (!this.parent) { 36 | value = undefined; 37 | } else { 38 | if (this.parent instanceof Env) { 39 | value = this.parent.get(symbol); 40 | } else { 41 | value = this.parent[symbol]; 42 | } 43 | } 44 | 45 | if (value && parts.length > 0) { 46 | for (var i = 0; i < parts.length; i++) { 47 | value = value[parts[i]]; 48 | } 49 | } 50 | 51 | return value; 52 | }, 53 | 54 | set: function (symbol, value) { 55 | symbol = String(symbol); 56 | 57 | var parts = symbol.split("."); 58 | 59 | if (parts.length > 1) { 60 | var name = parts.slice(0,parts.length-1).join("."); 61 | object = this.get(name); 62 | 63 | try { 64 | object[parts[parts.length-1]] = value; 65 | } catch (e) { 66 | throw new Error(name + " is unsubscriptable: " + e); 67 | } 68 | } else { 69 | if (this.has(symbol)) { 70 | if (this.symbols.hasOwnProperty(symbol)) { 71 | this.symbols[symbol] = value; 72 | } else if (this.parent instanceof Env) { 73 | try { 74 | this.parent.set(symbol, value); 75 | } catch (e) { 76 | this.symbols[symbol] = value; 77 | } 78 | } else { 79 | this.parent[symbol] = value; 80 | } 81 | } else { 82 | var object = this; 83 | while (object.parent && object.parent.symbols != global) { 84 | object = object.parent; 85 | } 86 | object.symbols[symbol] = value; 87 | } 88 | } 89 | }, 90 | 91 | // FIXME: This method sucks. 92 | let: function (symbol, value) { 93 | symbol = String(symbol); 94 | this.symbols[symbol] = value; 95 | } 96 | }); 97 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/codeview/allfiles.tmpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {! Link.base = ""; /* all generated links will be relative to this */ !} 6 | js-lisp Documentation - File Index 7 | 8 | 9 | 10 | 11 | 12 | {+include("static/header.html")+} 13 | 14 |
15 | 18 | 19 |
20 | ©{+JSDOC.opt.D.copyright+}
21 | Generated by JsDoc Toolkit {+JSDOC.VERSION+} on {+new Date()+}
22 | HTML template: Codeview 23 |
24 |
25 | 26 |
27 |
28 |

File Index

29 | 30 |
    31 | 32 |
  • 33 |

    {+new Link().toSrc(item.alias).withText(item.name)+}

    34 | 35 | {+resolveLinks(item.desc)+} 36 | 37 |
    38 | 39 |
    Author:
    40 |
    {+item.author+}
    41 |
    42 | 43 | 44 |
    Version:
    45 |
    {+item.version+}
    46 |
    47 | 48 | {! var locations = item.comment.getTag('location').map(function($){return $.toString().replace(/(^\$ ?| ?\$$)/g, '').replace(/^HeadURL: https:/g, 'http:');}) !} 49 | 50 |
    Location:
    51 | 52 |
    {+location+}
    53 |
    54 |
    55 |
    56 |
  • 57 |
    58 |
59 |
60 |
61 | 62 | -------------------------------------------------------------------------------- /src/javascript/lisp.js: -------------------------------------------------------------------------------- 1 | return { 2 | VERSION: "0.0.1", 3 | 4 | Class: Class, 5 | Env: Env, 6 | Macro: Macro, 7 | Symbol: Symbol, 8 | Keyword: Keyword, 9 | Generator: Generator, 10 | 11 | env: ROOT_ENV, 12 | 13 | exception: { 14 | StreamException: StreamException, 15 | StreamEOFException: StreamEOFException, 16 | ArgumentError: ArgumentError, 17 | StopIteration: StopIteration 18 | }, 19 | 20 | parse: parse, 21 | defun: defun, 22 | defmacro: defmacro, 23 | 24 | /** 25 | * Evaluates a string as lisp code. 26 | */ 27 | eval: function (string, env) { 28 | var tempEnv = lisp.env; 29 | lisp.env = env || lisp.env; 30 | try { 31 | var expressions = parse.script(string); 32 | var ret = null; 33 | for (var i = 0; i < expressions.length; i++) { 34 | ret = resolve(expressions[i]); 35 | } 36 | } finally { 37 | lisp.env = tempEnv; 38 | } 39 | return ret; 40 | }, 41 | 42 | /** 43 | * This method is here so lisp.log can be called in code and it 44 | * will work regardless of if we're being called in a browser (with 45 | * or without "console") or in node.js (if we're in node.js, this 46 | * will be replaced with sys.puts). 47 | */ 48 | log: function () { 49 | if (typeof(console) == "object" && console.log) { 50 | console.log.apply(console, arguments); 51 | } 52 | }, 53 | 54 | /** 55 | * Loads an arbitrary file and evaluates it as lisp code. 56 | */ 57 | load: function (source, callback) { 58 | makeRequest(source, function (script) { 59 | lisp.eval(script); 60 | if (callback) { 61 | callback(source); 62 | } 63 | }); 64 | }, 65 | 66 | /** 67 | * Handles a script tag by loading and evaluating the script pointed 68 | * to by its src attribute (if there is one), and then by evaluating 69 | * its inner content (if there is any). 70 | */ 71 | dotag: function (tag) { 72 | if (tag.src) { 73 | lisp.load(tag.src, function (script) { 74 | lisp.eval(tag.textContent); 75 | tag.parentElement.removeChild(tag); 76 | }); 77 | } else { 78 | lisp.eval(tag.textContent); 79 | tag.parentElement.removeChild(tag); 80 | } 81 | }, 82 | 83 | /** 84 | * Grabs all of the unevaluated text/lisp script tags so far in the 85 | * html document and evaluates their contents. 86 | */ 87 | run: function () { 88 | var tags = document.getElementsByTagName("script"); 89 | for (var i = 0; i < tags.length; i++) { 90 | var tag = tags[i]; 91 | if (tag.type == "text/lisp") { 92 | lisp.dotag(tag); 93 | } 94 | } 95 | } 96 | }; 97 | -------------------------------------------------------------------------------- /support/vendor/Class.js: -------------------------------------------------------------------------------- 1 | /*jsl:ignore*/ // Suppress jsl warnings 2 | 3 | (function () { 4 | var initializing = false; 5 | var fnTest = (/xyz/).test(function(){xyz;}) ? (/\b_super\b/) : /.*/; 6 | 7 | /** 8 | *

Defines a base class from which to create new classes that can be 9 | * extended into new classes as well.

10 | * 11 | *

This constructor does nothing.

12 | * 13 | *

Modified from: http://ejohn.org/blog/simple-javascript-inheritance/

14 | * 15 | * @class 16 | * @name Class 17 | */ 18 | this.Class = function () {}; 19 | 20 | /** 21 | *

Creates a new class that inherits from the calling class.

22 | * 23 | * @function 24 | * 25 | * @param {string, object} classNameOrProps 26 | * Either the name of the class, or an object containing the class' properties. 27 | * @param {object} props 28 | * An object containing the class' properties (only if classNameOrProps 29 | * specifies the class name). 30 | */ 31 | Class.extend = function (classNameOrProps, props) { 32 | var _super = this.prototype; 33 | var className = props ? classNameOrProps : "Class"; 34 | props = props || classNameOrProps; 35 | 36 | // Instantiate a base class (but only create the instance, 37 | // don't run the init constructor) 38 | initializing = true; 39 | var prototype = new this(); 40 | initializing = false; 41 | 42 | // Copy the properties over onto the new prototype 43 | for (var name in props) { 44 | // Check if we're overwriting an existing function 45 | if (typeof props[name] == "function" && 46 | typeof _super[name] == "function" && 47 | fnTest.test(props[name])) { 48 | prototype[name] = (function(name, fn){ 49 | return function() { 50 | var tmp = this._super; 51 | 52 | // Add a new ._super() method that is the same method 53 | // but on the super-class 54 | this._super = _super[name]; 55 | 56 | // The method only need to be bound temporarily, so we 57 | // remove it when we're done executing 58 | var ret = fn.apply(this, arguments); 59 | this._super = tmp; 60 | 61 | return ret; 62 | }; 63 | })(name, props[name]); 64 | } else { 65 | prototype[name] = props[name]; 66 | } 67 | } 68 | 69 | // The new class 70 | var NewClass = function () { 71 | // All construction is actually done in the init method 72 | if (!initializing && this.init) 73 | this.init.apply(this, arguments); 74 | } 75 | 76 | NewClass.className = className; 77 | NewClass.prototype = prototype; 78 | NewClass.constructor = Class; 79 | NewClass.extend = arguments.callee; 80 | 81 | return NewClass; 82 | }; 83 | })(); 84 | 85 | /*jsl:end*/ 86 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/frame/String.js: -------------------------------------------------------------------------------- 1 | /** 2 | @name String 3 | @class Additions to the core string object. 4 | */ 5 | 6 | /** @author Steven Levithan, released as public domain. */ 7 | String.prototype.trim = function() { 8 | var str = this.replace(/^\s+/, ''); 9 | for (var i = str.length - 1; i >= 0; i--) { 10 | if (/\S/.test(str.charAt(i))) { 11 | str = str.substring(0, i + 1); 12 | break; 13 | } 14 | } 15 | return str; 16 | } 17 | /*t: 18 | plan(6, "Testing String.prototype.trim."); 19 | 20 | var s = " a bc ".trim(); 21 | is(s, "a bc", "multiple spaces front and back are trimmed."); 22 | 23 | s = "a bc\n\n".trim(); 24 | is(s, "a bc", "newlines only in back are trimmed."); 25 | 26 | s = "\ta bc".trim(); 27 | is(s, "a bc", "tabs only in front are trimmed."); 28 | 29 | s = "\n \t".trim(); 30 | is(s, "", "an all-space string is trimmed to empty."); 31 | 32 | s = "a b\nc".trim(); 33 | is(s, "a b\nc", "a string with no spaces in front or back is trimmed to itself."); 34 | 35 | s = "".trim(); 36 | is(s, "", "an empty string is trimmed to empty."); 37 | 38 | */ 39 | 40 | String.prototype.balance = function(open, close) { 41 | var i = 0; 42 | while (this.charAt(i) != open) { 43 | if (i == this.length) return [-1, -1]; 44 | i++; 45 | } 46 | 47 | var j = i+1; 48 | var balance = 1; 49 | while (j < this.length) { 50 | if (this.charAt(j) == open) balance++; 51 | if (this.charAt(j) == close) balance--; 52 | if (balance == 0) break; 53 | j++; 54 | if (j == this.length) return [-1, -1]; 55 | } 56 | 57 | return [i, j]; 58 | } 59 | /*t: 60 | plan(16, "Testing String.prototype.balance."); 61 | 62 | var s = "{abc}".balance("{","}"); 63 | is(s[0], 0, "opener in first is found."); 64 | is(s[1], 4, "closer in last is found."); 65 | 66 | s = "ab{c}de".balance("{","}"); 67 | is(s[0], 2, "opener in middle is found."); 68 | is(s[1], 4, "closer in middle is found."); 69 | 70 | s = "a{b{c}de}f".balance("{","}"); 71 | is(s[0], 1, "nested opener is found."); 72 | is(s[1], 8, "nested closer is found."); 73 | 74 | s = "{}".balance("{","}"); 75 | is(s[0], 0, "opener with no content is found."); 76 | is(s[1], 1, "closer with no content is found."); 77 | 78 | s = "".balance("{","}"); 79 | is(s[0], -1, "empty string opener is -1."); 80 | is(s[1], -1, "empty string closer is -1."); 81 | 82 | s = "{abc".balance("{","}"); 83 | is(s[0], -1, "opener with no closer returns -1."); 84 | is(s[1], -1, "no closer returns -1."); 85 | 86 | s = "abc".balance("{","}"); 87 | is(s[0], -1, "no opener or closer returns -1 for opener."); 88 | is(s[1], -1, "no opener or closer returns -1 for closer."); 89 | 90 | s = "a= levels; 6 | var newline = pretty ? '\n' : ''; 7 | var singleprefix = pretty ? times(' ', 2) : ''; 8 | var prefix = pretty ? times(singleprefix, level) : ''; 9 | 10 | var json; 11 | var value; 12 | 13 | switch (typeof(object)) 14 | { 15 | case 'undefined': 16 | return 'undefined'; 17 | case 'object': 18 | if (!object) { 19 | // 'object' is null. 20 | return 'null'; 21 | } else if (object instanceof Array) { 22 | // 'object' is an Array. 23 | json = '['; 24 | 25 | if (!done) { 26 | json += newline; 27 | value = null; 28 | for (var i = 0; i < object.length; i++) { 29 | value = toJSON(object[i], pretty, levels, level+1); 30 | json += prefix + singleprefix + value + ', ' + newline; 31 | } 32 | json = json.replace(/[\s\n]*$/g, ''); 33 | json = json.replace(/,$/, ''); 34 | if (object.length > 0) { 35 | json += newline + prefix; 36 | } 37 | } else { 38 | json += ' ... '; 39 | } 40 | 41 | return json + ']'; 42 | } else if (object instanceof Date) { 43 | // 'object' is a Date. 44 | // Taken from http://www.json.org/json2.js 45 | function f (n) { 46 | // Format integers to have at least two digits. 47 | return n < 10 ? '0' + n : n; 48 | } 49 | 50 | return '"' + 51 | object.getUTCFullYear() + '-' + 52 | f(object.getUTCMonth() + 1) + '-' + 53 | f(object.getUTCDate()) + ' ' + 54 | f(object.getUTCHours()) + ':' + 55 | f(object.getUTCMinutes()) + ':' + 56 | f(object.getUTCSeconds()) + 57 | '"'; 58 | } else { 59 | json = '{'; 60 | 61 | if (!done) { 62 | json = json + newline; 63 | count = 0; 64 | value = null; 65 | for (var key in object) { 66 | count++; 67 | if (object[key] == global) { 68 | value = "[global]"; 69 | } else { 70 | value = toJSON(object[key], pretty, levels, level+1); 71 | } 72 | json += prefix + singleprefix + '"' + key + '": ' + value; 73 | json += ', ' + newline; 74 | } 75 | json = json.replace(/[\s\n]*$/g, ''); 76 | json = json.replace(/,$/, ''); 77 | if (count > 0) { 78 | json += newline + prefix; 79 | } 80 | } else { 81 | json += ' ... '; 82 | } 83 | 84 | return json + '}'; 85 | } 86 | case 'function': 87 | var match = object.toString().match(/[^\(]+\([^\)]*\)/); 88 | return (match ? match[0] : 'function ()') + ' { ... }'; 89 | case 'string': 90 | return '"' + object.replace(/"/g, '\\"') + '"'; 91 | case 'number': 92 | return object; 93 | case 'boolean': 94 | default: 95 | return object.toString(); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/frame/Chain.js: -------------------------------------------------------------------------------- 1 | /**@constructor*/ 2 | function ChainNode(object, link) { 3 | this.value = object; 4 | this.link = link; // describes this node's relationship to the previous node 5 | } 6 | 7 | /**@constructor*/ 8 | function Chain(valueLinks) { 9 | this.nodes = []; 10 | this.cursor = -1; 11 | 12 | if (valueLinks && valueLinks.length > 0) { 13 | this.push(valueLinks[0], "//"); 14 | for (var i = 1, l = valueLinks.length; i < l; i+=2) { 15 | this.push(valueLinks[i+1], valueLinks[i]); 16 | } 17 | } 18 | } 19 | 20 | Chain.prototype.push = function(o, link) { 21 | if (this.nodes.length > 0 && link) this.nodes.push(new ChainNode(o, link)); 22 | else this.nodes.push(new ChainNode(o)); 23 | } 24 | 25 | Chain.prototype.unshift = function(o, link) { 26 | if (this.nodes.length > 0 && link) this.nodes[0].link = link; 27 | this.nodes.unshift(new ChainNode(o)); 28 | this.cursor++; 29 | } 30 | 31 | Chain.prototype.get = function() { 32 | if (this.cursor < 0 || this.cursor > this.nodes.length-1) return null; 33 | return this.nodes[this.cursor]; 34 | } 35 | 36 | Chain.prototype.first = function() { 37 | this.cursor = 0; 38 | return this.get(); 39 | } 40 | 41 | Chain.prototype.last = function() { 42 | this.cursor = this.nodes.length-1; 43 | return this.get(); 44 | } 45 | 46 | Chain.prototype.next = function() { 47 | this.cursor++; 48 | return this.get(); 49 | } 50 | 51 | Chain.prototype.prev = function() { 52 | this.cursor--; 53 | return this.get(); 54 | } 55 | 56 | Chain.prototype.toString = function() { 57 | var string = ""; 58 | for (var i = 0, l = this.nodes.length; i < l; i++) { 59 | if (this.nodes[i].link) string += " -("+this.nodes[i].link+")-> "; 60 | string += this.nodes[i].value.toString(); 61 | } 62 | return string; 63 | } 64 | 65 | Chain.prototype.joinLeft = function() { 66 | var result = ""; 67 | for (var i = 0, l = this.cursor; i < l; i++) { 68 | if (result && this.nodes[i].link) result += this.nodes[i].link; 69 | result += this.nodes[i].value.toString(); 70 | } 71 | return result; 72 | } 73 | 74 | 75 | /* USAGE: 76 | 77 | var path = "one/two/three.four/five-six"; 78 | var pathChain = new Chain(path.split(/([\/.-])/)); 79 | print(pathChain); 80 | 81 | var lineage = new Chain(); 82 | lineage.push("Port"); 83 | lineage.push("Les", "son"); 84 | lineage.push("Dawn", "daughter"); 85 | lineage.unshift("Purdie", "son"); 86 | 87 | print(lineage); 88 | 89 | // walk left 90 | for (var node = lineage.last(); node !== null; node = lineage.prev()) { 91 | print("< "+node.value); 92 | } 93 | 94 | // walk right 95 | var node = lineage.first() 96 | while (node !== null) { 97 | print(node.value); 98 | node = lineage.next(); 99 | if (node && node.link) print("had a "+node.link+" named"); 100 | } 101 | 102 | */ -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | js-lisp Documentation - Index 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 |
15 | 39 | 40 |
41 | 42 | Generated by JsDoc Toolkit 2.3.2 on Tue Jul 13 2010 12:33:47 GMT-0700 (PDT)
43 | HTML template: Codeview 44 |
45 |
46 | 47 |
48 |
49 |

Class Index

50 | 51 | 89 |
90 |
91 | 92 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/templates/jsdoc/static/default.css: -------------------------------------------------------------------------------- 1 | /* default.css */ 2 | body 3 | { 4 | font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif; 5 | width: 800px; 6 | } 7 | 8 | .header 9 | { 10 | clear: both; 11 | background-color: #ccc; 12 | padding: 8px; 13 | } 14 | 15 | h1 16 | { 17 | font-size: 150%; 18 | font-weight: bold; 19 | padding: 0; 20 | margin: 1em 0 0 .3em; 21 | } 22 | 23 | hr 24 | { 25 | border: none 0; 26 | border-top: 1px solid #7F8FB1; 27 | height: 1px; 28 | } 29 | 30 | pre.code 31 | { 32 | display: block; 33 | padding: 8px; 34 | border: 1px dashed #ccc; 35 | } 36 | 37 | #index 38 | { 39 | margin-top: 24px; 40 | float: left; 41 | width: 160px; 42 | position: absolute; 43 | left: 8px; 44 | background-color: #F3F3F3; 45 | padding: 8px; 46 | } 47 | 48 | #content 49 | { 50 | margin-left: 190px; 51 | width: 600px; 52 | } 53 | 54 | .classList 55 | { 56 | list-style-type: none; 57 | padding: 0; 58 | margin: 0 0 0 8px; 59 | font-family: arial, sans-serif; 60 | font-size: 1em; 61 | overflow: auto; 62 | } 63 | 64 | .classList li 65 | { 66 | padding: 0; 67 | margin: 0 0 8px 0; 68 | } 69 | 70 | .summaryTable { width: 100%; } 71 | 72 | h1.classTitle 73 | { 74 | font-size:170%; 75 | line-height:130%; 76 | } 77 | 78 | h2 { font-size: 110%; } 79 | caption, div.sectionTitle 80 | { 81 | background-color: #7F8FB1; 82 | color: #fff; 83 | font-size:130%; 84 | text-align: left; 85 | padding: 2px 6px 2px 6px; 86 | border: 1px #7F8FB1 solid; 87 | } 88 | 89 | div.sectionTitle { margin-bottom: 8px; } 90 | .summaryTable thead { display: none; } 91 | 92 | .summaryTable td 93 | { 94 | vertical-align: top; 95 | padding: 4px; 96 | border-bottom: 1px #7F8FB1 solid; 97 | border-right: 1px #7F8FB1 solid; 98 | } 99 | 100 | /*col#summaryAttributes {}*/ 101 | .summaryTable td.attributes 102 | { 103 | border-left: 1px #7F8FB1 solid; 104 | width: 140px; 105 | text-align: right; 106 | } 107 | 108 | td.attributes, .fixedFont 109 | { 110 | line-height: 15px; 111 | color: #002EBE; 112 | font-family: "Courier New",Courier,monospace; 113 | font-size: 13px; 114 | } 115 | 116 | .summaryTable td.nameDescription 117 | { 118 | text-align: left; 119 | font-size: 13px; 120 | line-height: 15px; 121 | } 122 | 123 | .summaryTable td.nameDescription, .description 124 | { 125 | line-height: 15px; 126 | padding: 4px; 127 | padding-left: 4px; 128 | } 129 | 130 | .summaryTable { margin-bottom: 8px; } 131 | 132 | ul.inheritsList 133 | { 134 | list-style: square; 135 | margin-left: 20px; 136 | padding-left: 0; 137 | } 138 | 139 | .detailList { 140 | margin-left: 20px; 141 | line-height: 15px; 142 | } 143 | .detailList dt { margin-left: 20px; } 144 | 145 | .detailList .heading 146 | { 147 | font-weight: bold; 148 | padding-bottom: 6px; 149 | margin-left: 0; 150 | } 151 | 152 | .light, td.attributes, .light a:link, .light a:visited 153 | { 154 | color: #777; 155 | font-style: italic; 156 | } 157 | 158 | .fineprint 159 | { 160 | text-align: right; 161 | font-size: 10px; 162 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js: -------------------------------------------------------------------------------- 1 | if (typeof JSDOC == "undefined") JSDOC = {}; 2 | 3 | /** 4 | @constructor 5 | */ 6 | JSDOC.TokenStream = function(tokens) { 7 | this.tokens = (tokens || []); 8 | this.rewind(); 9 | } 10 | 11 | /** 12 | @constructor 13 | @private 14 | */ 15 | function VoidToken(/**String*/type) { 16 | this.toString = function() {return ""}; 17 | this.is = function(){return false;} 18 | } 19 | 20 | JSDOC.TokenStream.prototype.rewind = function() { 21 | this.cursor = -1; 22 | } 23 | 24 | /** 25 | @type JSDOC.Token 26 | */ 27 | JSDOC.TokenStream.prototype.look = function(/**Number*/n, /**Boolean*/considerWhitespace) { 28 | if (typeof n == "undefined") n = 0; 29 | 30 | if (considerWhitespace == true) { 31 | if (this.cursor+n < 0 || this.cursor+n > this.tokens.length) return {}; 32 | return this.tokens[this.cursor+n]; 33 | } 34 | else { 35 | var count = 0; 36 | var i = this.cursor; 37 | 38 | while (true) { 39 | if (i < 0) return new JSDOC.Token("", "VOID", "START_OF_STREAM"); 40 | else if (i > this.tokens.length) return new JSDOC.Token("", "VOID", "END_OF_STREAM"); 41 | 42 | if (i != this.cursor && (this.tokens[i] === undefined || this.tokens[i].is("WHIT"))) { 43 | if (n < 0) i--; else i++; 44 | continue; 45 | } 46 | 47 | if (count == Math.abs(n)) { 48 | return this.tokens[i]; 49 | } 50 | count++; 51 | (n < 0)? i-- : i++; 52 | } 53 | 54 | return new JSDOC.Token("", "VOID", "STREAM_ERROR"); // because null isn't an object and caller always expects an object 55 | } 56 | } 57 | 58 | /** 59 | @type JSDOC.Token|JSDOC.Token[] 60 | */ 61 | JSDOC.TokenStream.prototype.next = function(/**Number*/howMany) { 62 | if (typeof howMany == "undefined") howMany = 1; 63 | if (howMany < 1) return null; 64 | var got = []; 65 | 66 | for (var i = 1; i <= howMany; i++) { 67 | if (this.cursor+i >= this.tokens.length) { 68 | return null; 69 | } 70 | got.push(this.tokens[this.cursor+i]); 71 | } 72 | this.cursor += howMany; 73 | 74 | if (howMany == 1) { 75 | return got[0]; 76 | } 77 | else return got; 78 | } 79 | 80 | /** 81 | @type JSDOC.Token[] 82 | */ 83 | JSDOC.TokenStream.prototype.balance = function(/**String*/start, /**String*/stop) { 84 | if (!stop) stop = JSDOC.Lang.matching(start); 85 | 86 | var depth = 0; 87 | var got = []; 88 | var started = false; 89 | 90 | while ((token = this.look())) { 91 | if (token.is(start)) { 92 | depth++; 93 | started = true; 94 | } 95 | 96 | if (started) { 97 | got.push(token); 98 | } 99 | 100 | if (token.is(stop)) { 101 | depth--; 102 | if (depth == 0) return got; 103 | } 104 | if (!this.next()) break; 105 | } 106 | } 107 | 108 | JSDOC.TokenStream.prototype.getMatchingToken = function(/**String*/start, /**String*/stop) { 109 | var depth = 0; 110 | var cursor = this.cursor; 111 | 112 | if (!start) { 113 | start = JSDOC.Lang.matching(stop); 114 | depth = 1; 115 | } 116 | if (!stop) stop = JSDOC.Lang.matching(start); 117 | 118 | while ((token = this.tokens[cursor])) { 119 | if (token.is(start)) { 120 | depth++; 121 | } 122 | 123 | if (token.is(stop) && cursor) { 124 | depth--; 125 | if (depth == 0) return this.tokens[cursor]; 126 | } 127 | cursor++; 128 | } 129 | } 130 | 131 | JSDOC.TokenStream.prototype.insertAhead = function(/**JSDOC.Token*/token) { 132 | this.tokens.splice(this.cursor+1, 0, token); 133 | } -------------------------------------------------------------------------------- /src/javascript/lisp/utils.js: -------------------------------------------------------------------------------- 1 | function _S (name) { 2 | return new Symbol(name); 3 | } 4 | 5 | function _K (name) { 6 | return new Keyword(name); 7 | } 8 | 9 | function defun (name, func) { 10 | var env = (lisp && lisp.env) || ROOT_ENV; 11 | env.set(name, func); 12 | } 13 | 14 | function defmacro (name, func) { 15 | var env = (lisp && lisp.env) || ROOT_ENV; 16 | env.set(name, new Macro(func)); 17 | } 18 | 19 | function isCallable (object) { 20 | return typeof(object) === "function" || 21 | (object instanceof Macro); 22 | } 23 | 24 | function resolve (value) { 25 | if (value instanceof Symbol) { 26 | return lisp.env.get(value); 27 | } else if (value instanceof Array) { 28 | return doSExp(value); 29 | } else { 30 | return value; 31 | } 32 | } 33 | 34 | /** 35 | * Recursively resolves all (resolve) expressions. 36 | */ 37 | function checkResolve (expression) { 38 | if (expression instanceof Array) { 39 | if ((expression.length > 0) && 40 | (equal(expression[0], _S("resolve")))) { 41 | return resolve(expression); 42 | } 43 | for (var i = 0; i < expression.length; i++) { 44 | expression[i] = checkResolve(expression[i]); 45 | } 46 | } 47 | return expression; 48 | } 49 | 50 | function checkExplode (expression, parent, index) { 51 | if (expression instanceof Array) { 52 | if ((expression.length > 0) && 53 | (equal(expression[0], _S("explode"))) && 54 | parent) { 55 | var list = resolve(expression[1]); 56 | if (!(list instanceof Array)) { 57 | list = [list]; // Be lenient if someone is trying to "explode" a non-list 58 | } 59 | // Insert the expressions elements into the parent 60 | var end = parent.slice(index+1); 61 | parent.splice(index, 1); // Remove the (explode) expression 62 | parent.splice.apply(parent, [index, list.length].concat(list)); 63 | parent.splice.apply(parent, [parent.length, end.length].concat(end)); 64 | return index + list.length; 65 | } else { 66 | for (var i = 0; i < expression.length; i++) { 67 | i = checkExplode(expression[i], expression, i); 68 | } 69 | } 70 | } 71 | return parent ? index : expression; 72 | } 73 | 74 | function doSExp (sexp) { 75 | assert(!!sexp, "doSExp got empty expression"); 76 | 77 | if (sexp.length === 0) { 78 | // An expression with no arguments, in js-lisp, is an empty list. 79 | return []; 80 | } 81 | 82 | var first = sexp[0]; 83 | var object = resolve(first); 84 | 85 | assert(isCallable(object), "'" + first.value + "' is not callable"); 86 | 87 | var thisObject = null; 88 | if (first instanceof Symbol) { 89 | var thisObjectPath = first.value.split(".").slice(0,-1).join("."); 90 | thisObject = lisp.env.get(thisObjectPath); 91 | } 92 | var args = sexp.slice(1); 93 | 94 | if (object instanceof lisp.Macro) { 95 | return object.callable.apply(thisObject, args); 96 | } else { 97 | return object.apply(thisObject, args.map(resolve)); 98 | } 99 | } 100 | 101 | function predicate (args, testFunc) { 102 | if (args.length === 0) { 103 | return false; 104 | } 105 | for (var i = 0; i < args.length; i++) { 106 | if (!testFunc(resolve(args[i]))) { 107 | return false; 108 | } 109 | } 110 | return true; 111 | } 112 | 113 | function comparator (args, testFunc) { 114 | if (args.length < 2) { 115 | return false; 116 | } 117 | var a = resolve(args[0]); 118 | for (var i = 1; i < args.length; i++) { 119 | var b = resolve(args[i]); 120 | if (!testFunc(a, b)) { 121 | return false; 122 | } 123 | a = b; 124 | } 125 | return true; 126 | } 127 | -------------------------------------------------------------------------------- /src/javascript/utils/utils.js: -------------------------------------------------------------------------------- 1 | var ArgumentError = Class.extend({ 2 | init: function (message) { 3 | this.message = message; 4 | }, 5 | toString: function () { 6 | return "ArgumentError: " + this.message; 7 | } 8 | }); 9 | 10 | function assert (assertion, errorString) { 11 | if (!assertion) { 12 | throw new Error(errorString || ""); 13 | } 14 | } 15 | 16 | function withNewEnv (callable) { 17 | var tempEnv = lisp.env; 18 | lisp.env = new Env(lisp.env); 19 | var ret = callable(); 20 | lisp.env = tempEnv; 21 | return ret; 22 | } 23 | 24 | /** 25 | * The method used for (equal) equality in js-lisp. 26 | * 27 | * @returns Whether a and b are equal from js-lisp's perspective. 28 | */ 29 | function equal (a, b) { 30 | // Test Symbol equality 31 | if (a instanceof Symbol) { 32 | if (!(b instanceof Symbol)) { 33 | return false; 34 | } 35 | return a.value == b.value; 36 | } 37 | 38 | // Test Keyword equality 39 | if (a instanceof Keyword) { 40 | if (!(b instanceof Keyword)) { 41 | return false; 42 | } 43 | return a.value == b.value; 44 | } 45 | 46 | // Test Array (list) equality 47 | if (a instanceof Array) { 48 | if (!(b instanceof Array)) { 49 | return false; 50 | } 51 | if (a.length !== b.length) { 52 | return false; // Return early in this easy and fast test 53 | } 54 | for (var i = 0; i < a.length; i++) { 55 | if (!equal(a[i], b[i])) { 56 | return false; 57 | } 58 | } 59 | return true; 60 | } 61 | 62 | return a == b; 63 | } 64 | 65 | function argsToArray (args) { 66 | var a = []; 67 | for (var i = 0; i < args.length; i++) { 68 | a.push(args[i]); 69 | } 70 | return a; 71 | } 72 | 73 | function deepCopyArray (array) { 74 | var newArray = []; 75 | var item; 76 | for (var i = 0; i < array.length; i++) { 77 | item = array[i]; 78 | if (item instanceof Array) { 79 | item = deepCopyArray(item); 80 | } 81 | newArray.push(item); 82 | } 83 | return newArray; 84 | } 85 | 86 | function makeRequest (url, successCallback) { 87 | var request; 88 | 89 | if (window.XMLHttpRequest) { 90 | request = new XMLHttpRequest(); 91 | } else if (window.ActiveXObject) { 92 | request = new ActiveXObject("Msxml2.XMLHTTP"); 93 | } else { 94 | throw new Error("Ajax request not supported in this browser"); 95 | } 96 | 97 | request.open("GET", url, false); // Load the script synchronously 98 | request.send(null); 99 | 100 | if (request.status == 200) { 101 | successCallback(request.responseText); 102 | } 103 | 104 | assert(request.status != 404, "Trying to load lisp script that " + 105 | "does not exist: " + url); 106 | } 107 | 108 | function times (string, num) { 109 | var ret = ''; 110 | for (var i = 0; i < num; i++) { 111 | ret += string; 112 | } 113 | return ret; 114 | } 115 | 116 | // From: http://note19.com/2007/05/27/javascript-guid-generator/ 117 | // This is for gensym(). 118 | // I know these aren't real guids, and i'm sure in a million years 119 | // someone might actually be unlucky enough to witness a conflict 120 | // with gensym(), but this seems safe enough for the time being. 121 | function S4() { 122 | return (((1+Math.random())*0x10000)|0).toString(16).substring(1); 123 | } 124 | function guid() { 125 | return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); 126 | } 127 | 128 | // Used primarly for auto-generated code, so you don't end up pummeling 129 | // any vars in the current scope. 130 | function gensym () { 131 | return _S(guid().replace(/\-/g,'#')); // Be extra random :) 132 | } 133 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/frame/Opt.js: -------------------------------------------------------------------------------- 1 | /** @namespace */ 2 | Opt = { 3 | /** 4 | * Get commandline option values. 5 | * @param {Array} args Commandline arguments. Like ["-a=xml", "-b", "--class=new", "--debug"] 6 | * @param {object} optNames Map short names to long names. Like {a:"accept", b:"backtrace", c:"class", d:"debug"}. 7 | * @return {object} Short names and values. Like {a:"xml", b:true, c:"new", d:true} 8 | */ 9 | get: function(args, optNames) { 10 | var opt = {"_": []}; // the unnamed option allows multiple values 11 | for (var i = 0; i < args.length; i++) { 12 | var arg = new String(args[i]); 13 | var name; 14 | var value; 15 | if (arg.charAt(0) == "-") { 16 | if (arg.charAt(1) == "-") { // it's a longname like --foo 17 | arg = arg.substring(2); 18 | var m = arg.split("="); 19 | name = m.shift(); 20 | value = m.shift(); 21 | if (typeof value == "undefined") value = true; 22 | 23 | for (var n in optNames) { // convert it to a shortname 24 | if (name == optNames[n]) { 25 | name = n; 26 | } 27 | } 28 | } 29 | else { // it's a shortname like -f 30 | arg = arg.substring(1); 31 | var m = arg.split("="); 32 | name = m.shift(); 33 | value = m.shift(); 34 | if (typeof value == "undefined") value = true; 35 | 36 | for (var n in optNames) { // find the matching key 37 | if (name == n || name+'[]' == n) { 38 | name = n; 39 | break; 40 | } 41 | } 42 | } 43 | if (name.match(/(.+)\[\]$/)) { // it's an array type like n[] 44 | name = RegExp.$1; 45 | if (!opt[name]) opt[name] = []; 46 | } 47 | 48 | if (opt[name] && opt[name].push) { 49 | opt[name].push(value); 50 | } 51 | else { 52 | opt[name] = value; 53 | } 54 | } 55 | else { // not associated with any optname 56 | opt._.push(args[i]); 57 | } 58 | } 59 | return opt; 60 | } 61 | } 62 | 63 | /*t: 64 | plan(11, "Testing Opt."); 65 | 66 | is( 67 | typeof Opt, 68 | "object", 69 | "Opt is an object." 70 | ); 71 | 72 | is( 73 | typeof Opt.get, 74 | "function", 75 | "Opt.get is a function." 76 | ); 77 | 78 | var optNames = {a:"accept", b:"backtrace", c:"class", d:"debug", "e[]":"exceptions"}; 79 | var t_options = Opt.get(["-a=xml", "-b", "--class=new", "--debug", "-e=one", "-e=two", "foo", "bar"], optNames); 80 | 81 | is( 82 | t_options.a, 83 | "xml", 84 | "an option defined with a short name can be accessed by its short name." 85 | ); 86 | 87 | is( 88 | t_options.b, 89 | true, 90 | "an option defined with a short name and no value are true." 91 | ); 92 | 93 | is( 94 | t_options.c, 95 | "new", 96 | "an option defined with a long name can be accessed by its short name." 97 | ); 98 | 99 | is( 100 | t_options.d, 101 | true, 102 | "an option defined with a long name and no value are true." 103 | ); 104 | 105 | is( 106 | typeof t_options.e, 107 | "object", 108 | "an option that can accept multiple values is defined." 109 | ); 110 | 111 | is( 112 | t_options.e.length, 113 | 2, 114 | "an option that can accept multiple values can have more than one value." 115 | ); 116 | 117 | is( 118 | t_options.e[1], 119 | "two", 120 | "an option that can accept multiple values can be accessed as an array." 121 | ); 122 | 123 | is( 124 | typeof t_options._, 125 | "object", 126 | "the property '_' is defined for unnamed options." 127 | ); 128 | 129 | is( 130 | t_options._[0], 131 | "foo", 132 | "the property '_' can be accessed as an array." 133 | ); 134 | */ -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/main.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @version $Id: main.js 795 2009-06-19 07:03:22Z micmath $ 3 | */ 4 | 5 | function main() { 6 | IO.include("lib/JSDOC.js"); 7 | IO.includeDir("plugins/"); 8 | 9 | // process the options 10 | 11 | // the -c option: options are defined in a configuration file 12 | if (JSDOC.opt.c) { 13 | eval("JSDOC.conf = " + IO.readFile(JSDOC.opt.c)); 14 | 15 | LOG.inform("Using configuration file at '"+JSDOC.opt.c+"'."); 16 | 17 | for (var c in JSDOC.conf) { 18 | if (c !== "D" && !defined(JSDOC.opt[c])) { // commandline overrules config file 19 | JSDOC.opt[c] = JSDOC.conf[c]; 20 | } 21 | } 22 | 23 | if (typeof JSDOC.conf["_"] != "undefined") { 24 | JSDOC.opt["_"] = JSDOC.opt["_"].concat(JSDOC.conf["_"]); 25 | } 26 | 27 | LOG.inform("With configuration: "); 28 | for (var o in JSDOC.opt) { 29 | LOG.inform(" "+o+": "+JSDOC.opt[o]); 30 | } 31 | } 32 | 33 | // be verbose 34 | if (JSDOC.opt.v) LOG.verbose = true; 35 | 36 | // send log messages to a file 37 | if (JSDOC.opt.o) LOG.out = IO.open(JSDOC.opt.o); 38 | 39 | // run the unit tests 40 | if (JSDOC.opt.T) { 41 | LOG.inform("JsDoc Toolkit running in test mode at "+new Date()+"."); 42 | IO.include("frame/Testrun.js"); 43 | IO.include("test.js"); 44 | } 45 | else { 46 | // a template must be defined and must be a directory path 47 | if (!JSDOC.opt.t && System.getProperty("jsdoc.template.dir")) { 48 | JSDOC.opt.t = System.getProperty("jsdoc.template.dir"); 49 | } 50 | if (JSDOC.opt.t && !JSDOC.opt.t.charAt(JSDOC.opt.t.length-1).match(/[\\\/]/)) { 51 | JSDOC.opt.t += SYS.slash; 52 | } 53 | 54 | // verbose messages about the options we were given 55 | LOG.inform("JsDoc Toolkit main() running at "+new Date()+"."); 56 | LOG.inform("With options: "); 57 | for (var o in JSDOC.opt) { 58 | LOG.inform(" "+o+": "+JSDOC.opt[o]); 59 | } 60 | 61 | // initialize and build a symbolSet from your code 62 | JSDOC.JsDoc(); 63 | 64 | // debugger's option: dump the entire symbolSet produced from your code 65 | if (JSDOC.opt.Z) { 66 | LOG.warn("So you want to see the data structure, eh? This might hang if you have circular refs..."); 67 | IO.include("frame/Dumper.js"); 68 | var symbols = JSDOC.JsDoc.symbolSet.toArray(); 69 | for (var i = 0, l = symbols.length; i < l; i++) { 70 | var symbol = symbols[i]; 71 | print("// symbol: " + symbol.alias); 72 | print(symbol.serialize()); 73 | } 74 | } 75 | else { 76 | if (typeof JSDOC.opt.t != "undefined") { 77 | try { 78 | // a file named "publish.js" must exist in the template directory 79 | load(JSDOC.opt.t+"publish.js"); 80 | 81 | // and must define a function named "publish" 82 | if (!publish) { 83 | LOG.warn("No publish() function is defined in that template so nothing to do."); 84 | } 85 | else { 86 | // which will be called with the symbolSet produced from your code 87 | publish(JSDOC.JsDoc.symbolSet); 88 | } 89 | } 90 | catch(e) { 91 | LOG.warn("Sorry, that doesn't seem to be a valid template: "+JSDOC.opt.t+"publish.js : "+e); 92 | } 93 | } 94 | else { 95 | LOG.warn("No template given. Might as well read the usage notes."); 96 | JSDOC.usage(); 97 | } 98 | } 99 | } 100 | 101 | // notify of any warnings 102 | if (!JSDOC.opt.q && LOG.warnings.length) { 103 | print(LOG.warnings.length+" warning"+(LOG.warnings.length != 1? "s":"")+"."); 104 | } 105 | 106 | // stop sending log messages to a file 107 | if (LOG.out) { 108 | LOG.out.flush(); 109 | LOG.out.close(); 110 | } 111 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/lib/JSDOC.js: -------------------------------------------------------------------------------- 1 | /** 2 | @overview 3 | @date $Date: 2009-09-04 07:43:41 +0100 (Fri, 04 Sep 2009) $ 4 | @version $Revision: 814 $ 5 | @location $HeadURL: https://jsdoc-toolkit.googlecode.com/svn/tags/jsdoc_toolkit-2.3.2/jsdoc-toolkit/app/lib/JSDOC.js $ 6 | @name JSDOC.js 7 | */ 8 | 9 | /** 10 | This is the main container for the JSDOC application. 11 | @namespace 12 | */ 13 | JSDOC = { 14 | }; 15 | 16 | /** 17 | @requires Opt 18 | */ 19 | if (typeof arguments == "undefined") arguments = []; 20 | JSDOC.opt = Opt.get( 21 | arguments, 22 | { 23 | a: "allfunctions", 24 | c: "conf", 25 | d: "directory", 26 | "D[]": "define", 27 | e: "encoding", 28 | "E[]": "exclude", 29 | h: "help", 30 | n: "nocode", 31 | o: "out", 32 | p: "private", 33 | q: "quiet", 34 | r: "recurse", 35 | S: "securemodules", 36 | s: "suppress", 37 | t: "template", 38 | T: "testmode", 39 | u: "unique", 40 | v: "verbose", 41 | x: "ext" 42 | } 43 | ); 44 | 45 | /** The current version string of this application. */ 46 | JSDOC.VERSION = "2.3.2"; 47 | 48 | /** Print out usage information and quit. */ 49 | JSDOC.usage = function() { 50 | print("USAGE: java -jar jsrun.jar app/run.js [OPTIONS] ..."); 51 | print(""); 52 | print("OPTIONS:"); 53 | print(" -a or --allfunctions\n Include all functions, even undocumented ones.\n"); 54 | print(" -c or --conf\n Load a configuration file.\n"); 55 | print(" -d= or --directory=\n Output to this directory (defaults to \"out\").\n"); 56 | print(" -D=\"myVar:My value\" or --define=\"myVar:My value\"\n Multiple. Define a variable, available in JsDoc as JSDOC.opt.D.myVar.\n"); 57 | print(" -e= or --encoding=\n Use this encoding to read and write files.\n"); 58 | print(" -E=\"REGEX\" or --exclude=\"REGEX\"\n Multiple. Exclude files based on the supplied regex.\n"); 59 | print(" -h or --help\n Show this message and exit.\n"); 60 | print(" -n or --nocode\n Ignore all code, only document comments with @name tags.\n"); 61 | print(" -o= or --out=\n Print log messages to a file (defaults to stdout).\n"); 62 | print(" -p or --private\n Include symbols tagged as private, underscored and inner symbols.\n"); 63 | print(" -q or --quiet\n Do not output any messages, not even warnings.\n"); 64 | print(" -r= or --recurse=\n Descend into src directories.\n"); 65 | print(" -s or --suppress\n Suppress source code output.\n"); 66 | print(" -S or --securemodules\n Use Secure Modules mode to parse source code.\n"); 67 | print(" -t= or --template=\n Required. Use this template to format the output.\n"); 68 | print(" -T or --test\n Run all unit tests and exit.\n"); 69 | print(" -u or --unique\n Force file names to be unique, but not based on symbol names.\n"); 70 | print(" -v or --verbose\n Provide verbose feedback about what is happening.\n"); 71 | print(" -x=[,EXT]... or --ext=[,EXT]...\n Scan source files with the given extension/s (defaults to js).\n"); 72 | 73 | quit(); 74 | } 75 | 76 | /*t: 77 | plan(4, "Testing JSDOC namespace."); 78 | 79 | is( 80 | typeof JSDOC, 81 | "object", 82 | "JSDOC.usage is a function." 83 | ); 84 | 85 | is( 86 | typeof JSDOC.VERSION, 87 | "string", 88 | "JSDOC.VERSION is a string." 89 | ); 90 | 91 | is( 92 | typeof JSDOC.usage, 93 | "function", 94 | "JSDOC.usage is a function." 95 | ); 96 | 97 | is( 98 | typeof JSDOC.opt, 99 | "object", 100 | "JSDOC.opt is a object." 101 | ); 102 | */ 103 | 104 | if (this.IO) IO.includeDir("lib/JSDOC/"); 105 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/lib/JSDOC/Lang.js: -------------------------------------------------------------------------------- 1 | /** 2 | @namespace 3 | */ 4 | JSDOC.Lang = { 5 | } 6 | 7 | JSDOC.Lang.isBuiltin = function(name) { 8 | return (JSDOC.Lang.isBuiltin.coreObjects.indexOf(name) > -1); 9 | } 10 | JSDOC.Lang.isBuiltin.coreObjects = ['_global_', 'Array', 'Boolean', 'Date', 'Error', 'Function', 'Math', 'Number', 'Object', 'RegExp', 'String']; 11 | 12 | JSDOC.Lang.whitespace = function(ch) { 13 | return JSDOC.Lang.whitespace.names[ch]; 14 | } 15 | JSDOC.Lang.whitespace.names = { 16 | " ": "SPACE", 17 | "\f": "FORMFEED", 18 | "\t": "TAB", 19 | "\u0009": "UNICODE_TAB", 20 | "\u000A": "UNICODE_NBR", 21 | "\u0008": "VERTICAL_TAB" 22 | }; 23 | 24 | JSDOC.Lang.newline = function(ch) { 25 | return JSDOC.Lang.newline.names[ch]; 26 | } 27 | JSDOC.Lang.newline.names = { 28 | "\n": "NEWLINE", 29 | "\r": "RETURN", 30 | "\u000A": "UNICODE_LF", 31 | "\u000D": "UNICODE_CR", 32 | "\u2029": "UNICODE_PS", 33 | "\u2028": "UNICODE_LS" 34 | }; 35 | 36 | JSDOC.Lang.keyword = function(word) { 37 | return JSDOC.Lang.keyword.names["="+word]; 38 | } 39 | JSDOC.Lang.keyword.names = { 40 | "=break": "BREAK", 41 | "=case": "CASE", 42 | "=catch": "CATCH", 43 | "=const": "VAR", 44 | "=continue": "CONTINUE", 45 | "=default": "DEFAULT", 46 | "=delete": "DELETE", 47 | "=do": "DO", 48 | "=else": "ELSE", 49 | "=false": "FALSE", 50 | "=finally": "FINALLY", 51 | "=for": "FOR", 52 | "=function": "FUNCTION", 53 | "=if": "IF", 54 | "=in": "IN", 55 | "=instanceof": "INSTANCEOF", 56 | "=new": "NEW", 57 | "=null": "NULL", 58 | "=return": "RETURN", 59 | "=switch": "SWITCH", 60 | "=this": "THIS", 61 | "=throw": "THROW", 62 | "=true": "TRUE", 63 | "=try": "TRY", 64 | "=typeof": "TYPEOF", 65 | "=void": "VOID", 66 | "=while": "WHILE", 67 | "=with": "WITH", 68 | "=var": "VAR" 69 | }; 70 | 71 | JSDOC.Lang.punc = function(ch) { 72 | return JSDOC.Lang.punc.names[ch]; 73 | } 74 | JSDOC.Lang.punc.names = { 75 | ";": "SEMICOLON", 76 | ",": "COMMA", 77 | "?": "HOOK", 78 | ":": "COLON", 79 | "||": "OR", 80 | "&&": "AND", 81 | "|": "BITWISE_OR", 82 | "^": "BITWISE_XOR", 83 | "&": "BITWISE_AND", 84 | "===": "STRICT_EQ", 85 | "==": "EQ", 86 | "=": "ASSIGN", 87 | "!==": "STRICT_NE", 88 | "!=": "NE", 89 | "<<": "LSH", 90 | "<=": "LE", 91 | "<": "LT", 92 | ">>>": "URSH", 93 | ">>": "RSH", 94 | ">=": "GE", 95 | ">": "GT", 96 | "++": "INCREMENT", 97 | "--": "DECREMENT", 98 | "+": "PLUS", 99 | "-": "MINUS", 100 | "*": "MUL", 101 | "/": "DIV", 102 | "%": "MOD", 103 | "!": "NOT", 104 | "~": "BITWISE_NOT", 105 | ".": "DOT", 106 | "[": "LEFT_BRACKET", 107 | "]": "RIGHT_BRACKET", 108 | "{": "LEFT_CURLY", 109 | "}": "RIGHT_CURLY", 110 | "(": "LEFT_PAREN", 111 | ")": "RIGHT_PAREN" 112 | }; 113 | 114 | JSDOC.Lang.matching = function(name) { 115 | return JSDOC.Lang.matching.names[name]; 116 | } 117 | JSDOC.Lang.matching.names = { 118 | "LEFT_PAREN": "RIGHT_PAREN", 119 | "RIGHT_PAREN": "LEFT_PAREN", 120 | "LEFT_CURLY": "RIGHT_CURLY", 121 | "RIGHT_CURLY": "LEFT_CURLY", 122 | "LEFT_BRACE": "RIGHT_BRACE", 123 | "RIGHT_BRACE": "LEFT_BRACE" 124 | } 125 | 126 | JSDOC.Lang.isNumber = function(str) { 127 | return /^(\.[0-9]|[0-9]+\.|[0-9])[0-9]*([eE][+-][0-9]+)?$/i.test(str); 128 | } 129 | 130 | JSDOC.Lang.isHexDec = function(str) { 131 | return /^0x[0-9A-F]+$/i.test(str); 132 | } 133 | 134 | JSDOC.Lang.isWordChar = function(str) { 135 | return /^[a-zA-Z0-9$_.]+$/.test(str); 136 | } 137 | 138 | JSDOC.Lang.isSpace = function(str) { 139 | return (typeof JSDOC.Lang.whitespace(str) != "undefined"); 140 | } 141 | 142 | JSDOC.Lang.isNewline = function(str) { 143 | return (typeof JSDOC.Lang.newline(str) != "undefined"); 144 | } -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "yaml" 2 | 3 | LISP_JS = "lisp" 4 | LISP_JS_MIN = "lisp.min" 5 | 6 | DOCS_ROOT = "docs" 7 | 8 | BUILD_CONFIG = "build.yaml" 9 | BUILD_DIRECTORY = "build" 10 | 11 | JSL_BINARY = "support/bin/jsl" 12 | JSL_CONFIG = "support/jsl.conf" 13 | 14 | JSDOC_ROOT = "support/bin/jsdoc-toolkit" 15 | 16 | task :default => :buildall 17 | 18 | task :watch do 19 | sh "python support/bin/watch.py" 20 | end 21 | 22 | # Build the javascript lisp library and core lisp library 23 | task :buildall => [:build, :minify] 24 | 25 | task :build do 26 | puts "+ Building project" 27 | File.open(BUILD_CONFIG) do |out| 28 | config = YAML::load(out) 29 | config.each do |outfilename, list| 30 | outfilename = File.join(BUILD_DIRECTORY, outfilename) 31 | File.delete(outfilename) if File.exists?(outfilename) 32 | puts "Writing #{outfilename}" 33 | system("mkdir -p #{File.dirname(outfilename)}") 34 | File.open(outfilename, 'w') do |outfile| 35 | list.each do |filename| 36 | puts " - writing #{filename} to #{outfilename}" 37 | outfile << File.read(filename) + "\n" 38 | end 39 | end 40 | end 41 | end 42 | end 43 | 44 | task :minify do 45 | puts "+ Minifying #{LISP_JS}.js" 46 | minfile = "#{BUILD_DIRECTORY}/#{LISP_JS_MIN}.js" 47 | File.delete(minfile) if File.exists?(minfile) 48 | sh " 49 | ruby support/bin/jsmin.rb < #{BUILD_DIRECTORY}/#{LISP_JS}.js > #{minfile} 50 | " 51 | end 52 | 53 | task :doc do 54 | sh " 55 | rm -rf #{DOCS_ROOT}/css #{DOCS_ROOT}/symbols #{DOCS_ROOT}/*.html 56 | mkdir -p #{DOCS_ROOT} 57 | java -jar #{JSDOC_ROOT}/jsrun.jar #{JSDOC_ROOT}/app/run.js -a -d=#{DOCS_ROOT} \ 58 | -t=#{JSDOC_ROOT}/templates/codeview #{BUILD_DIRECTORY}/#{LISP_JS}.js 59 | " 60 | end 61 | 62 | task :webserver do 63 | sh " 64 | # Press Ctrl-C to shutdown the test server 65 | python -c 'import SimpleHTTPServer; SimpleHTTPServer.test()' 66 | " 67 | end 68 | 69 | task :test => [:build] do 70 | sh " 71 | open http://localhost:8000/tests/ 72 | " 73 | Rake::Task["webserver"].invoke 74 | end 75 | 76 | task :lint => [:build] do 77 | puts "+ Running jsl (javascript lint)" 78 | sh " 79 | #{JSL_BINARY} -conf #{JSL_CONFIG} -process #{BUILD_DIRECTORY}/#{LISP_JS}.js | less 80 | " 81 | end 82 | 83 | task :nodetest => [:build] do 84 | puts "+ Running tests with node.js" 85 | sh " 86 | cd tests 87 | node node-tests.js 88 | " 89 | end 90 | 91 | task :line, :filename, :num do |t, args| 92 | # Because the files that actually get run in the browser are compiled 93 | # files, put together from a bunch of smaller files, the line numbers 94 | # that are reported when errors occur, and by programs like js lint, are 95 | # not the line numbers actually needed to easily find the problems in 96 | # code. This task takes one of the files in the build.yaml file and a 97 | # line number, and returns the actual file/line that we want. 98 | File.open(BUILD_CONFIG) do |out| 99 | config = YAML::load(out) 100 | files = config[args.filename] 101 | if not files 102 | raise "No build file #{args.filename}" 103 | end 104 | line = args.num.to_i 105 | current_line = 0 106 | found = false 107 | files.each do |filename| 108 | content = File.read(filename) 109 | file_line_count = content.lines.count + 1 # For the extra newline placed after each file in :build 110 | current_line += file_line_count 111 | if current_line >= line 112 | actual_line = file_line_count - (current_line - line) 113 | found = true 114 | puts "File: #{filename}, line: #{actual_line}" 115 | sh "if which mate; then mate #{filename} -l #{actual_line}; fi" 116 | break 117 | end 118 | end 119 | if not found 120 | raise "File not found with line number #{line}" 121 | end 122 | end 123 | end 124 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | @param [opt] Used to override the commandline options. Useful for testing. 4 | @version $Id: JsDoc.js 773 2009-01-24 09:42:04Z micmath $ 5 | */ 6 | JSDOC.JsDoc = function(/**object*/ opt) { 7 | if (opt) { 8 | JSDOC.opt = opt; 9 | } 10 | 11 | if (JSDOC.opt.h) { 12 | JSDOC.usage(); 13 | quit(); 14 | } 15 | 16 | // defend against options that are not sane 17 | if (JSDOC.opt._.length == 0) { 18 | LOG.warn("No source files to work on. Nothing to do."); 19 | quit(); 20 | } 21 | if (JSDOC.opt.t === true || JSDOC.opt.d === true) { 22 | JSDOC.usage(); 23 | } 24 | 25 | if (typeof JSDOC.opt.d == "string") { 26 | if (!JSDOC.opt.d.charAt(JSDOC.opt.d.length-1).match(/[\\\/]/)) { 27 | JSDOC.opt.d = JSDOC.opt.d+"/"; 28 | } 29 | LOG.inform("Output directory set to '"+JSDOC.opt.d+"'."); 30 | IO.mkPath(JSDOC.opt.d); 31 | } 32 | if (JSDOC.opt.e) IO.setEncoding(JSDOC.opt.e); 33 | 34 | // the -r option: scan source directories recursively 35 | if (typeof JSDOC.opt.r == "boolean") JSDOC.opt.r = 10; 36 | else if (!isNaN(parseInt(JSDOC.opt.r))) JSDOC.opt.r = parseInt(JSDOC.opt.r); 37 | else JSDOC.opt.r = 1; 38 | 39 | // the -D option: define user variables 40 | var D = {}; 41 | if (JSDOC.opt.D) { 42 | for (var i = 0; i < JSDOC.opt.D.length; i++) { 43 | var defineParts = JSDOC.opt.D[i].split(":", 2); 44 | if (defineParts) D[defineParts[0]] = defineParts[1]; 45 | } 46 | } 47 | JSDOC.opt.D = D; 48 | // combine any conf file D options with the commandline D options 49 | if (defined(JSDOC.conf)) for (var c in JSDOC.conf.D) { 50 | if (!defined(JSDOC.opt.D[c])) { 51 | JSDOC.opt.D[c] = JSDOC.conf.D[c]; 52 | } 53 | } 54 | 55 | // Give plugins a chance to initialize 56 | if (defined(JSDOC.PluginManager)) { 57 | JSDOC.PluginManager.run("onInit", JSDOC.opt); 58 | } 59 | 60 | JSDOC.opt.srcFiles = JSDOC.JsDoc._getSrcFiles(); 61 | JSDOC.JsDoc._parseSrcFiles(); 62 | JSDOC.JsDoc.symbolSet = JSDOC.Parser.symbols; 63 | } 64 | 65 | /** 66 | Retrieve source file list. 67 | @returns {String[]} The pathnames of the files to be parsed. 68 | */ 69 | JSDOC.JsDoc._getSrcFiles = function() { 70 | JSDOC.JsDoc.srcFiles = []; 71 | 72 | var ext = ["js"]; 73 | if (JSDOC.opt.x) { 74 | ext = JSDOC.opt.x.split(",").map(function($) {return $.toLowerCase()}); 75 | } 76 | 77 | for (var i = 0; i < JSDOC.opt._.length; i++) { 78 | JSDOC.JsDoc.srcFiles = JSDOC.JsDoc.srcFiles.concat( 79 | IO.ls(JSDOC.opt._[i], JSDOC.opt.r).filter( 80 | function($) { 81 | var thisExt = $.split(".").pop().toLowerCase(); 82 | 83 | if (JSDOC.opt.E) { 84 | for(var n = 0; n < JSDOC.opt.E.length; n++) { 85 | if ($.match(new RegExp(JSDOC.opt.E[n]))) { 86 | LOG.inform("Excluding " + $); 87 | return false; // if the file matches the regex then it's excluded. 88 | } 89 | } 90 | } 91 | 92 | return (ext.indexOf(thisExt) > -1); // we're only interested in files with certain extensions 93 | } 94 | ) 95 | ); 96 | } 97 | 98 | return JSDOC.JsDoc.srcFiles; 99 | } 100 | 101 | JSDOC.JsDoc._parseSrcFiles = function() { 102 | JSDOC.Parser.init(); 103 | for (var i = 0, l = JSDOC.JsDoc.srcFiles.length; i < l; i++) { 104 | var srcFile = JSDOC.JsDoc.srcFiles[i]; 105 | 106 | if (JSDOC.opt.v) LOG.inform("Parsing file: " + srcFile); 107 | 108 | try { 109 | var src = IO.readFile(srcFile); 110 | } 111 | catch(e) { 112 | LOG.warn("Can't read source file '"+srcFile+"': "+e.message); 113 | } 114 | 115 | var tr = new JSDOC.TokenReader(); 116 | var ts = new JSDOC.TokenStream(tr.tokenize(new JSDOC.TextStream(src))); 117 | 118 | JSDOC.Parser.parse(ts, srcFile); 119 | 120 | } 121 | JSDOC.Parser.finish(); 122 | 123 | if (JSDOC.PluginManager) { 124 | JSDOC.PluginManager.run("onFinishedParsing", JSDOC.Parser.symbols); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /tests/tests.js: -------------------------------------------------------------------------------- 1 | // Set this library up to work with node.js 2 | if ((typeof(window) == "undefined") && 3 | (typeof(global) == "object") && global && // Make sure it isn't null 4 | (typeof(require) == "function") && 5 | (typeof(exports) == "object") && exports) { 6 | // We are probably running in node.js now. 7 | // FIXME: Find a better way to tell we're running in node.js 8 | var JSTest = require("../support/vendor/JSTest/src/jstest"), 9 | lisp = require("../build/lisp"); 10 | } else { 11 | var global = window; 12 | } 13 | 14 | JSTest.TestCase({ 15 | name: 'Parser', 16 | 17 | // string 18 | 19 | testParseString: function () { 20 | this.assertEqual(lisp.parse.string('"this is a string"'), "this is a string"); 21 | this.assertEqual(lisp.parse.string(' \t"this too "'), "this too "); 22 | this.assertEqual(lisp.parse.string(' \t\r " \nand this" \n\n '), " \nand this"); 23 | }, 24 | 25 | testParseStringBadInput: function () { 26 | this.assertRaises(lisp.parse.ParserException, lisp.parse.string, null, '(hello)'); 27 | this.assertRaises(lisp.parse.ParserException, lisp.parse.string, null, 'test'); 28 | this.assertRaises(lisp.parse.ParserException, lisp.parse.string, null, '123.45'); 29 | this.assertRaises(lisp.parse.ParserException, lisp.parse.string, null, null); 30 | this.assertRaises(lisp.parse.ParserException, lisp.parse.string, null); 31 | }, 32 | 33 | // number 34 | 35 | testParseNumber: function () { 36 | this.assertEqual(lisp.parse.number("345"), 345); 37 | this.assertEqual(lisp.parse.number("34.5"), 34.5); 38 | this.assertEqual(lisp.parse.number("-12"), -12); 39 | this.assertEqual(lisp.parse.number(" 3.45e2 "), 3.45e2); 40 | this.assertEqual(lisp.parse.number("0377\n\r"), 0377); 41 | this.assertEqual(lisp.parse.number("\t0xFF\n"), 0xFF); 42 | }, 43 | 44 | // symbol 45 | 46 | testParseSymbol: function () { 47 | this.assertEqual(lisp.parse.symbol("abcd").value, "abcd"); 48 | this.assertEqual(lisp.parse.symbol("document.getElementById").value, 49 | "document.getElementById"); 50 | this.assertEqual(lisp.parse.symbol(" space-before").value, "space-before"); 51 | this.assertEqual(lisp.parse.symbol("space-after \t\n ").value, "space-after"); 52 | }, 53 | 54 | // keyword 55 | 56 | testParseKeyword: function () { 57 | this.assertEqual(lisp.parse.keyword(":hello").value, "hello"); 58 | this.assertEqual(lisp.parse.keyword(":good-bye").value, "good-bye"); 59 | this.assertEqual(lisp.parse.keyword(" \t :sayonara \n").value, "sayonara"); 60 | }, 61 | 62 | // sexp 63 | 64 | testParseSexp: function () { 65 | this.assertEqual(lisp.parse.script('(print "hello!")')[0], ["print", "hello!"]); 66 | }, 67 | 68 | // any 69 | 70 | testParseAny: function () { 71 | this.assertEqual(lisp.parse.any('"hello"'), "hello"); 72 | }, 73 | }); 74 | 75 | JSTest.TestCase({ 76 | name: 'Environment (Env class)', 77 | 78 | setup: function () { 79 | this.env = new lisp.Env(new lisp.Env(null, global), {}); 80 | }, 81 | 82 | testBasicGet: function () { 83 | this.assertUndefined(this.env.get("bob")); 84 | }, 85 | 86 | testBasicSet: function () { 87 | this.env.set("aname", "Bill"); 88 | this.assertEqual(this.env.get("aname"), "Bill"); 89 | }, 90 | 91 | testGlobalGet: function () { 92 | this.assertTrue(this.env.get("global") == global); 93 | }, 94 | 95 | testHas: function () { 96 | this.assertFalse(this.env.has("bob")); 97 | this.assertTrue(this.env.has("global")); 98 | 99 | this.env.set("bob", false); 100 | this.assertTrue(this.env.has("bob")); 101 | }, 102 | 103 | testGetDotPath: function () { 104 | this.assertEqual(this.env.get("document.getElementById"), document.getElementById); 105 | this.assertEqual(this.env.get("global.Array.prototype"), global.Array.prototype); 106 | }, 107 | 108 | testSetDotPath: function () { 109 | this.assertNotEqual(global.firstName, "Bill"); 110 | this.env.set("global.firstName", "Bill"); 111 | this.assertEqual(firstName, "Bill"); 112 | } 113 | }); 114 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | */ 4 | JSDOC.JsPlate = function(templateFile) { 5 | if (templateFile) this.template = IO.readFile(templateFile); 6 | 7 | this.templateFile = templateFile; 8 | this.code = ""; 9 | this.parse(); 10 | } 11 | 12 | JSDOC.JsPlate.prototype.parse = function() { 13 | this.template = this.template.replace(/\{#[\s\S]+?#\}/gi, ""); 14 | this.code = "var output=\u001e"+this.template; 15 | 16 | this.code = this.code.replace( 17 | //gi, 18 | function (match, eachName, inName) { 19 | return "\u001e;\rvar $"+eachName+"_keys = keys("+inName+");\rfor(var $"+eachName+"_i = 0; $"+eachName+"_i < $"+eachName+"_keys.length; $"+eachName+"_i++) {\rvar $"+eachName+"_last = ($"+eachName+"_i == $"+eachName+"_keys.length-1);\rvar $"+eachName+"_key = $"+eachName+"_keys[$"+eachName+"_i];\rvar "+eachName+" = "+inName+"[$"+eachName+"_key];\routput+=\u001e"; 20 | } 21 | ); 22 | this.code = this.code.replace(//g, "\u001e;\rif ($1) { output+=\u001e"); 23 | this.code = this.code.replace(//g, "\u001e;}\relse if ($1) { output+=\u001e"); 24 | this.code = this.code.replace(//g, "\u001e;}\relse { output+=\u001e"); 25 | this.code = this.code.replace(/<\/(if|for)>/g, "\u001e;\r};\routput+=\u001e"); 26 | this.code = this.code.replace( 27 | /\{\+\s*([\s\S]+?)\s*\+\}/gi, 28 | function (match, code) { 29 | code = code.replace(/"/g, "\u001e"); // prevent qoute-escaping of inline code 30 | code = code.replace(/(\r?\n)/g, " "); 31 | return "\u001e+ ("+code+") +\u001e"; 32 | } 33 | ); 34 | this.code = this.code.replace( 35 | /\{!\s*([\s\S]+?)\s*!\}/gi, 36 | function (match, code) { 37 | code = code.replace(/"/g, "\u001e"); // prevent qoute-escaping of inline code 38 | code = code.replace(/(\n)/g, " "); 39 | return "\u001e; "+code+";\routput+=\u001e"; 40 | } 41 | ); 42 | this.code = this.code+"\u001e;"; 43 | 44 | this.code = this.code.replace(/(\r?\n)/g, "\\n"); 45 | this.code = this.code.replace(/"/g, "\\\""); 46 | this.code = this.code.replace(/\u001e/g, "\""); 47 | } 48 | 49 | JSDOC.JsPlate.prototype.toCode = function() { 50 | return this.code; 51 | } 52 | 53 | JSDOC.JsPlate.keys = function(obj) { 54 | var keys = []; 55 | if (obj.constructor.toString().indexOf("Array") > -1) { 56 | for (var i = 0; i < obj.length; i++) { 57 | keys.push(i); 58 | } 59 | } 60 | else { 61 | for (var i in obj) { 62 | keys.push(i); 63 | } 64 | } 65 | return keys; 66 | }; 67 | 68 | JSDOC.JsPlate.values = function(obj) { 69 | var values = []; 70 | if (obj.constructor.toString().indexOf("Array") > -1) { 71 | for (var i = 0; i < obj.length; i++) { 72 | values.push(obj[i]); 73 | } 74 | } 75 | else { 76 | for (var i in obj) { 77 | values.push(obj[i]); 78 | } 79 | } 80 | return values; 81 | }; 82 | 83 | JSDOC.JsPlate.prototype.process = function(data, compact) { 84 | var keys = JSDOC.JsPlate.keys; 85 | var values = JSDOC.JsPlate.values; 86 | 87 | try { 88 | eval(this.code); 89 | } 90 | catch (e) { 91 | print(">> There was an error evaluating the compiled code from template: "+this.templateFile); 92 | print(" The error was on line "+e.lineNumber+" "+e.name+": "+e.message); 93 | var lines = this.code.split("\r"); 94 | if (e.lineNumber-2 >= 0) print("line "+(e.lineNumber-1)+": "+lines[e.lineNumber-2]); 95 | print("line "+e.lineNumber+": "+lines[e.lineNumber-1]); 96 | print(""); 97 | } 98 | 99 | if (compact) { // patch by mcbain.asm 100 | // Remove lines that contain only space-characters, usually left by lines in the template 101 | // which originally only contained JSPlate tags or code. This makes it easier to write 102 | // non-tricky templates which still put out nice code (not bloated with extra lines). 103 | // Lines purposely left blank (just a line ending) are left alone. 104 | output = output.replace(/\s+?(\r?)\n/g, "$1\n"); 105 | } 106 | 107 | /*debug*///print(this.code); 108 | return output; 109 | } -------------------------------------------------------------------------------- /src/lisp/core/functions.lisp: -------------------------------------------------------------------------------- 1 | (defun load (path::string) 2 | (lisp.load path)) 3 | 4 | 5 | (defun eval-string (str::string) 6 | "Takes a string and evaluates it in the current lisp environment." 7 | (lisp.eval str)) 8 | 9 | 10 | (defun doc (callable) 11 | "Returns the documentation of a given function or macro." 12 | (when (or (is-function callable) 13 | (is-macro callable)) 14 | (getkey callable :documentation))) 15 | 16 | 17 | (defun !! (value) 18 | "An alias for (not (not value)) or (and value)." 19 | (and value)) 20 | 21 | 22 | (setq ! #'not) ;; Alias, just because 23 | 24 | 25 | (defun regex (flags & rest) 26 | (assert (or (is-null flags) 27 | (is-string flags) 28 | (is-undefined flags)) (format nil "(regex) \ 29 | expects a string or nil as its first argument (got %l)" flags)) 30 | (new RegExp (apply #'concat rest) flags)) 31 | 32 | 33 | (defun starts-with (str::string pattern &opt flags::string) 34 | (when (instanceof pattern RegExp) 35 | (setq pattern pattern.source)) 36 | (assert (is-string pattern) (format nil "starts-with expects a string or \ 37 | regex as its second argument (got %l)" pattern)) 38 | (!! (str.match (regex flags "^" pattern)))) 39 | 40 | 41 | (defun ends-with (str::string pattern &opt flags::string) 42 | (when (instanceof pattern RegExp) 43 | (setq pattern pattern.source)) 44 | (assert (is-string pattern) (format nil "ends-with expects a string or \ 45 | regex as its second argument (got %l)" pattern)) 46 | (!! (str.match (regex flags pattern "$")))) 47 | 48 | 49 | (defun rest (seq) 50 | (if (== sequence.length 0) 51 | nil 52 | (seq.slice 1))) 53 | 54 | 55 | (defun first (seq) 56 | (if (== sequence.length 0) 57 | nil 58 | (nth seq 0))) 59 | 60 | 61 | (defun second (seq) 62 | (if (== sequence.length 0) 63 | nil 64 | (nth seq 1))) 65 | 66 | 67 | (defun third (seq) 68 | (if (== sequence.length 0) 69 | nil 70 | (nth seq 2))) 71 | 72 | 73 | (defun sort! (array:Array &opt compare::function) 74 | "Sorts and returns the given array. This function uses parameter 75 | type checking to automatically make sure it gets the right kinds of 76 | arguments. In this function, for example, you know that when you 77 | reach the function body you have an Array as your first argument 78 | and a function as your second (or undefined, because it's optional)." 79 | (array.sort (|| compare (lambda (a b) (if (> a b) 1 -1))))) 80 | 81 | 82 | (defun sort (array:Array &opt compareFunc::function) 83 | "Returns a sorted copy of the given array." 84 | (sort! (array.concat) compareFunc)) 85 | 86 | ;; This was the old (sort) before parameter type-checking and &opt: 87 | ; (defun sort (array compareFunc) 88 | ; "Returns a sorted copy of the given Array." 89 | ; ;; Input validation 90 | ; (assert (and (>= (length arguments) 1) (<= (length arguments) 2)) 91 | ; (format nil "(sort) requires 1 or 2 arguments (got %l)" (length arguments))) 92 | ; (assert (is-array array) 93 | ; (format nil "(sort) requires an Array as its argument (got %l)" array)) 94 | ; (sort! (array.concat) compareFunc)) 95 | 96 | 97 | (defun xrange (a::number &opt b::number step::number) 98 | "Returns a generator that returns a number each time it is 99 | called, starting with `a', ending when it is greater than `b', 100 | and incrementing by `step'." 101 | ;; Sanatize the input 102 | (when (is-undefined b) 103 | (setq b a) 104 | (setq a 0)) 105 | (||= step 1) 106 | ;; Return the generator 107 | (let ((last a)) 108 | (generator () 109 | (let ((ret last)) 110 | (setq last (+ last step)) 111 | (if (> ret b) 112 | (stop-iteration) 113 | ret))))) 114 | 115 | 116 | (defun is-even (num::number) 117 | "Returns true if the given number is even." 118 | (== 0 (% num 2))) 119 | 120 | 121 | (defun round (num::number) 122 | "A shortcut for Math.round." 123 | (Math.round num)) 124 | 125 | 126 | (defun random () 127 | "A shortcut for Math.random." 128 | (Math.random)) 129 | -------------------------------------------------------------------------------- /examples/repl/script.lisp: -------------------------------------------------------------------------------- 1 | (defun repl-represent (value) 2 | "Returns a lispy string representation of the given value" 3 | (cond ((is-null value) "nil") 4 | ((is-true value) "t") 5 | ((is-false value) "f") 6 | ((instanceof value lisp.Symbol) (to-string value)) 7 | ((instanceof value lisp.Keyword) (concat ":" (to-string value))) 8 | ((instanceof value Array) 9 | (concat "(" (join " " (map repl-represent value)) ")")) 10 | (t (to-json value t)))) 11 | 12 | (setq keycodes (object 13 | :backspace 8 :delete 46 14 | :left 37 :up 38 :right 39 :down 40 15 | :0 48 :1 49 :2 50 :3 51 :4 52 :5 53 16 | :6 54 :7 55 :8 56 :9 57 :a 65 :b 66 17 | :c 67 :d 68 :e 69 :f 70 :g 71 :h 72 18 | :i 73 :j 74 :k 75 :l 76 :m 77 :n 78 19 | :o 79 :p 80 :q 81 :r 82 :s 83 :t 84 20 | :u 85 :v 86 :w 87 :x 88 :y 89 :z 90)) 21 | 22 | (defun help () 23 | "Prints the help text" 24 | (print "Commands: 25 | [ctrl-h] - Display this help 26 | [ctrl-k] - Clear the screen 27 | [ctrl-a] - Move to start of line 28 | [ctrl-e] - Move to end of line 29 | [alt-left] - Move left one word 30 | [alt-right] - Move right one word 31 | [alt-backspace] - Delete one word to the left 32 | [alt-delete] - Delete one word to the right 33 | ")) 34 | 35 | (defun clear () 36 | (controller.reset)) 37 | 38 | (defun refresh () 39 | (setq window.location "")) 40 | 41 | (defun lisp.log (& rest) 42 | (try 43 | (controller.message (join " " (if rest rest (array))) "jquery-console-stdout") 44 | (:catch (e) 45 | (controller.message (to-string e) "jquery-console-message-error")))) 46 | 47 | (setq controller nil) ;; This is how we control the repl 48 | 49 | ($ (lambda () 50 | (let ((repl-id "#console") 51 | (repl ($ repl-id))) 52 | (when (=== repl.length 0) 53 | (throw (new Error (format nil "Console with id %s does not exist" repl-id)))) 54 | (setq controller (repl.console (object 55 | :welcomeMessage "js-lisp REPL" 56 | :ps1 ">> " 57 | :ps2 ".. " 58 | :ps3 "=> " 59 | :autofocus t ;; Automatically sets focus on the console when the page loads 60 | :animateScroll nil 61 | :promptHistory t ;; Maintains a history of input given at the prompt 62 | ;:historyPreserveColumn t ;; Preserves the column you are on while scrolling through history 63 | :commandValidate (lambda (line) 64 | (!= line "")) 65 | :commandHandle (lambda (line) 66 | (let ((this controller) 67 | (ret nil)) 68 | (try 69 | (setq ret (array (object :msg (repl-represent (lisp.eval line)) 70 | :className "jquery-console-message-value"))) 71 | (:catch (e) 72 | (setq ret (when (not (instanceof e lisp.exception.StreamEOFException)) 73 | (controller.message (to-string e) "jquery-console-message-error") 74 | t)))) 75 | ret)))))) 76 | 77 | (controller.notice "Hit Ctrl-h for help") 78 | 79 | (defun controller.consoleControl (event) 80 | ;; TODO: Make these (cond) expressions into (case) expressions 81 | ;; whenever (case) is written. 82 | (cond (event.ctrlKey 83 | (controller.cancelKey event.keyCode) 84 | (cond ((== event.keyCode keycodes.h) (help) (controller.commandResult)) 85 | ((== event.keyCode keycodes.k) (clear)) 86 | ((== event.keyCode keycodes.a) (controller.moveToStart)) 87 | ((== event.keyCode keycodes.e) (controller.moveToEnd)) 88 | (t (controller.defaultConsoleControl event)))) 89 | (event.altKey 90 | (controller.cancelKey event.keyCode) 91 | (cond ((== event.keyCode keycodes.left) (controller.moveWordLeft)) 92 | ((== event.keyCode keycodes.right) (controller.moveWordRight)) 93 | ((== event.keyCode keycodes.backspace) (controller.deleteWordLeft)) 94 | ((== event.keyCode keycodes.delete) (controller.deleteWordRight)) 95 | (t (controller.defaultConsoleControl event)))) 96 | (event.metaKey 97 | (controller.cancelKey event.keyCode) 98 | (cond ((== event.keyCode keycodes.r) (setq window.location "")) 99 | (t (controller.defaultConsoleControl event)))) 100 | (t (controller.defaultConsoleControl event)))))) 101 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/frame/Testrun.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileOverview 3 | * @name JsTestrun 4 | * @author Michael Mathews micmath@gmail.com 5 | * @url $HeadURL: https://jsdoc-toolkit.googlecode.com/svn/tags/jsdoc_toolkit-2.3.2/jsdoc-toolkit/app/frame/Testrun.js $ 6 | * @revision $Id: Testrun.js 418 2008-01-15 21:40:33Z micmath $ 7 | * @license X11/MIT License 8 | * (See the accompanying README file for full details.) 9 | */ 10 | 11 | /** 12 | Yet another unit testing tool for JavaScript. 13 | @author Michael Mathews micmath@gmail.com 14 | @param {object} testCases Properties are testcase names, values are functions to execute as tests. 15 | */ 16 | function testrun(testCases) { 17 | var ran = 0; 18 | for (t in testCases) { 19 | var result = testCases[t](); 20 | ran++; 21 | } 22 | 23 | return testrun.reportOut+"-------------------------------\n"+((testrun.fails>0)? ":( Failed "+testrun.fails+"/" : ":) Passed all ")+testrun.count+" test"+((testrun.count == 1)? "":"s")+".\n"; 24 | } 25 | 26 | 27 | testrun.count = 0; 28 | testrun.current = null; 29 | testrun.passes = 0; 30 | testrun.fails = 0; 31 | testrun.reportOut = ""; 32 | 33 | /** @private */ 34 | testrun.report = function(text) { 35 | testrun.reportOut += text+"\n"; 36 | } 37 | 38 | /** 39 | Check if test evaluates to true. 40 | @param {string} test To be evaluated. 41 | @param {string} message Optional. To be displayed in the report. 42 | @return {boolean} True if the string test evaluates to true. 43 | */ 44 | ok = function(test, message) { 45 | testrun.count++; 46 | 47 | var result; 48 | try { 49 | result = eval(test); 50 | 51 | if (result) { 52 | testrun.passes++; 53 | testrun.report(" OK "+testrun.count+" - "+((message != null)? message : "")); 54 | } 55 | else { 56 | testrun.fails++; 57 | testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); 58 | } 59 | } 60 | catch(e) { 61 | testrun.fails++ 62 | testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); 63 | 64 | } 65 | } 66 | 67 | /** 68 | Check if test is same as expected. 69 | @param {string} test To be evaluated. 70 | @param {string} expected 71 | @param {string} message Optional. To be displayed in the report. 72 | @return {boolean} True if (test == expected). Note that the comparison is not a strict equality check. 73 | */ 74 | is = function(test, expected, message) { 75 | testrun.count++; 76 | 77 | var result; 78 | try { 79 | result = eval(test); 80 | 81 | if (result == expected) { 82 | testrun.passes++ 83 | testrun.report(" OK "+testrun.count+" - "+((message != null)? message : "")); 84 | } 85 | else { 86 | testrun.fails++ 87 | testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); 88 | testrun.report("expected: "+expected); 89 | testrun.report(" got: "+result); 90 | } 91 | } 92 | catch(e) { 93 | testrun.fails++ 94 | testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); 95 | testrun.report("expected: "+expected); 96 | testrun.report(" got: "+result);} 97 | } 98 | 99 | /** 100 | Check if test matches pattern. 101 | @param {string} test To be evaluated. 102 | @param {string} pattern Used to create a RegExp. 103 | @param {string} message Optional. To be displayed in the report. 104 | @return {boolean} True if test matches pattern. 105 | */ 106 | like = function(test, pattern, message) { 107 | testrun.count++; 108 | 109 | var result; 110 | try { 111 | result = eval(test); 112 | var rgx = new RegExp(pattern); 113 | 114 | if (rgx.test(result)) { 115 | testrun.passes++ 116 | testrun.report(" OK "+testrun.count+" - "+((message != null)? message : "")); 117 | } 118 | else { 119 | testrun.fails++ 120 | testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); 121 | testrun.report(" this: "+result); 122 | testrun.report("is not like: "+pattern); 123 | } 124 | } 125 | catch(e) { 126 | testrun.fails++ 127 | testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); 128 | } 129 | } -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/frame/Dumper.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class 3 |
  4 | This is a lightly modified version of Kevin Jones' JavaScript
  5 | library Data.Dump. To download the original visit:
  6 |     http://openjsan.org/doc/k/ke/kevinj/Data/Dump/
  7 | 
  8 | AUTHORS
  9 | 
 10 | The Data.Dump JavaScript module is written by Kevin Jones 
 11 | (kevinj@cpan.org), based on Data::Dump by Gisle Aas (gisle@aas.no),
 12 | based on Data::Dumper by Gurusamy Sarathy (gsar@umich.edu).
 13 | 
 14 | COPYRIGHT
 15 | 
 16 | Copyright 2007 Kevin Jones. Copyright 1998-2000,2003-2004 Gisle Aas.
 17 | Copyright 1996-1998 Gurusamy Sarathy.
 18 | 
 19 | This program is free software; you can redistribute it and/or modify
 20 | it under the terms of the Perl Artistic License
 21 | 
 22 | See http://www.perl.com/perl/misc/Artistic.html
 23 | 
24 | * @static 25 | */ 26 | Dumper = { 27 | /** @param [...] The objects to dump. */ 28 | dump: function () { 29 | if (arguments.length > 1) 30 | return this._dump(arguments); 31 | else if (arguments.length == 1) 32 | return this._dump(arguments[0]); 33 | else 34 | return "()"; 35 | }, 36 | 37 | _dump: function (obj) { 38 | if (typeof obj == 'undefined') return 'undefined'; 39 | var out; 40 | if (obj.serialize) { return obj.serialize(); } 41 | var type = this._typeof(obj); 42 | if (obj.circularReference) obj.circularReference++; 43 | switch (type) { 44 | case 'circular': 45 | out = "{ //circularReference\n}"; 46 | break; 47 | case 'object': 48 | var pairs = new Array; 49 | 50 | for (var prop in obj) { 51 | if (prop != "circularReference" && obj.hasOwnProperty(prop)) { //hide inherited properties 52 | pairs.push(prop + ': ' + this._dump(obj[prop])); 53 | } 54 | } 55 | 56 | out = '{' + this._format_list(pairs) + '}'; 57 | break; 58 | 59 | case 'string': 60 | for (var prop in Dumper.ESC) { 61 | if (Dumper.ESC.hasOwnProperty(prop)) { 62 | obj = obj.replace(prop, Dumper.ESC[prop]); 63 | } 64 | } 65 | 66 | // Escape UTF-8 Strings 67 | if (obj.match(/^[\x00-\x7f]*$/)) { 68 | out = '"' + obj.replace(/\"/g, "\\\"").replace(/([\n\r]+)/g, "\\$1") + '"'; 69 | } 70 | else { 71 | out = "unescape('"+escape(obj)+"')"; 72 | } 73 | break; 74 | 75 | case 'array': 76 | var elems = new Array; 77 | 78 | for (var i=0; i 60 ? '\n' : ' '; 109 | return nl + list.join(',' + nl) + nl; 110 | }, 111 | 112 | _typeof: function (obj) { 113 | if (obj && obj.circularReference && obj.circularReference > 1) return 'circular'; 114 | if (Array.prototype.isPrototypeOf(obj)) return 'array'; 115 | if (Date.prototype.isPrototypeOf(obj)) return 'date'; 116 | if (typeof obj.nodeType != 'undefined') return 'element'; 117 | return typeof(obj); 118 | }, 119 | 120 | _dump_dom: function (obj) { 121 | return '"' + Dumper.nodeTypes[obj.nodeType] + '"'; 122 | } 123 | }; 124 | 125 | Dumper.ESC = { 126 | "\t": "\\t", 127 | "\n": "\\n", 128 | "\f": "\\f" 129 | }; 130 | 131 | Dumper.nodeTypes = { 132 | 1: "ELEMENT_NODE", 133 | 2: "ATTRIBUTE_NODE", 134 | 3: "TEXT_NODE", 135 | 4: "CDATA_SECTION_NODE", 136 | 5: "ENTITY_REFERENCE_NODE", 137 | 6: "ENTITY_NODE", 138 | 7: "PROCESSING_INSTRUCTION_NODE", 139 | 8: "COMMENT_NODE", 140 | 9: "DOCUMENT_NODE", 141 | 10: "DOCUMENT_TYPE_NODE", 142 | 11: "DOCUMENT_FRAGMENT_NODE", 143 | 12: "NOTATION_NODE" 144 | }; -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/t/TestDoc.js: -------------------------------------------------------------------------------- 1 | var TestDoc = { 2 | fails: 0, 3 | plans: 0, 4 | passes: 0, 5 | results: [] 6 | }; 7 | 8 | TestDoc.record = function(result) { 9 | TestDoc.results.push(result); 10 | if (typeof result.verdict == "boolean") { 11 | if (result.verdict === false) TestDoc.fails++; 12 | if (result.verdict === true) TestDoc.passes++; 13 | } 14 | } 15 | 16 | TestDoc.prove = function(filePath) { 17 | if (typeof document != "undefined" && typeof document.write != "undefined") { 18 | if (TestDoc.console) print = function(s) { TestDoc.console.appendChild(document.createTextNode(s+"\n")); } 19 | else print = function(s) { document.write(s+"
"); } 20 | } 21 | TestDoc.run(TestDoc.readFile(filePath)); 22 | } 23 | 24 | TestDoc.run = function(src) { 25 | try { eval(src); } catch(e) { print("# ERROR! "+e); } 26 | 27 | var chunks = src.split(/\/\*t:/); 28 | 29 | var run = function(chunk) { 30 | // local shortcuts 31 | var is = TestDoc.assertEquals; 32 | var isnt = TestDoc.assertNotEquals; 33 | var plan = TestDoc.plan; 34 | var requires = TestDoc.requires; 35 | 36 | try { eval(chunk); } catch(e) { print("# ERROR! "+e); } 37 | } 38 | for (var start = -1, end = 0; (start = src.indexOf("/*t:", end)) > end; start = end) { 39 | run( 40 | src.substring( 41 | start+4, 42 | (end = src.indexOf("*/", start)) 43 | ) 44 | ); 45 | } 46 | } 47 | 48 | TestDoc.Result = function(verdict, message) { 49 | this.verdict = verdict; 50 | this.message = message; 51 | } 52 | 53 | TestDoc.Result.prototype.toString = function() { 54 | if (typeof this.verdict == "boolean") { 55 | return (this.verdict? "ok" : "not ok") + " " + (++TestDoc.report.counter) + " - " + this.message; 56 | } 57 | 58 | return "# " + this.message; 59 | } 60 | 61 | TestDoc.requires = function(file) { 62 | if (!TestDoc.requires.loaded[file]) { 63 | load(file); 64 | TestDoc.requires.loaded[file] = true; 65 | } 66 | } 67 | TestDoc.requires.loaded = {}; 68 | 69 | TestDoc.report = function() { 70 | TestDoc.report.counter = 0; 71 | print("1.."+TestDoc.plans); 72 | for (var i = 0; i < TestDoc.results.length; i++) { 73 | print(TestDoc.results[i]); 74 | } 75 | print("----------------------------------------"); 76 | if (TestDoc.fails == 0 && TestDoc.passes == TestDoc.plans) { 77 | print("All tests successful."); 78 | } 79 | else { 80 | print("Failed " + TestDoc.fails + "/" + TestDoc.plans + " tests, "+((TestDoc.plans == 0)? 0 : Math.round(TestDoc.passes/(TestDoc.passes+TestDoc.fails)*10000)/100)+"% okay. Planned to run "+TestDoc.plans+", did run "+(TestDoc.passes+TestDoc.fails)+".") 81 | } 82 | } 83 | 84 | TestDoc.plan = function(n, message) { 85 | TestDoc.plans += n; 86 | TestDoc.record(new TestDoc.Result(null, message+" ("+n+" tests)")); 87 | } 88 | 89 | TestDoc.assertEquals = function(a, b, message) { 90 | var result = (a == b); 91 | if (!result) message += "\n#\n# " + a + " does not equal " + b + "\n#"; 92 | TestDoc.record(new TestDoc.Result(result, message)); 93 | } 94 | 95 | TestDoc.assertNotEquals = function(a, b, message) { 96 | var result = (a != b); 97 | if (!result) message += "\n#\n# " + a + " equals " + b + "\n#"; 98 | TestDoc.record(new TestDoc.Result(result, message)); 99 | } 100 | 101 | TestDoc.readFile = (function(){ 102 | // rhino 103 | if (typeof readFile == "function") { 104 | return function(url) { 105 | var text = readFile(url); 106 | return text || ""; 107 | } 108 | } 109 | 110 | // a web browser 111 | else { 112 | return function(url) { 113 | var httpRequest; 114 | 115 | if (window.XMLHttpRequest) { // Mozilla, Safari, etc 116 | httpRequest = new XMLHttpRequest(); 117 | } 118 | else if (window.ActiveXObject) { // IE 119 | try { 120 | httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); 121 | } 122 | catch (e) { 123 | try { 124 | httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 125 | } 126 | catch (e) { 127 | } 128 | } 129 | } 130 | 131 | if (!httpRequest) { throw "Cannot create HTTP Request."; } 132 | 133 | httpRequest.open('GET', url, false); 134 | httpRequest.send(''); 135 | if (httpRequest.readyState == 4) { 136 | if (httpRequest.status >= 400) { 137 | throw "The HTTP Request returned an error code: "+httpRequest.status; 138 | } 139 | } 140 | 141 | return httpRequest.responseText || ""; 142 | } 143 | } 144 | })(); 145 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js: -------------------------------------------------------------------------------- 1 | LOG.inform("XMLDOC.DomReader loaded"); 2 | 3 | XMLDOC.DomReader = function(root) { 4 | 5 | this.dom = root; 6 | 7 | /** 8 | * The current node the reader is on 9 | */ 10 | this.node = root; 11 | 12 | /** 13 | * Get the current node the reader is on 14 | * @type XMLDOC.Parser.node 15 | */ 16 | XMLDOC.DomReader.prototype.getNode = function() { 17 | return this.node; 18 | }; 19 | 20 | /** 21 | * Set the node the reader should be positioned on. 22 | * @param node {XMLDOC.Parser.node} 23 | */ 24 | XMLDOC.DomReader.prototype.setNode = function(node) { 25 | this.node = node; 26 | }; 27 | 28 | /** 29 | * A helper method to make sure the current node will 30 | * never return null, unless null is passed as the root. 31 | * @param step {String} An expression to evaluate - should return a node or null 32 | */ 33 | XMLDOC.DomReader.prototype.navigate = function(step) { 34 | var n; 35 | if ((n = step) != null) 36 | { 37 | this.node = n; 38 | return this.node; 39 | } 40 | return null; 41 | }; 42 | 43 | /** 44 | * Get the root node of the current node's document. 45 | */ 46 | XMLDOC.DomReader.prototype.root = function() { 47 | this.navigate(this.dom); 48 | }; 49 | 50 | /** 51 | * Get the parent of the current node. 52 | */ 53 | XMLDOC.DomReader.prototype.parent = function() { 54 | return this.navigate(this.node.parentNode()); 55 | }; 56 | 57 | /** 58 | * Get the first child of the current node. 59 | */ 60 | XMLDOC.DomReader.prototype.firstChild = function() { 61 | return this.navigate(this.node.firstChild()); 62 | }; 63 | 64 | /** 65 | * Get the last child of the current node. 66 | */ 67 | XMLDOC.DomReader.prototype.lastChild = function() { 68 | return this.navigate(this.node.lastChild()); 69 | }; 70 | 71 | /** 72 | * Get the next sibling of the current node. 73 | */ 74 | XMLDOC.DomReader.prototype.nextSibling = function() { 75 | return this.navigate(this.node.nextSibling()); 76 | }; 77 | 78 | /** 79 | * Get the previous sibling of the current node. 80 | */ 81 | XMLDOC.DomReader.prototype.prevSibling = function() { 82 | return this.navigate(this.node.prevSibling()); 83 | }; 84 | 85 | //=============================================================================================== 86 | // Support methods 87 | 88 | /** 89 | * Walk the tree starting with the current node, calling the plug-in for 90 | * each node visited. Each time the plug-in is called, the DomReader 91 | * is passed as the only parameter. Use the {@link XMLDOC.DomReader#getNode} method 92 | * to access the current node. This method uses a depth first traversal pattern. 93 | * 94 | * @param srcFile {String} The source file being evaluated 95 | */ 96 | XMLDOC.DomReader.prototype.getSymbols = function(srcFile) 97 | { 98 | XMLDOC.DomReader.symbols = []; 99 | XMLDOC.DomReader.currentFile = srcFile; 100 | JSDOC.Symbol.srcFile = (srcFile || ""); 101 | 102 | if (defined(JSDOC.PluginManager)) { 103 | JSDOC.PluginManager.run("onDomGetSymbols", this); 104 | } 105 | 106 | return XMLDOC.DomReader.symbols; 107 | }; 108 | 109 | /** 110 | * Find the node with the given name using a depth first traversal. 111 | * Does not modify the DomReader's current node. 112 | * 113 | * @param name {String} The name of the node to find 114 | * @return the node that was found, or null if not found 115 | */ 116 | XMLDOC.DomReader.prototype.findNode = function(name) 117 | { 118 | var findNode = null; 119 | 120 | // Start at the current node and move into the subtree, 121 | // looking for the node with the given name 122 | function deeper(node, find) 123 | { 124 | var look = null; 125 | 126 | if (node) { 127 | if (node.name == find) 128 | { 129 | return node; 130 | } 131 | 132 | if (node.firstChild()) 133 | { 134 | look = deeper(node.firstChild(), find); 135 | } 136 | 137 | if (!look && node.nextSibling()) 138 | { 139 | look = deeper(node.nextSibling(), find); 140 | } 141 | } 142 | 143 | return look; 144 | } 145 | 146 | return deeper(this.getNode().firstChild(), name); 147 | }; 148 | 149 | /** 150 | * Find the next node with the given name using a depth first traversal. 151 | * 152 | * @param name {String} The name of the node to find 153 | */ 154 | XMLDOC.DomReader.prototype.findPreviousNode = function(name) 155 | { 156 | }; 157 | 158 | }; 159 | 160 | -------------------------------------------------------------------------------- /support/bin/jsdoc-toolkit/app/frame/Link.js: -------------------------------------------------------------------------------- 1 | /** Handle the creation of HTML links to documented symbols. 2 | @constructor 3 | */ 4 | function Link() { 5 | this.alias = ""; 6 | this.src = ""; 7 | this.file = ""; 8 | this.text = ""; 9 | this.innerName = ""; 10 | this.classLink = false; 11 | this.targetName = ""; 12 | 13 | this.target = function(targetName) { 14 | if (defined(targetName)) this.targetName = targetName; 15 | return this; 16 | } 17 | this.inner = function(inner) { 18 | if (defined(inner)) this.innerName = inner; 19 | return this; 20 | } 21 | this.withText = function(text) { 22 | if (defined(text)) this.text = text; 23 | return this; 24 | } 25 | this.toSrc = function(filename) { 26 | if (defined(filename)) this.src = filename; 27 | return this; 28 | } 29 | this.toSymbol = function(alias) { 30 | if (defined(alias)) this.alias = new String(alias); 31 | return this; 32 | } 33 | this.toClass = function(alias) { 34 | this.classLink = true; 35 | return this.toSymbol(alias); 36 | } 37 | this.toFile = function(file) { 38 | if (defined(file)) this.file = file; 39 | return this; 40 | } 41 | 42 | this.toString = function() { 43 | var linkString; 44 | var thisLink = this; 45 | 46 | if (this.alias) { 47 | linkString = this.alias.replace(/(^|[^a-z$0-9_#.:^-])([|a-z$0-9_#.:^-]+)($|[^a-z$0-9_#.:^-])/i, 48 | function(match, prematch, symbolName, postmatch) { 49 | var symbolNames = symbolName.split("|"); 50 | var links = []; 51 | for (var i = 0, l = symbolNames.length; i < l; i++) { 52 | thisLink.alias = symbolNames[i]; 53 | links.push(thisLink._makeSymbolLink(symbolNames[i])); 54 | } 55 | return prematch+links.join("|")+postmatch; 56 | } 57 | ); 58 | } 59 | else if (this.src) { 60 | linkString = thisLink._makeSrcLink(this.src); 61 | } 62 | else if (this.file) { 63 | linkString = thisLink._makeFileLink(this.file); 64 | } 65 | 66 | return linkString; 67 | } 68 | } 69 | 70 | /** prefixed for hashes */ 71 | Link.hashPrefix = ""; 72 | 73 | /** Appended to the front of relative link paths. */ 74 | Link.base = ""; 75 | 76 | Link.symbolNameToLinkName = function(symbol) { 77 | var linker = ""; 78 | if (symbol.isStatic) linker = "."; 79 | else if (symbol.isInner) linker = "-"; 80 | 81 | return Link.hashPrefix+linker+symbol.name; 82 | } 83 | 84 | /** Create a link to another symbol. */ 85 | Link.prototype._makeSymbolLink = function(alias) { 86 | var linkBase = Link.base+publish.conf.symbolsDir; 87 | var linkTo = Link.symbolSet.getSymbol(alias); 88 | var linkPath; 89 | var target = (this.targetName)? " target=\""+this.targetName+"\"" : ""; 90 | 91 | // is it an internal link? 92 | if (alias.charAt(0) == "#") var linkPath = alias; 93 | 94 | // if there is no symbol by that name just return the name unaltered 95 | else if (!linkTo) return this.text || alias; 96 | 97 | // it's a symbol in another file 98 | else { 99 | if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property 100 | if (linkTo.isEvent) { 101 | linkPath = 102 | (Link.filemap)? Link.filemap[linkTo.memberOf] 103 | : 104 | escape(linkTo.memberOf) || "_global_"; 105 | linkPath += publish.conf.ext + "#event:" + Link.symbolNameToLinkName(linkTo); 106 | } 107 | else { 108 | linkPath = 109 | (Link.filemap)? Link.filemap[linkTo.memberOf] 110 | : 111 | escape(linkTo.memberOf) || "_global_"; 112 | linkPath += publish.conf.ext + "#" + Link.symbolNameToLinkName(linkTo); 113 | } 114 | } 115 | else { 116 | linkPath = (Link.filemap)? Link.filemap[linkTo.alias] : escape(linkTo.alias); 117 | linkPath += publish.conf.ext;// + (this.classLink? "":"#" + Link.hashPrefix + "constructor"); 118 | } 119 | linkPath = linkBase + linkPath 120 | } 121 | 122 | var linkText = this.text || alias; 123 | 124 | var link = {linkPath: linkPath, linkText: linkText, linkInner: (this.innerName? "#"+this.innerName : "")}; 125 | 126 | if (typeof JSDOC.PluginManager != "undefined") { 127 | JSDOC.PluginManager.run("onSymbolLink", link); 128 | } 129 | 130 | return ""+link.linkText+""; 131 | } 132 | 133 | /** Create a link to a source file. */ 134 | Link.prototype._makeSrcLink = function(srcFilePath) { 135 | var target = (this.targetName)? " target=\""+this.targetName+"\"" : ""; 136 | 137 | // transform filepath into a filename 138 | var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "_"); 139 | var outFilePath = Link.base + publish.conf.srcDir + srcFile + publish.conf.ext; 140 | 141 | if (!this.text) this.text = FilePath.fileName(srcFilePath); 142 | return ""+this.text+""; 143 | } 144 | 145 | /** Create a link to a source file. */ 146 | Link.prototype._makeFileLink = function(filePath) { 147 | var target = (this.targetName)? " target=\""+this.targetName+"\"" : ""; 148 | 149 | var outFilePath = Link.base + filePath; 150 | 151 | if (!this.text) this.text = filePath; 152 | return ""+this.text+""; 153 | } --------------------------------------------------------------------------------