GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: The Nu programming language.
Homepage: http://programming.nu
Clone URL: git://github.com/timburks/nu.git
Added "macro-0" as an alias for the existing Nu macro operator.
timburks (author)
Mon Aug 04 09:39:33 -0700 2008
commit  ab8b5d084d5219b32f7ac72707f61528c4f33771
tree    a3dc094bc63d6c433fc6c0915bd16bb7ce9e0d85
parent  d0a07b287f316d60f94dfe87251469b7a6bea000
...
21
22
23
24
 
25
26
27
28
29
30
 
31
32
33
34
35
 
...
21
22
23
 
24
25
26
27
28
29
 
30
31
32
33
 
34
35
0
@@ -21,14 +21,14 @@
0
                             functions:(dict)))  ;; for each function, remember its signature
0
 
0
 (global import
0
- (macro _
0
+ (macro-0 _
0
              (NuBridgeSupport importFramework:((margs car) stringValue)
0
                   fromPath:(if (margs cdr) (then (eval ((margs cdr) car))) (else nil))
0
                   intoDictionary:BridgeSupport)))
0
 
0
 (global import-system
0
- (macro _
0
+ (macro-0 _
0
              (((NSString stringWithShellCommand:"ls /System/Library/Frameworks") lines) each:
0
               (do (line)
0
                   (set name ((line componentsSeparatedByString:".") 0))
0
- (eval (cons 'import (list name)))))))
0
\ No newline at end of file
0
+ (eval (cons 'import (list name)))))))
...
17
18
19
20
 
21
22
23
...
17
18
19
 
20
21
22
23
0
@@ -17,7 +17,7 @@
0
 ;; See the License for the specific language governing permissions and
0
 ;; limitations under the License.
0
 
0
-(macro bridge
0
+(macro-0 bridge
0
      (set __kind (margs first))
0
      (set __name (margs second))
0
      (set __signature (margs third))
...
178
179
180
181
 
182
183
184
...
197
198
199
200
 
201
202
203
...
469
470
471
472
 
473
474
475
...
790
791
792
793
 
794
795
796
...
178
179
180
 
181
182
183
184
...
197
198
199
 
200
201
202
203
...
469
470
471
 
472
473
474
475
...
790
791
792
 
793
794
795
796
0
@@ -178,7 +178,7 @@
0
      (imethod (void) addClass: (id) class is (@classes addObject:class)))
0
 
0
 ;; Extract information from one line of class and method comments.
0
-(macro parseClassAndMethodCommentLine
0
+(macro-0 parseClassAndMethodCommentLine
0
      (cond ((line beginsWithString:"@class")
0
             (set @class (line substringFromIndex:(+ 1 ("@class" length)))))
0
            ((line beginsWithString:"@category") ;; category is an alias for class
0
@@ -197,7 +197,7 @@
0
                 (@discussion appendString:line))))
0
 
0
 ;; Extract documentation information from class and method comments.
0
-(macro parseClassAndMethodComments
0
+(macro-0 parseClassAndMethodComments
0
      (set @discussion (NSMutableString string))
0
      (if @comments
0
          (if (set match (objc-comment-pattern findInString:@comments))
0
@@ -469,7 +469,7 @@ END))
0
                                              (set $comments "#{(match groupAtIndex:0)}"))
0
                         (else nil)))))
0
 
0
-(macro site-header
0
+(macro-0 site-header
0
      (if (eq $sitename "programming.nu")
0
          (then <<-END
0
 <div style="float:left; margin-right:10px">
0
@@ -790,7 +790,7 @@ END))
0
 ;;
0
 ;; Main program starts here
0
 ;;
0
-(macro nudoc
0
+(macro-0 nudoc
0
      (set $classes (NSMutableDictionary dictionary))
0
      (set $files (NSMutableDictionary dictionary))
0
      
...
28
29
30
31
 
32
33
34
35
36
37
 
38
39
40
41
 
42
43
44
45
46
 
47
48
49
50
51
 
52
53
54
...
28
29
30
 
31
32
33
34
35
36
 
37
38
39
40
 
41
42
43
44
45
 
46
47
48
49
50
 
51
52
53
54
0
@@ -28,27 +28,27 @@
0
              (then (meval ((pairs cdr) cdr) (subst (pairs second) (pairs first) code)))
0
              (else (eval code))))
0
     
0
- (macro class-help-0
0
+ (macro-0 class-help-0
0
          (meval (list 'className (margs first)
0
                       'helpText (margs second))
0
                 '(class className
0
                       (imethod (id) help is helpText))))
0
     
0
- (macro class-help-1
0
+ (macro-0 class-help-1
0
          (eval (list 'class (margs first)
0
                      (list 'imethod '(id) 'help 'is (margs second)))))
0
     
0
- (macro class-help-2
0
+ (macro-0 class-help-2
0
          (class (unquote (margs first))
0
               (imethod (id) help is (unquote (margs second)))))
0
     
0
     ; we might prefer this when the parser can handle commas.
0
- ;(macro class-help-3
0
+ ;(macro-0 class-help-3
0
     ; (class ,(margs first))
0
     ; (imethod (id) help is ,(margs second)))
0
     )
0
 
0
-(macro class-help
0
+(macro-0 class-help
0
      (class (unquote (margs first))
0
           (imethod (id) help is (unquote (margs second)))))
0
 
...
77
78
79
80
 
81
82
83
...
77
78
79
 
80
81
82
83
0
@@ -77,7 +77,7 @@
0
 ;; We just use an "_" for the macro name argument because its local name is unimportant.
0
 ;; It does not work with the latest (more restrictive) ObjC runtimes from Apple.
0
 (global protocol
0
- (macro _
0
+ (macro-0 _
0
              (set __signatureForIdentifier (NuBridgedFunction functionWithName:"signature_for_identifier" signature:"@@@"))
0
              (function __parse_signature (typeSpecifier)
0
                   (__signatureForIdentifier typeSpecifier (NuSymbolTable sharedSymbolTable)))
...
101
102
103
104
 
105
106
107
...
110
111
112
113
 
114
115
116
...
119
120
121
122
 
123
124
125
...
128
129
130
131
 
132
133
134
...
137
138
139
140
 
141
142
143
...
155
156
157
158
 
159
160
161
...
166
167
168
169
 
170
171
172
...
174
175
176
177
 
178
179
180
...
101
102
103
 
104
105
106
107
...
110
111
112
 
113
114
115
116
...
119
120
121
 
122
123
124
125
...
128
129
130
 
131
132
133
134
...
137
138
139
 
140
141
142
143
...
155
156
157
 
158
159
160
161
...
166
167
168
 
169
170
171
172
...
174
175
176
 
177
178
179
180
0
@@ -101,7 +101,7 @@
0
           (set $assertions (+ $assertions @assertions))
0
           (puts "#{((self class) name)}: completed #{(testcases count)} tests/#{@assertions} assertions/#{@failures} failures/#{@errors} errors")))
0
 
0
-(macro assert_equal
0
+(macro-0 assert_equal
0
      (set @assertions (+ @assertions 1))
0
      (set __reference (eval (car margs)))
0
      (set __actual (eval (car (cdr margs))))
0
@@ -110,7 +110,7 @@
0
              (set @failures (+ @failures 1)))
0
      nil)
0
 
0
-(macro assert_not_equal
0
+(macro-0 assert_not_equal
0
      (set @assertions (+ @assertions 1))
0
      (set __reference (eval (car margs)))
0
      (set __actual (eval (car (cdr margs))))
0
@@ -119,7 +119,7 @@
0
              (set @failures (+ @failures 1)))
0
      nil)
0
 
0
-(macro assert_greater_than
0
+(macro-0 assert_greater_than
0
      (set @assertions (+ @assertions 1))
0
      (set __reference (eval (car margs)))
0
      (set __actual (eval (car (cdr margs))))
0
@@ -128,7 +128,7 @@
0
              (set @failures (+ @failures 1)))
0
      nil)
0
 
0
-(macro assert_less_than
0
+(macro-0 assert_less_than
0
      (set @assertions (+ @assertions 1))
0
      (set __reference (eval (car margs)))
0
      (set __actual (eval (car (cdr margs))))
0
@@ -137,7 +137,7 @@
0
              (set @failures (+ @failures 1)))
0
      nil)
0
 
0
-(macro assert_throws
0
+(macro-0 assert_throws
0
      (set @assertions (+ @assertions 1))
0
      (set __desired (eval (car margs)))
0
      (set __block (cdr margs))
0
@@ -155,7 +155,7 @@
0
               (set @failures (+ @failures 1))))
0
      nil)
0
 
0
-(macro assert_in_delta
0
+(macro-0 assert_in_delta
0
      (set @assertions (+ @assertions 1))
0
      (set __reference (eval (car margs)))
0
      (set __actual (eval (car (cdr (margs)))))
0
@@ -166,7 +166,7 @@
0
          (set @failures (+ @failures 1)))
0
      nil)
0
 
0
-(macro assert_true
0
+(macro-0 assert_true
0
      (set @assertions (+ @assertions 1))
0
      (set __actual (eval (car margs)))
0
      (unless __actual
0
@@ -174,7 +174,7 @@
0
              (set @failures (+ @failures 1)))
0
      nil)
0
 
0
-(macro assert_false
0
+(macro-0 assert_false
0
      (set @assertions (+ @assertions 1))
0
      (set __actual (eval (car margs)))
0
      (if __actual
...
1874
1875
1876
 
1877
1878
1879
...
1874
1875
1876
1877
1878
1879
1880
0
@@ -1874,6 +1874,7 @@ void load_builtins(NuSymbolTable *symbolTable)
0
     install("def", Nu_function_operator);
0
     install("function", Nu_function_operator);
0
     install("macro", Nu_macro_operator);
0
+ install("macro-0", Nu_macro_operator);
0
     install("progn", Nu_progn_operator);
0
     install("then", Nu_progn_operator);
0
     install("else", Nu_progn_operator);
...
133
134
135
136
 
137
138
 
139
140
 
141
142
143
...
133
134
135
 
136
137
 
138
139
 
140
141
142
143
0
@@ -133,11 +133,11 @@
0
      
0
      (imethod (id) testLoopMacro is
0
           ;; here is a simple macro defining an unending loop
0
- (macro loop (eval (append '(while t) margs)))
0
+ (macro-0 loop (eval (append '(while t) margs)))
0
           ;; here's a macro that decrements a named value
0
- (macro decrement (set (unquote (margs car)) (- (unquote (margs car)) 1)))
0
+ (macro-0 decrement (set (unquote (margs car)) (- (unquote (margs car)) 1)))
0
           ;; here's a macro that increments a named value
0
- (macro increment (set (unquote (margs car)) (+ (unquote (margs car)) 1)))
0
+ (macro-0 increment (set (unquote (margs car)) (+ (unquote (margs car)) 1)))
0
           ;; run the loop, breaking out after 5 iterations
0
           (set count 0)
0
           (set x 10)
...
15
16
17
18
 
19
20
21
...
25
26
27
28
 
29
30
31
...
34
35
36
37
 
38
39
40
...
43
44
45
46
 
47
48
49
...
56
57
58
59
 
60
61
62
...
64
65
66
67
 
68
69
70
...
72
73
74
75
 
76
77
78
...
15
16
17
 
18
19
20
21
...
25
26
27
 
28
29
30
31
...
34
35
36
 
37
38
39
40
...
43
44
45
 
46
47
48
49
...
56
57
58
 
59
60
61
62
...
64
65
66
 
67
68
69
70
...
72
73
74
 
75
76
77
78
0
@@ -15,7 +15,7 @@
0
      ;; recursive macro test case done wrong.
0
      ;; because x is not a gensym it keeps getting redefined in the recursive descent
0
      (imethod (id) testBrokenFactorialMacro is
0
- (macro mfact
0
+ (macro-0 mfact
0
                (set x (eval (car margs)))
0
                (if (== x 0)
0
                    (then 1)
0
@@ -25,7 +25,7 @@
0
      ;; recursive macro test case done right.
0
      ;; names prefixed with the "__" sigil are gensyms.
0
      (imethod (id) testFactorialMacro is
0
- (macro mfact
0
+ (macro-0 mfact
0
                (set __x (eval (car margs)))
0
                (if (== __x 0)
0
                    (then 1)
0
@@ -34,7 +34,7 @@
0
      
0
      ;; test string interpolation of gensyms
0
      (imethod (id) testGensymInterpolation is
0
- (macro interpolateGensym
0
+ (macro-0 interpolateGensym
0
                (set __x 123)
0
                (set __y 456)
0
                "you got #{__x} and #{__y}")
0
@@ -43,7 +43,7 @@
0
      ;; test some macro implementation details
0
      (imethod (id) testMacroImplementation is
0
           (set s (NuSymbolTable sharedSymbolTable))
0
- (macro forty (set __x 22) (set __y (+ __x 18)))
0
+ (macro-0 forty (set __x 22) (set __y (+ __x 18)))
0
           (set newBody (send forty body:(send forty body) withGensymPrefix:"g999" symbolTable:s))
0
           (assert_equal "((set g999__x 22) (set g999__y (+ g999__x 18)))" (newBody stringValue)))
0
      
0
@@ -56,7 +56,7 @@
0
                (newName appendString:":")
0
                newName)
0
           
0
- (macro reader
0
+ (macro-0 reader
0
                (set __name ((car margs) stringValue))
0
                (_class addInstanceVariable:__name
0
                        signature:"@")
0
@@ -64,7 +64,7 @@
0
                        signature:"@@:"
0
                        body:(do () (self valueForIvar:__name))))
0
           
0
- (macro writer
0
+ (macro-0 writer
0
                (set __name ((car margs) stringValue))
0
                (_class addInstanceVariable:__name
0
                        signature:"@")
0
@@ -72,7 +72,7 @@
0
                        signature:"v@:@"
0
                        body:(do (new) (self setValue:new forIvar:__name))))
0
           
0
- (macro accessor
0
+ (macro-0 accessor
0
                (set __name ((car margs) stringValue))
0
                (_class addInstanceVariable:__name
0
                        signature:"@")
...
51
52
53
 
54
55
56
...
51
52
53
54
55
56
57
0
@@ -51,6 +51,7 @@ END)))
0
           '(("void" "v" 400)
0
             ("id" "@" 400)
0
             ("int" "i" 400)
0
+ ("BOOL" "C" 20)
0
             ("float" "f" 100)
0
             ("double" "d" 100)
0
             ("CGRect" "{_CGRect={_CGPoint=ff}{_CGSize=ff}}" 20)

Comments

    No one has commented yet.