diff --git a/collects/honu/core/main.rkt b/collects/honu/core/main.rkt index 46924cbc4e..da786ede04 100644 --- a/collects/honu/core/main.rkt +++ b/collects/honu/core/main.rkt @@ -17,6 +17,7 @@ [honu-+ +] [honu-- -] [honu-* *] [honu-/ /] [honu-^ ^] + [honu-dot |.|] [honu-cons ::] [honu-and and] [honu-or or] diff --git a/collects/honu/core/private/honu2.rkt b/collects/honu/core/private/honu2.rkt index eef446ece3..52dc4cfe05 100644 --- a/collects/honu/core/private/honu2.rkt +++ b/collects/honu/core/private/honu2.rkt @@ -86,6 +86,18 @@ [right right]) #'(operator left right)))))) +(provide honu-dot) +(define-honu-operator/syntax honu-dot 10000 'left + (lambda (left right) + (with-syntax ([left left] + [right right]) + #'(let ([left* left] + [right* right]) + (cond + [(list? left*) + (list-ref left* right*)] + [else (error 'dot "don't know how to deal with ~a and ~a" left* right*)]))))) + (define-binary-operator honu-+ 1 'left +) (define-binary-operator honu-- 1 'left -) (define-binary-operator honu-* 2 'left *) diff --git a/collects/honu/core/private/parse2.rkt b/collects/honu/core/private/parse2.rkt index 8da329072d..796183b070 100644 --- a/collects/honu/core/private/parse2.rkt +++ b/collects/honu/core/private/parse2.rkt @@ -238,12 +238,21 @@ (define body (parse-all #'(stuff ...))) (do-parse #'(rest ...) precedence left body)))] [(#%parens args ...) - (debug "function call ~a\n" left) - (values (left (with-syntax ([current current] - [(parsed-args ...) - (parse-comma-expression #'(args ...)) ]) - #'(current parsed-args ...))) - #'(rest ...)) + (if current + (let () + (debug "function call ~a\n" left) + (values (left (with-syntax ([current current] + [(parsed-args ...) + (parse-comma-expression #'(args ...)) ]) + #'(current parsed-args ...))) + #'(rest ...))) + (let () + (debug "inner expression ~a\n" #'(args ...)) + (define-values (inner-expression unparsed) (parse #'(args ...))) + (when (not (empty-syntax? unparsed)) + (error 'parse "expression had unparsed elements ~a" unparsed)) + (do-parse #'(rest ...) precedence left inner-expression))) + #; (do-parse #'(rest ...) 0