From 4e987026148fe65c323afbc93cd560c07bf06b3f Mon Sep 17 00:00:00 2001 From: Yale AI Dept Date: Wed, 14 Jul 1993 13:08:00 -0500 Subject: Import to github. --- ast/type-structs.scm | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 ast/type-structs.scm (limited to 'ast/type-structs.scm') diff --git a/ast/type-structs.scm b/ast/type-structs.scm new file mode 100644 index 0000000..0ba4705 --- /dev/null +++ b/ast/type-structs.scm @@ -0,0 +1,159 @@ +;;; File: ast/type-structs Author: John + +;;; This contains AST structures for the type-related declarations, +;;; including `data', `class', `instance', and `type' decls. Basic type +;;; syntax is also defined here. + +;;; Structures declared here: +;;; type type-var type-con context signature synonym-decl +;;; data-decl class-decl instance-decl + + +;;; -> +;;; -> -> *** +;;; -> ... tycon +;;; +;;; -> tyvar +;;; -> tycon +;;; -> () *** +;;; -> ( ) grouping syntax +;;; -> ( , ... , ) *** +;;; -> [ ] *** +;;; *** Special cases + +;;; Type with no context - either a tyvar or a constructor +(define-struct type + (include ast-node)) + +(define-struct tyvar + (include type) + (predicate tyvar?) + (slots + (name (type symbol)))) + +(define-struct tycon + (include type) + (predicate tycon?) + (slots + (name (type symbol)) + (def (type def)) + (args (type (list type))))) + +;;; -> [ =>] +;;; +;;; -> +;;; -> ( , ... , ) + +;;; A single class, variable pair +(define-struct context + (include ast-node) + (slots + (class (type class-ref)) + (tyvar (type symbol)))) + + +;;; Type + context +(define-struct signature + (include type) + (slots + (context (type (list context))) + (type (type type)))) + + +;;; Major type declarations. Note: no explicit structures for +;;; or are needed - these are just special cases of type. + +;;; -> type = +;;; +;;; -> ... + +(define-struct synonym-decl + (include ast-node) + (slots + (simple (type type)) + (body (type type)))) + + +;;; -> data [ => ] = +;;; [deriving | ( , ... ) ] +;;; +;;; -> | ... | +;;; + +(define-struct data-decl + (include ast-node) + (slots + (context (type (list context))) + (simple (type type)) + (constrs (type (list constr))) + (deriving (type (list class-ref))) + (annotations (type (list annotation-value))))) + +;;; -> ... +;;; -> + +(define-struct constr + (include ast-node) + (slots + (constructor (type con-ref)) ; this con-ref has an infix? flag. + (types (type (list (tuple type (list annotation-value))))))) + + +;;; -> class [ => ] [where { [;] } ] +;;; +;;; -> [ ; ] [ ] +;;; +;;; -> ; ... ; + +(define-struct class-decl + (include ast-node) + (slots + (class (type class-ref)) + (super-classes (type (list context))) + (class-var (type symbol)) ; name of type var for this class in decls + (decls (type (list decl))))) ; + + +;;; -> instance [ =>] +;;; [where { [;] } ] +;;; +;;; -> +;;; -> ( ... ) +;;; -> ( , ... , ) +;;; -> () +;;; -> [ ] +;;; -> ( -> ) +;;; + +(define-struct instance-decl + (include ast-node) + (slots + ;; + (context (type (list context))) + ;; + (class (type class-ref)) + ;; + (simple (type type)) + ;; + (decls (type (list valdef))) + )) + + + +;;; -> default +;;; -> default ( , ... , ) + +(define-struct default-decl + (include ast-node) + (slots + (types (type (list type))))) + + +;;; -> + +(define-struct class-ref + (include ast-node) + (slots + (name (type symbol)) + (class (type def)))) + -- cgit v1.2.3