@@ -21,6 +21,81 @@ namespace lang {
2121
2222// / TreeView provides a statically-typed way to access the members of a TreeRef
2323// / instead of using TK_MATCH
24+ //
25+ // A few notes on types and their aliases:
26+ // - List<T> is really a Tree with kind TK_LIST and elements as subtrees
27+ // - Maybe<T> is really a Tree with kind TK_OPTION that has 0 or 1 subtree of type T
28+ // - Builtin types are: Ident (TK_IDENT), String (TK_STRING)
29+ //
30+ // -- NB: dim_list can only contain Const and Ident trees
31+ // -- NB: dim_list is optional (can be empty)
32+ // Type = TensorType(ScalarType scalar_type, List<Expr> dim_list) TK_TENSOR_TYPE
33+ // Param = Param(Ident name, Type type) TK_PARAM
34+ //
35+ // Def = Def(Ident name, List<Param> params, List<Param> returns, List<Stmt> body) TK_DEF
36+ //
37+ // -- NB: reduction_variables are only filled during semantic analysis
38+ // Stmt = Comprehension(Ident lhs_ident, List<Ident> lhs_indices, TK_COMPREHENSION
39+ // AssignKind assignment, Expr rhs,
40+ // List<WhereClause> range_constraints,
41+ // Option<Equivalent> eqiuvalent_stmt,
42+ // List<Ident> reduction_variables)
43+ //
44+ // WhereClause = Let(Ident name, Expr expr) TK_LET
45+ // | RangeConstraint(Ident name, Expr l, Expr r) TK_RANGE_CONSTRAINT
46+ // | Exists(Expr expr) TK_EXISTS
47+ //
48+ // Equivalent = Equivalent(String name, List<Expr> accesses) TK_EQUIVALENT
49+ //
50+ // Expr = TernaryIf(Expr cond, Expr true_expr, Expr false_expr) TK_IF_EXPR
51+ // | BinOp(Expr lhs, Expr rhs)
52+ // | And TK_AND
53+ // | Or TK_OR
54+ // | Lt '<'
55+ // | Gt '>'
56+ // | Eq TK_EQ
57+ // | Le TK_LE
58+ // | Ge TK_GE
59+ // | Ne TK_NE
60+ // | Add '+'
61+ // | Sub '-'
62+ // | Mul '*'
63+ // | Div '/'
64+ // | UnaryOp(Expr expr)
65+ // | Not '!'
66+ // | USub '-'
67+ // | Const(Number value, ScalarType type) TK_CONST
68+ // | Cast(Expr expr, ScalarType type) TK_CAST
69+ // | Select(Expr base, Number dim) '.'
70+ // -- XXX: Apply is emitted by the parser, and gets desugared into
71+ // -- Access and BuiltIn as part of the Sema pass.
72+ // | Apply(Ident name, List<Expr> args) TK_APPLY
73+ // | Access(Ident name, List<Expr> args) TK_ACCESS
74+ // | BuiltIn(Ident name, List<Expr> args, Type type) TK_BUILT_IN
75+ // -- XXX: yes, Ident is a valid Expr too
76+ // | Ident name TK_IDENT
77+ //
78+ // ScalarType = Int8() TK_INT8
79+ // | Int16() TK_INT16
80+ // | Int32() TK_INT32
81+ // | Int64() TK_INT64
82+ // | UInt8() TK_UINT8
83+ // | UInt16() TK_UINT16
84+ // | UInt32() TK_UINT32
85+ // | UInt64() TK_UINT64
86+ // | Bool() TK_BOOL
87+ // | Float() TK_FLOAT
88+ // | Double() TK_DOUBLE
89+ //
90+ // AssignKind = PlusEq() TK_PLUS_EQ
91+ // | TimesEq() TK_TIMES_EQ
92+ // | MinEq() TK_MIN_EQ
93+ // | MaxEq() TK_MAX_EQ
94+ // | PlusEqB() TK_PLUS_EQ_B
95+ // | TimesEqB() TK_TIMES_EQ_B
96+ // | MinEqB() TK_MIN_EQ_B
97+ // | MaxEqB() TK_MAX_EQ_B
98+
2499struct TreeView {
25100 explicit TreeView (const TreeRef& tree_) : tree_(tree_) {}
26101 TreeRef tree () const {
0 commit comments