Reorder parsing so calls get properly parsed inside expressions
This commit is contained in:
parent
4011e3b0db
commit
2c529c368a
1 changed files with 22 additions and 22 deletions
|
@ -105,27 +105,7 @@ parser's debug output.")
|
|||
left))
|
||||
|
||||
(define-syntax-matcher expression ()
|
||||
(match-syntax call))
|
||||
|
||||
(define-syntax-matcher arglist (arguments)
|
||||
(setf arguments (list (match-syntax expression)))
|
||||
(loop :while (match-token 'token-comma)
|
||||
:do (push (match-syntax expression) arguments))
|
||||
(nreverse arguments))
|
||||
|
||||
(define-syntax-matcher call (name arguments)
|
||||
(setf name (match-syntax equality))
|
||||
(cond ((and (typep name 'token-name)
|
||||
(match-token 'token-open-paren))
|
||||
(setf arguments (match-syntax arglist))
|
||||
(consume-token 'token-close-paren
|
||||
"Close parenthesis ')' is required to end function call argument list.")
|
||||
(make-instance 'node-call
|
||||
:source *syntax-source*
|
||||
:comment *token-comment*
|
||||
:callee (transform name 'asm-function)
|
||||
:arguments arguments))
|
||||
(t name)))
|
||||
(match-syntax equality))
|
||||
|
||||
(define-binary-expr-matcher equality comparison
|
||||
(token-equal-equal node-expr-test-equal)
|
||||
|
@ -153,7 +133,27 @@ parser's debug output.")
|
|||
:comment *token-comment*
|
||||
:operator-token (previous-token)
|
||||
:operand (match-syntax primary))
|
||||
(match-syntax primary))))
|
||||
(match-syntax call))))
|
||||
|
||||
(define-syntax-matcher arglist (arguments)
|
||||
(setf arguments (list (match-syntax expression)))
|
||||
(loop :while (match-token 'token-comma)
|
||||
:do (push (match-syntax expression) arguments))
|
||||
(nreverse arguments))
|
||||
|
||||
(define-syntax-matcher call (name arguments)
|
||||
(setf name (match-syntax primary))
|
||||
(cond ((and (typep name 'token-name)
|
||||
(match-token 'token-open-paren))
|
||||
(setf arguments (match-syntax arglist))
|
||||
(consume-token 'token-close-paren
|
||||
"Close parenthesis ')' is required to end function call argument list.")
|
||||
(make-instance 'node-call
|
||||
:source *syntax-source*
|
||||
:comment *token-comment*
|
||||
:callee (transform name 'asm-function)
|
||||
:arguments arguments))
|
||||
(t name)))
|
||||
|
||||
(define-syntax-matcher primary ()
|
||||
(cond ((or (match-token 'token-name)
|
||||
|
|
Loading…
Add table
Reference in a new issue