parse arguments. provide basic math operations

This commit is contained in:
Jon Rafkind 2011-07-18 11:18:42 -06:00
parent 7eedae8f69
commit 3a1dde7f14
4 changed files with 15 additions and 3 deletions

View File

@ -10,6 +10,11 @@
(rename-out [#%dynamic-honu-module-begin #%module-begin]
[honu-function function]
[honu-var var]
[honu-+ +]
[honu-- -]
[honu-* *]
[honu-/ /]
[honu-^ ^]
[literal:honu-= =]
[literal:semicolon |;|]
[literal:#%braces #%braces]

View File

@ -46,3 +46,5 @@
#'(- left right))))
(define-binary-operator honu-* 2 *)
(define-binary-operator honu-/ 2 /)
(define-binary-operator honu-^ 2 expt)

View File

@ -157,8 +157,12 @@
(do-parse #'(rest ...)
0
(lambda (x) x)
(left (with-syntax ([current current])
#'(current args ...))))
(left (with-syntax ([current current]
[(parsed-args ...)
(if (null? (syntax->list #'(args ...)))
'()
(list (parse #'(args ...))))])
#'(current parsed-args ...))))
#;
(error 'parse "function call")]
[else (error 'what "dont know ~a" #'head)])]

View File

@ -22,7 +22,8 @@ function test1(){
test("x = 3", x, 3);
test("y = 2", y, 2);
*/
print(x)
print(x + 2);
print(x ^ 2)
}
test1()