summary refs log tree commit diff stats
path: root/data/ast.yml
blob: b1d55327feb76ae6ff205d10e9b06641676f6453 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#
#
#           The Nimrod Compiler
#        (c) Copyright 2008 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

{
'SymFlag': [          # already 26 flags!
  'sfUsed',           # read access of sym (for warnings) or simply used
  'sfStar',           # symbol has * visibility
  'sfMinus',          # symbol has - visibility
  'sfInInterface',    # symbol is in interface section declared
  'sfFromGeneric',    # symbol is instantiation of a generic; this is needed 
                      # for symbol file generation; such symbols should always
                      # be written into the ROD file
  'sfGlobal',         # symbol is at global scope

  'sfForward',        # symbol is forward directed
  'sfImportc',        # symbol is external; imported
  'sfExportc',        # symbol is exported (under a specified name)
  'sfVolatile',       # variable is volatile
  'sfRegister',       # variable should be placed in a register
  'sfPure',           # object is "pure" that means it has no type-information
  
  'sfResult',         # variable is 'result' in proc
  'sfNoSideEffect',   # proc has no side effects
  'sfMainModule',     # module is the main module
  'sfSystemModule',   # module is the system module
  'sfNoReturn',       # proc never returns (an exit proc)
  'sfAddrTaken',      # the variable's address is taken (ex- or implicitely)
  'sfCompilerProc',   # proc is a compiler proc, that is a C proc that is
                      # needed for the code generator
  'sfCppMethod',      # proc is a C++ method (not implemented yet)
  'sfDiscriminant',   # field is a discriminant in a record/object
  'sfDeprecated',     # symbol is deprecated
  'sfInClosure',      # variable is accessed by a closure
  'sfTypeCheck',      # wether macro parameters should be type checked
  'sfCompileTime',    # proc can be evaluated at compile time
  'sfThreadVar',      # variable is a thread variable
  'sfMerge',          # proc can be merged with itself
  'sfDeadCodeElim',   # dead code elimination for the module is turned on
],

'TypeFlag': [
  'tfVarargs',        # procedure has C styled varargs
  'tfFinal',          # is the object final?
  'tfAcyclic',        # type is acyclic (for GC optimization)
  'tfEnumHasWholes'   # enum cannot be mapped into a range
],

'TypeKind': [        # order is important!
                     # Don't forget to change hti.nim if you make a change here
  'tyNone', 'tyBool', 'tyChar',
  'tyEmpty', 'tyArrayConstr', 'tyNil', 
  'tyGeneric',
  'tyGenericInst', # instantiated generic type
  'tyGenericParam',
  'tyEnum',
  'tyAnyEnum',
  'tyArray',
  'tyObject',
  'tyTuple',
  'tySet',
  'tyRange',
  'tyPtr', 'tyRef',
  'tyVar',
  'tySequence',
  'tyProc',
  'tyPointer', 'tyOpenArray',
  'tyString', 'tyCString', 'tyForward',
  # numerical types:
  'tyInt', 'tyInt8', 'tyInt16', 'tyInt32', 'tyInt64', # signed integers
  'tyFloat', 'tyFloat32', 'tyFloat64', 'tyFloat128'
],

'NodeFlag': [ # keep this number under 16 for performance reasons!
  'nfNone',
  'nfBase2', # nfBase10 is default, so not needed
  'nfBase8',
  'nfBase16',
  'nfAllConst', # used to mark complex expressions constant
  'nfTransf',   # node has been transformed
  'nfSem',      # node has been checked for semantics
],

'NodeKind': [  # these are pure nodes
  # order is extremely important, because ranges are used to check whether
  # a node belongs to a certain class
  'nkNone',               # unknown node kind: indicates an error

  # Expressions:
  # Atoms:
  'nkEmpty',              # the node is empty
  'nkIdent',              # node is an identifier
  'nkSym',                # node is a symbol
  'nkType',               # node is used for its typ field

  'nkCharLit',            # a character literal ''

  'nkIntLit',             # an integer literal
  'nkInt8Lit',
  'nkInt16Lit',
  'nkInt32Lit',
  'nkInt64Lit',
  'nkFloatLit',           # a floating point literal
  'nkFloat32Lit',
  'nkFloat64Lit',
  'nkStrLit',             # a string literal ""
  'nkRStrLit',            # a raw string literal r""
  'nkTripleStrLit',       # a triple string literal """
  'nkMetaNode',           # difficult to explan; represents itself
                          # (used for macros)
  'nkNilLit',             # the nil literal
  # end of atoms
  'nkDotCall',            # used to temporarily flag a nkCall node; this is used
                          # for transforming ``s.len`` to ``len(s)``
  'nkCommand',            # a call like ``p 2, 4`` without parenthesis
  'nkCall',               # a call like p(x, y) or an operation like +(a, b)
  'nkGenericCall',        # a call with given type parameters
  'nkExplicitTypeListCall', # a call with given explicit typelist
  'nkExprEqExpr',         # a named parameter with equals: ''expr = expr''
  'nkExprColonExpr',      # a named parameter with colon: ''expr: expr''
  'nkIdentDefs',          # a definition like `a, b: typeDesc = expr`
                          # either typeDesc or expr may be nil; used in
                          # formal parameters, var statements, etc.
  'nkVarTuple',           # a ``var (a, b) = expr`` construct
  'nkInfix',              # a call like (a + b)
  'nkPrefix',             # a call like !a
  'nkPostfix',            # something like a! (also used for visibility)
  'nkPar',                # syntactic (); may be a tuple constructor
  'nkCurly',              # syntactic {}
  'nkBracket',            # syntactic []
  'nkBracketExpr',        # an expression like a[i..j, k]
  'nkPragmaExpr',         # an expression like a{.pragmas.}
  'nkRange',              # an expression like i..j
  'nkDotExpr',            # a.b
  'nkCheckedFieldExpr',   # a.b, but b is a field that needs to be checked
  'nkDerefExpr',          # a^
  'nkIfExpr',             # if as an expression
  'nkElifExpr',
  'nkElseExpr',
  'nkLambda',             # lambda expression
  'nkAccQuoted',          # `a` as a node
  'nkHeaderQuoted',       # `a(x: int)` as a node

  'nkTableConstr',        # a table constructor {expr: expr}
  'nkQualified',          # describes a.b for qualified identifiers
  'nkHiddenStdConv',      # an implicit standard type conversion
  'nkHiddenSubConv',      # an implicit type conversion from a subtype
                          # to a supertype
  'nkHiddenCallConv',     # an implicit type conversion via a type converter
  'nkConv',               # a type conversion
  'nkCast',               # a type cast
  'nkAddr',               # a addr expression
  'nkHiddenAddr',         # implicit address operator
  'nkHiddenDeref',        # implicit ^ operator
  'nkObjDownConv',        # down conversion between object types
  'nkObjUpConv',          # up conversion between object types
  'nkChckRangeF',         # range check for floats
  'nkChckRange64',        # range check for 64 bit ints
  'nkChckRange',          # range check for ints
  'nkStringToCString',    # string to cstring
  'nkCStringToString',    # cstring to string
  'nkPassAsOpenArray',    # thing is passed as an open array
  # end of expressions

  'nkAsgn',               # a = b
  'nkFastAsgn',           # internal node for a fast ``a = b`` (no string copy) 
  'nkDefaultTypeParam',   # `ident = typeDesc` in generic parameters
  'nkGenericParams',      # generic parameters
  'nkFormalParams',       # formal parameters
  'nkOfInherit',          # inherited from symbol

  'nkModule',             # the syntax tree of a module
  'nkProcDef',            # a proc
  'nkConverterDef',       # a converter
  'nkMacroDef',           # a macro
  'nkTemplateDef',        # a template
  'nkIteratorDef',        # an iterator

  'nkOfBranch',           # used inside case statements for (cond, action)-pairs
  'nkElifBranch',         # used in if statements
  'nkExceptBranch',       # an except section
  'nkElse',               # an else part
  'nkMacroStmt',          # a macro statement
  'nkAsmStmt',            # an assembler block
  'nkPragma',             # a pragma statement
  'nkIfStmt',             # an if statement
  'nkWhenStmt',           # a when statement
  'nkForStmt',            # a for statement
  'nkWhileStmt',          # a while statement
  'nkCaseStmt',           # a case statement
  'nkVarSection',         # a var section
  'nkConstSection',       # a const section
  'nkConstDef',           # a const definition
  'nkTypeSection',        # a type section (consists of type definitions)
  'nkTypeDef',            # a type definition
  'nkYieldStmt',          # the yield statement as a tree
  'nkTryStmt',            # a try statement
  'nkFinally',            # a finally section
  'nkRaiseStmt',          # a raise statement
  'nkReturnStmt',         # a return statement
  'nkBreakStmt',          # a break statement
  'nkContinueStmt',       # a continue statement
  'nkBlockStmt',          # a block statement
  'nkDiscardStmt',        # a discard statement
  'nkStmtList',           # a list of statements
  'nkImportStmt',         # an import statement
  'nkFromStmt',           # a from * import statement
  'nkImportAs',           # an `import xyx as abc` section
  'nkIncludeStmt',        # an include statement
  'nkAccessStmt',         # used internally for iterators
  'nkCommentStmt',        # a comment statement
  'nkStmtListExpr',       # a statement list followed by an expr; this is used
                          # to allow powerful multi-line templates
  'nkBlockExpr',          # a statement block ending in an expr; this is used
                          # to allowe powerful multi-line templates that open a
                          # temporary scope
  'nkStmtListType',       # a statement list ending in a type; for macros
  'nkBlockType',          # a statement block ending in a type; for macros
  'nkVm',                 # indicates a virtual instruction; integer field is
                          # used for the concrete opcode

  # types as syntactic trees:
  'nkTypeOfExpr',
  'nkObjectTy',
  'nkTupleTy',
  'nkRecList',            # list of record/object parts
  'nkRecCase',            # case section of record/object
  'nkRecWhen',            # when section of record/object
  'nkRefTy',
  'nkPtrTy',
  'nkVarTy',
  'nkProcTy',
  'nkEnumTy',
  'nkEnumFieldDef',       # `ident = expr` in an enumeration
  'nkReturnToken',        # token used for interpretation
],

'SymKind': [
  # the different symbols (start with the prefix sk);
  # order is important for the documentation generator!
  'skUnknownSym',         # unknown symbol: used for parsing assembler blocks
  'skConditional',        # symbol for the preprocessor (may become obsolete)
  'skDynLib',             # symbol represents a dynamic library; this is used
                          # internally; it does not exist in Nimrod code
  'skParam',              # a parameter
  'skTypeParam',          # a type parameter; example: proc x[T]() <- `T`
  'skTemp',               # a temporary variable (introduced by compiler)
  'skType',               # a type
  'skConst',              # a constant
  'skVar',                # a variable
  'skProc',               # a proc
  'skIterator',           # an iterator
  'skConverter',          # a type converter
  'skMacro',              # a macro
  'skTemplate',           # a template
  'skField',              # a field in a record or object
  'skEnumField',          # an identifier in an enum
  'skForVar',             # a for loop variable
  'skModule',             # module identifier
  'skLabel',              # a label (for block statement)
  'skStub'                # symbol is a stub and not yet loaded from the ROD
                          # file (it is loaded on demand, which may mean: never)
]
}