Skip to content
This repository
Browse code

not allowing free variables, anymore -- too many errors; you have to …

…quote strings
  • Loading branch information...
commit 91429a464b544e8f531a113659a7bb69c267d60b 1 parent 733078b
Bill Burdick authored April 23, 2012
16  TODO.html
@@ -20,6 +20,10 @@
20 20
 <li>parser macros should return (ast, errors, warnings)</li>
21 21
 <li>error if let/do has no expr</li>
22 22
 <li>error if let finds more than one body expr</li>
  23
+<li>debug mode should put a cons into funcs of a new error and the list from the parent
  24
+<ul>
  25
+<li>can use this to see the origin of a thunk</li>
  26
+</ul></li>
23 27
 <li>add assertMonad() to testing.cs
24 28
 <ul>
25 29
 <li>probably use env for this</li>
@@ -63,21 +67,19 @@
63 67
 <li>comments that attach event handlers?</li>
64 68
 <li>make TTT into a notebook that shows the TTT grid</li>
65 69
 <li>optionally hide source code</li>
  70
+<li>load/save</li>
66 71
 </ul></li>
67  
-<li>better browser environment
  72
+<li>a 'require' directive that works in browsers and on the cmd line
68 73
 <ul>
69  
-<li>left side should be an editor</li>
70  
-<li>loading files should load them into the editor</li>
71  
-<li>input should be in a blinking box on the right side, not in an alert box</li>
72  
-<li>should be able to load *.lsr files into the environment</li>
  74
+<li>adding a script tag works in browsers, provided you're not violating access restrictions (the launch script can help with that)</li>
73 75
 </ul></li>
74  
-<li>use curlies for do/let
  76
+<li>use curlies for do/let?
75 77
 <ul>
  78
+<li>not sure what this means for indentation</li>
76 79
 <li>remove intermediate step of inserting {}; -- convert directly to parenthesized groups</li>
77 80
 <li>allow newlines in open groups</li>
78 81
 <li>{ and } would be a grouping macros</li>
79 82
 </ul></li>
80  
-<li>debug mode should put a cons into funcs of a new exception and the list from the parent</li>
81 83
 <li>add prelude.lsr
82 84
 <ul>
83 85
 <li>put parser macros in there</li>
14  TODO.md
Source Rendered
@@ -4,6 +4,8 @@
4 4
 * parser macros should return (ast, errors, warnings)
5 5
 * error if let/do has no expr
6 6
 * error if let finds more than one body expr
  7
+* debug mode should put a cons into funcs of a new error and the list from the parent
  8
+   * can use this to see the origin of a thunk
7 9
 * add assertMonad() to testing.cs
8 10
    * probably use env for this
9 11
 * pretty printer function can take an assoc-list of printers for types
@@ -34,16 +36,14 @@
34 36
    * comments that attach event handlers?
35 37
    * make TTT into a notebook that shows the TTT grid
36 38
    * optionally hide source code
37  
-* better browser environment
38  
-   * left side should be an editor
39  
-   * loading files should load them into the editor
40  
-   * input should be in a blinking box on the right side, not in an alert box
41  
-   * should be able to load *.lsr files into the environment
42  
-* use curlies for do/let
  39
+   * load/save
  40
+* a 'require' directive that works in browsers and on the cmd line
  41
+   * adding a script tag works in browsers, provided you're not violating access restrictions (the launch script can help with that)
  42
+* use curlies for do/let?
  43
+   * not sure what this means for indentation
43 44
    * remove intermediate step of inserting {}; -- convert directly to parenthesized groups
44 45
    * allow newlines in open groups
45 46
    * { and } would be a grouping macros
46  
-* debug mode should put a cons into funcs of a new exception and the list from the parent
47 47
 * add prelude.lsr
48 48
    * put parser macros in there
49 49
 * integrate physics engine
7  leisure.cs
@@ -248,7 +248,11 @@ class Code
248 248
         code = code.copyWith(nameSub val).reffedValue(deref)
249 249
         if vars.find((v)-> v == val) then code.addVar(val)
250 250
         else if ctx[nameSub(val)]? or code.global.find((v)-> v == val) then code
251  
-        else code.copyWith(JSON.stringify(scanTok(val))).unreffedValue(deref)
  251
+        #else code.copyWith(JSON.stringify(scanTok(val))).unreffedValue(deref)
  252
+        else if typeof val == 'number' then code.copyWith(JSON.stringify(scanTok(val))).unreffedValue(deref)
  253
+        else
  254
+          console.log "FREE: #{val}, type: #{typeof val}"
  255
+          code.addErr "attempt to use free variable: #{val}"
252 256
     when 'lit'
253 257
       val = getLitVal ast
254 258
       src = if typeof val == 'function' or typeof val == 'object'
@@ -542,6 +546,7 @@ continueApply tag(apply(laz(func))(laz(arg)), func.leisureStart, arg.leisureEnd)
542 546
   try
543 547
     l = JSON.parse(name)
544 548
     if typeof l == 'string' then lit(laz(l))
  549
+    else if typeof l == 'number' then ref(laz(l))
545 550
     else ref(laz(name))
546 551
   catch err
547 552
     ref(laz(name))
7  leisure.js
@@ -514,8 +514,11 @@ misrepresented as being the original software.
514 514
             return v === val;
515 515
           })) {
516 516
             return code;
517  
-          } else {
  517
+          } else if (typeof val === 'number') {
518 518
             return code.copyWith(JSON.stringify(scanTok(val))).unreffedValue(deref);
  519
+          } else {
  520
+            console.log("FREE: " + val + ", type: " + (typeof val));
  521
+            return code.addErr("attempt to use free variable: " + val);
519 522
           }
520 523
         }
521 524
         break;
@@ -1000,6 +1003,8 @@ misrepresented as being the original software.
1000 1003
       l = JSON.parse(name);
1001 1004
       if (typeof l === 'string') {
1002 1005
         return lit(laz(l));
  1006
+      } else if (typeof l === 'number') {
  1007
+        return ref(laz(l));
1003 1008
       } else {
1004 1009
         return ref(laz(name));
1005 1010
       }
18  testLeisure.cs
@@ -53,19 +53,19 @@
53 53
 
54 54
 run 'test1', -> assertParse("1", "ref 1")
55 55
 run 'test2', -> assertParse("\\x.x x y", "lambda x . apply (apply (ref x) (ref x)) (ref y)", "\\x.x x y")
56  
-run 'test3', -> assertEval("(\\x . x) hello", 'hello')
57  
-run 'test4', -> assertEval("eval (apply (lambda x (ref x)) (lit hello))", 'hello')
58  
-run 'test5', -> assertEval("(eq cons cons) yes no", 'yes')
59  
-run 'test6', -> assertEval("(eq cons true) yes no", 'no')
  56
+run 'test3', -> assertEval("(\\x . x) 'hello'", 'hello')
  57
+run 'test4', -> assertEval("eval (apply (lambda 'x' (ref 'x')) (lit 'hello'))", 'hello')
  58
+run 'test5', -> assertEval("(eq cons cons) 'yes' 'no'", 'yes')
  59
+run 'test6', -> assertEval("(eq cons true) 'yes' 'no'", 'no')
60 60
 run 'test7', -> LZ.astEval(LZ.gen(LZ.parse("cons 1 2")))
61 61
 run 'test8', -> LZ.astEval(LZ.gen(LZ.parse("head (cons 1 2)")))
62 62
 run 'test9', -> assertEval("head (cons 1 2)", 1)
63 63
 run 'test10', -> assertEval("tail (cons 1 2)", 2)
64  
-run 'test11', -> assertEval("last (cons a nil)", 'a')
65  
-run 'test12', -> assertEval("last (cons a (cons b nil))", 'b')
66  
-run 'test13', -> assertEval("(is (cons a b) cons) yes no", 'yes')
67  
-run 'test14', -> assertEval("(eval (lambda a (lambda b (ref a)))) yes no", 'yes')
68  
-run 'test15', -> assertEval("(\\1 .; 1) hello", 'hello')
  64
+run 'test11', -> assertEval("last (cons 'a' nil)", 'a')
  65
+run 'test12', -> assertEval("last (cons 'a' (cons 'b' nil))", 'b')
  66
+run 'test13', -> assertEval("(is (cons 'a' 'b') cons) 'yes' 'no'", 'yes')
  67
+run 'test14', -> assertEval("(eval (lambda 'a' (lambda 'b' (ref 'a')))) 'yes' 'no'", 'yes')
  68
+run 'test15', -> assertEval("(\\1 .; 1) 'hello'", 'hello')
69 69
 run 'test16', -> assertEval("head ([ 1 ])", 1)
70 70
 run 'test17', -> assertEval("head (tail (append ([ 1 ]) ([ 2 ])))", 2)
71 71
 run 'test18', -> assertEval("head [1]", 1)
18  testLeisure.js
@@ -59,19 +59,19 @@ Tests for Leisure
59 59
   });
60 60
 
61 61
   run('test3', function() {
62  
-    return assertEval("(\\x . x) hello", 'hello');
  62
+    return assertEval("(\\x . x) 'hello'", 'hello');
63 63
   });
64 64
 
65 65
   run('test4', function() {
66  
-    return assertEval("eval (apply (lambda x (ref x)) (lit hello))", 'hello');
  66
+    return assertEval("eval (apply (lambda 'x' (ref 'x')) (lit 'hello'))", 'hello');
67 67
   });
68 68
 
69 69
   run('test5', function() {
70  
-    return assertEval("(eq cons cons) yes no", 'yes');
  70
+    return assertEval("(eq cons cons) 'yes' 'no'", 'yes');
71 71
   });
72 72
 
73 73
   run('test6', function() {
74  
-    return assertEval("(eq cons true) yes no", 'no');
  74
+    return assertEval("(eq cons true) 'yes' 'no'", 'no');
75 75
   });
76 76
 
77 77
   run('test7', function() {
@@ -91,23 +91,23 @@ Tests for Leisure
91 91
   });
92 92
 
93 93
   run('test11', function() {
94  
-    return assertEval("last (cons a nil)", 'a');
  94
+    return assertEval("last (cons 'a' nil)", 'a');
95 95
   });
96 96
 
97 97
   run('test12', function() {
98  
-    return assertEval("last (cons a (cons b nil))", 'b');
  98
+    return assertEval("last (cons 'a' (cons 'b' nil))", 'b');
99 99
   });
100 100
 
101 101
   run('test13', function() {
102  
-    return assertEval("(is (cons a b) cons) yes no", 'yes');
  102
+    return assertEval("(is (cons 'a' 'b') cons) 'yes' 'no'", 'yes');
103 103
   });
104 104
 
105 105
   run('test14', function() {
106  
-    return assertEval("(eval (lambda a (lambda b (ref a)))) yes no", 'yes');
  106
+    return assertEval("(eval (lambda 'a' (lambda 'b' (ref 'a')))) 'yes' 'no'", 'yes');
107 107
   });
108 108
 
109 109
   run('test15', function() {
110  
-    return assertEval("(\\1 .; 1) hello", 'hello');
  110
+    return assertEval("(\\1 .; 1) 'hello'", 'hello');
111 111
   });
112 112
 
113 113
   run('test16', function() {

0 notes on commit 91429a4

Please sign in to comment.
Something went wrong with that request. Please try again.