parse multiple call arguments
This commit is contained in:
parent
10e79ba2ec
commit
d4ea3b5d79
|
@ -70,6 +70,13 @@
|
|||
(debug "Semicolon? ~a ~a\n" what is)
|
||||
is)
|
||||
|
||||
(define (comma? what)
|
||||
(define-literal-set check (honu-comma))
|
||||
(define is (and (identifier? what)
|
||||
((literal-set->predicate check) what)))
|
||||
(debug "Comma? ~a ~a\n" what is)
|
||||
is)
|
||||
|
||||
(define-literal-set argument-stuff [honu-comma])
|
||||
|
||||
(define (parse-arguments arguments)
|
||||
|
@ -88,6 +95,18 @@
|
|||
(loop (cons #'name out) #'())]
|
||||
[() (reverse out)])))
|
||||
|
||||
(define (parse-call-arguments arguments)
|
||||
(if (null? (syntax->list arguments))
|
||||
'()
|
||||
(let loop ([used '()]
|
||||
[rest arguments])
|
||||
(if (empty-syntax? rest)
|
||||
(reverse used)
|
||||
(let-values ([(parsed unparsed)
|
||||
(parse rest)])
|
||||
(loop (cons parsed used)
|
||||
unparsed))))))
|
||||
|
||||
;; 1 + 1
|
||||
;; ^
|
||||
;; left: identity
|
||||
|
@ -162,6 +181,9 @@
|
|||
0
|
||||
(lambda (x) x)
|
||||
(left current)))]
|
||||
[(comma? #'head)
|
||||
(values (left current)
|
||||
#'(rest ...))]
|
||||
[(semicolon? #'head)
|
||||
(values (left current)
|
||||
#'(rest ...))
|
||||
|
@ -195,9 +217,7 @@
|
|||
(debug "function call ~a\n" left)
|
||||
(values (left (with-syntax ([current current]
|
||||
[(parsed-args ...)
|
||||
(if (null? (syntax->list #'(args ...)))
|
||||
'()
|
||||
(list (parse-all #'(args ...))))])
|
||||
(parse-call-arguments #'(args ...)) ])
|
||||
#'(current parsed-args ...)))
|
||||
#'(rest ...))
|
||||
#;
|
||||
|
|
|
@ -26,11 +26,12 @@ test1(){
|
|||
print(x ^ 2)
|
||||
}
|
||||
|
||||
val test2(val x){
|
||||
print(x)
|
||||
val test2(val x, val y){
|
||||
print(x);
|
||||
print(y)
|
||||
}
|
||||
|
||||
// test1();
|
||||
test2(5);
|
||||
test2(5, 9);
|
||||
|
||||
function(z){ print(z) }(12)
|
||||
// function(z){ print(z) }(12)
|
||||
|
|
Loading…
Reference in New Issue
Block a user