From a080f6079cc69ae939e34eba661f063273cc28b8 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Wed, 6 Jul 2011 17:00:42 -0400 Subject: [PATCH] removing dependency on types --- js-assembler/get-runtime.rkt | 2 -- js-assembler/runtime-src/baselib-lists.js | 26 ++++++++++++++++++++++- js-assembler/runtime-src/link.js | 2 -- js-assembler/runtime-src/runtime.js | 23 ++++++++------------ tests/earley/earley.rkt | 2 +- 5 files changed, 35 insertions(+), 20 deletions(-) diff --git a/js-assembler/get-runtime.rkt b/js-assembler/get-runtime.rkt index f7a2003..3e623eb 100644 --- a/js-assembler/get-runtime.rkt +++ b/js-assembler/get-runtime.rkt @@ -68,8 +68,6 @@ baselib-exceptions.js baselib-readergraph.js - link.js - types.js runtime.js)) diff --git a/js-assembler/runtime-src/baselib-lists.js b/js-assembler/runtime-src/baselib-lists.js index 366d881..4750417 100644 --- a/js-assembler/runtime-src/baselib-lists.js +++ b/js-assembler/runtime-src/baselib-lists.js @@ -153,6 +153,29 @@ var makePair = Cons.makeInstance; + var makeList = function() { + var result = Empty.EMPTY; + for(var i = arguments.length-1; i >= 0; i--) { + result = Cons.makeInstance(arguments[i], result); + } + return result; + }; + + + // isList: Any -> Boolean + // Returns true if x is a list (a chain of pairs terminated by EMPTY). + var isList = function(x) { + while (x !== Empty.EMPTY) { + if (x instanceof Cons){ + x = x.rest; + } else { + return false; + } + } + return true; + }; + + ////////////////////////////////////////////////////////////////////// @@ -160,8 +183,9 @@ exports.Empty = Empty; exports.Cons = Cons; exports.isPair = isPair; + exports.isList = isList; exports.makePair = makePair; - + exports.makeList = makeList; })(this['plt'].baselib); \ No newline at end of file diff --git a/js-assembler/runtime-src/link.js b/js-assembler/runtime-src/link.js index 6156d8a..cd4611d 100644 --- a/js-assembler/runtime-src/link.js +++ b/js-assembler/runtime-src/link.js @@ -6,7 +6,6 @@ if (! this['plt']) { this['plt'] = {}; } var link = {}; scope['link'] = link; - // link.ready: (string (string -> void)) -> void // When the name announces that it's ready, calls the function f. link.ready = function(name, f) { @@ -27,7 +26,6 @@ if (! this['plt']) { this['plt'] = {}; } }; - // notifyAll: string -> void // Tell all listeners that the name is ready. var notifyAll = function(name) { diff --git a/js-assembler/runtime-src/runtime.js b/js-assembler/runtime-src/runtime.js index a7b9105..bae32c4 100644 --- a/js-assembler/runtime-src/runtime.js +++ b/js-assembler/runtime-src/runtime.js @@ -27,18 +27,16 @@ if(this['plt'] === undefined) { this['plt'] = {}; } var isNumber = plt.baselib.numbers.isNumber; var isNatural = plt.baselib.numbers.isNatural; var isReal = plt.baselib.numbers.isReal; - var isPair = types.isPair; - var isList = types.isList; - var isVector = types.isVector; - var isString = types.isString; - var equals = types.equals; + var isPair = plt.baselib.lists.isPair; + var isList = plt.baselib.lists.isList; + var isVector = plt.baselib.vectors.isVector; + var isString = plt.baselib.strings.isString; + var equals = plt.baselib.equality.equals; - - var NULL = types.EMPTY; + var NULL = plt.baselib.lists.EMPTY; var VOID = plt.baselib.constants.VOID_VALUE; var EOF = plt.baselib.constants.EOF_VALUE; - var NEGATIVE_ZERO = plt.baselib.numbers.negative_zero; var INF = plt.baselib.numbers.inf; var NEGATIVE_INF = plt.baselib.numbers.negative_inf; @@ -50,9 +48,9 @@ if(this['plt'] === undefined) { this['plt'] = {}; } var makeComplex = plt.baselib.numbers.makeComplex; - var makeVector = types.vector; - var makeList = types.list; - var makePair = types.pair; + var makeVector = plt.baselib.vectors.makeVector; + var makeList = plt.baselib.lists.makeList; + var makePair = plt.baselib.lists.makePair; var heir = plt.baselib.heir; var toDomNode = plt.baselib.format.toDomNode; @@ -2633,7 +2631,4 @@ if(this['plt'] === undefined) { this['plt'] = {}; } exports['StructType'] = plt.baselib.structs.StructType; - scope.link.announceReady('runtime'); - - })(this['plt']); \ No newline at end of file diff --git a/tests/earley/earley.rkt b/tests/earley/earley.rkt index d58d390..7ac0cf9 100644 --- a/tests/earley/earley.rkt +++ b/tests/earley/earley.rkt @@ -1,4 +1,4 @@ -#lang s-exp "../../lang/base.rkt" +#lang planet dyoo/whalesong (begin (define make-parser (lambda (grammar lexer)