[honu] add dot as an operator. parse parenthesized expressions
This commit is contained in:
parent
c8695ddf2e
commit
17f1ac53be
|
@ -17,6 +17,7 @@
|
||||||
[honu-+ +] [honu-- -]
|
[honu-+ +] [honu-- -]
|
||||||
[honu-* *] [honu-/ /]
|
[honu-* *] [honu-/ /]
|
||||||
[honu-^ ^]
|
[honu-^ ^]
|
||||||
|
[honu-dot |.|]
|
||||||
[honu-cons ::]
|
[honu-cons ::]
|
||||||
[honu-and and]
|
[honu-and and]
|
||||||
[honu-or or]
|
[honu-or or]
|
||||||
|
|
|
@ -86,6 +86,18 @@
|
||||||
[right right])
|
[right right])
|
||||||
#'(operator left 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-- 1 'left -)
|
(define-binary-operator honu-- 1 'left -)
|
||||||
(define-binary-operator honu-* 2 'left *)
|
(define-binary-operator honu-* 2 'left *)
|
||||||
|
|
|
@ -238,12 +238,21 @@
|
||||||
(define body (parse-all #'(stuff ...)))
|
(define body (parse-all #'(stuff ...)))
|
||||||
(do-parse #'(rest ...) precedence left body)))]
|
(do-parse #'(rest ...) precedence left body)))]
|
||||||
[(#%parens args ...)
|
[(#%parens args ...)
|
||||||
|
(if current
|
||||||
|
(let ()
|
||||||
(debug "function call ~a\n" left)
|
(debug "function call ~a\n" left)
|
||||||
(values (left (with-syntax ([current current]
|
(values (left (with-syntax ([current current]
|
||||||
[(parsed-args ...)
|
[(parsed-args ...)
|
||||||
(parse-comma-expression #'(args ...)) ])
|
(parse-comma-expression #'(args ...)) ])
|
||||||
#'(current parsed-args ...)))
|
#'(current parsed-args ...)))
|
||||||
#'(rest ...))
|
#'(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 ...)
|
(do-parse #'(rest ...)
|
||||||
0
|
0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user