Files
Nim/data/ast.yml
2010-02-26 01:26:16 +01:00

275 lines
12 KiB
YAML
Executable File

#
#
# The Nimrod Compiler
# (c) Copyright 2009 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
{
'SymFlag': [ # already 30 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
'sfSideEffect', # proc may have side effects; cannot prove it has none
'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
'sfProcvar', # proc can be passed to a proc var
'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
'sfBorrow' # proc is borrowed
],
'TypeFlag': [
'tfVarargs', # procedure has C styled varargs
'tfNoSideEffect', # procedure type does not allow side effects
'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', 'tyExpr', 'tyStmt', 'tyTypeDesc',
'tyGenericInvokation', # ``T[a, b]`` for types to invoke
'tyGenericBody', # ``T[a, b, body]`` last parameter is the body
'tyGenericInst', # ``T[a, b, realInstance]`` instantiated generic type
'tyGenericParam', # ``a`` in the example
'tyDistinct',
'tyEnum',
'tyOrdinal',
'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)
'nkCallStrLit', # a call with a string literal
# x"abc" has two sons: nkIdent, nkRStrLit
# x"""abc""" has two sons: nkIdent, nkTripleStrLit
'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
'nkTableConstr', # a table constructor {expr: expr}
'nkBind', # ``bind expr`` node
'nkSymChoice', # symbol choice node
'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)
'nkGenericParams', # generic parameters
'nkFormalParams', # formal parameters
'nkOfInherit', # inherited from symbol
'nkModule', # the syntax tree of a module
'nkProcDef', # a proc
'nkMethodDef', # a method
'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
'nkIncludeStmt', # an include statement
'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
# types as syntactic trees:
'nkTypeOfExpr',
'nkObjectTy',
'nkTupleTy',
'nkRecList', # list of object parts
'nkRecCase', # case section of object
'nkRecWhen', # when section of object
'nkRefTy',
'nkPtrTy',
'nkVarTy',
'nkDistinctTy', # distinct type
'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!
'skUnknown', # unknown symbol: used for parsing assembler blocks
# and first phase symbol lookup in generics
'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
'skGenericParam', # a generic parameter; eq in ``proc x[eq=`==`]()``
'skTemp', # a temporary variable (introduced by compiler)
'skType', # a type
'skConst', # a constant
'skVar', # a variable
'skProc', # a proc
'skMethod', # a method
'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)
]
}