Renamed "nested-expression" syntax to match docs

This commit is contained in:
William J. Bowman 2016-01-14 15:20:39 -05:00
parent c7aefdb032
commit d613b53700
No known key found for this signature in database
GPG Key ID: DDD48D26958F0D1A

View File

@ -147,19 +147,19 @@
#:attr constructor-name #:attr constructor-name
(format-id #'x "~a-~a" (lang-name) #'x))) (format-id #'x "~a-~a" (lang-name) #'x)))
;; A nested-expression can appear as the argument to a terminal in ;; A terminal-args can appear as the argument to a terminal in
;; an expression, or as a sub-expression in a nested-expression. ;; an expression, or as a sub-expression in a terminal-args.
;; Each nested-expression export args, a list of types the ;; Each terminal-args export args, a list of types the
;; nested-expression represents and the list of types the non-terminal's ;; terminal-args represents and the list of types the non-terminal's
;; constructor expects in this case. ;; constructor expects in this case.
(define-syntax-class (nested-expression non-terminal-type) (define-syntax-class (terminal-args non-terminal-type)
;; A meta-variable is a nested-expression ;; A meta-variable is a terminal-args
(pattern (pattern
e:meta-variable e:meta-variable
#:attr args #:attr args
(list #'e.type)) (list #'e.type))
;; An identifier is a nested-expression, but is treated as syntax ;; An identifier is a terminal-args, but is treated as syntax
(pattern (pattern
x:id x:id
#:attr args #:attr args
@ -173,14 +173,14 @@
;; We use De-Bruijn indices, so binding positions are removed. ;; We use De-Bruijn indices, so binding positions are removed.
(pattern (pattern
(#:bind x:var-meta-variable . (~var t (nested-expression non-terminal-type))) (#:bind x:var-meta-variable . (~var t (terminal-args non-terminal-type)))
#:attr args #:attr args
(attribute t.args)) (attribute t.args))
;; A nested-expression applied to other nested expressions is a nested-expression ;; A terminal-args applied to other nested expressions is a terminal-args
(pattern (pattern
((~var h (nested-expression non-terminal-type)) ((~var h (terminal-args non-terminal-type))
(~var t (nested-expression non-terminal-type)) ...) (~var t (terminal-args non-terminal-type)) ...)
#:attr args #:attr args
(for/fold ([ls (attribute h.args)]) (for/fold ([ls (attribute h.args)])
([args (attribute t.args)]) ([args (attribute t.args)])
@ -206,9 +206,9 @@
#:attr constr-decl #:attr constr-decl
#`(x.constructor-name : #,non-terminal-type)) #`(x.constructor-name : #,non-terminal-type))
;; A terminal applied to a nested-expression is a valid expression. ;; A terminal applied to a terminal-args is a valid expression.
(pattern (pattern
(x:terminal . (~var c (nested-expression non-terminal-type))) (x:terminal . (~var c (terminal-args non-terminal-type)))
#:attr constr-decl #:attr constr-decl
#`(x.constructor-name : (-> #,@(attribute c.args) #,non-terminal-type)))) #`(x.constructor-name : (-> #,@(attribute c.args) #,non-terminal-type))))