parse arguments. provide basic math operations
This commit is contained in:
parent
7eedae8f69
commit
3a1dde7f14
|
@ -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]
|
||||
|
|
|
@ -46,3 +46,5 @@
|
|||
#'(- left right))))
|
||||
|
||||
(define-binary-operator honu-* 2 *)
|
||||
(define-binary-operator honu-/ 2 /)
|
||||
(define-binary-operator honu-^ 2 expt)
|
||||
|
|
|
@ -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)])]
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user