pynestml.symbols package
Submodules
pynestml.symbols.boolean_type_symbol module
- class pynestml.symbols.boolean_type_symbol.BooleanTypeSymbol
Bases:
pynestml.symbols.type_symbol.TypeSymbol
- is_castable_to(_other_type)
Test castability of this SymbolType to _other_type.
The implementation of this function in TypeSymbol takes care of casting to `TemplateTypeSymbol`s, hence, any children that override this function need to always call the parent implementation, before doing their own castability checks. :return: True if castable, otherwise False :rtype: bool
- is_numeric()
Returns whether this symbol represents a numeric type. :return: True if numeric, otherwise False. :rtype: bool
- is_primitive()
Returns whether this symbol represents a primitive type. :return: true if primitive, otherwise false. :rtype: bool
- negate()
- print_nestml_type()
pynestml.symbols.error_type_symbol module
- class pynestml.symbols.error_type_symbol.ErrorTypeSymbol
Bases:
pynestml.symbols.type_symbol.TypeSymbol
Originally intended to only be a ‘Null type’ for the TypeSymbol hierarchy, it is now also a device to communicate errors and warnings back to a place where they can be properly logged (we cant do that here because we don’t know t he source-position). Thought about using Exceptions but that would lead to loads of code duplication in the visitors responsible for expression typing. In the end a little bit of ugliness here saves us a lot throughout the project -ptraeder
p.s. could possibly resolve this by associating type-symbol objects with expressions they belong to. The field for that is already present from Symbol and we already instantiate types for every expression anyways
- is_castable_to(_other_type)
Test castability of this SymbolType to _other_type.
The implementation of this function in TypeSymbol takes care of casting to `TemplateTypeSymbol`s, hence, any children that override this function need to always call the parent implementation, before doing their own castability checks. :return: True if castable, otherwise False :rtype: bool
- is_numeric()
Returns whether this symbol represents a numeric type. :return: True if numeric, otherwise False. :rtype: bool
- is_primitive()
Returns whether this symbol represents a primitive type. :return: true if primitive, otherwise false. :rtype: bool
- negate()
- print_nestml_type()
pynestml.symbols.function_symbol module
- class pynestml.symbols.function_symbol.FunctionSymbol(name, param_types, return_type, element_reference, scope=None, is_predefined=False)
Bases:
pynestml.symbols.symbol.Symbol
This class is used to store a single function symbol, e.g. the definition of the function max. .. attribute:: param_types
A list of the types of parameters.
- type
list(TypeSymbol)
- return_type
The type of the returned value.
- Type
type_symbol
- add_parameter_type(new_type)
Adds the handed over type to the list of argument types. :param new_type: a single type symbol :type new_type: type_symbol
- equals(_other=None)
Compares the handed over instance of function symbol to this one and returns true, if the they are equal. :param _other: a different function symbol :type _other: FunctionSymbol :return: True if equal, otherwise False. :rtype: bool
- get_parameter_types()
Returns a list of all parameter types. :return: a list of parameter types. :rtype: list(TypeSymbol)
- get_return_type()
Returns the return type of this function symbol :return: a single type symbol. :rtype: type_symbol
- print_symbol()
Returns a string representation of this symbol.
- set_return_type(new_type)
Sets the return type to the handed over one. :param new_type: a single type symbol :type new_type: type_symbol
pynestml.symbols.integer_type_symbol module
- class pynestml.symbols.integer_type_symbol.IntegerTypeSymbol
Bases:
pynestml.symbols.type_symbol.TypeSymbol
- is_castable_to(_other_type)
Test castability of this SymbolType to _other_type.
The implementation of this function in TypeSymbol takes care of casting to `TemplateTypeSymbol`s, hence, any children that override this function need to always call the parent implementation, before doing their own castability checks. :return: True if castable, otherwise False :rtype: bool
- is_numeric()
Returns whether this symbol represents a numeric type. :return: True if numeric, otherwise False. :rtype: bool
- is_primitive()
Returns whether this symbol represents a primitive type. :return: true if primitive, otherwise false. :rtype: bool
- print_nestml_type()
pynestml.symbols.nest_time_type_symbol module
- class pynestml.symbols.nest_time_type_symbol.NESTTimeTypeSymbol
Bases:
pynestml.symbols.type_symbol.TypeSymbol
- is_castable_to(_other_type)
Test castability of this SymbolType to _other_type.
The implementation of this function in TypeSymbol takes care of casting to `TemplateTypeSymbol`s, hence, any children that override this function need to always call the parent implementation, before doing their own castability checks. :return: True if castable, otherwise False :rtype: bool
- is_numeric()
Returns whether this symbol represents a numeric type. :return: True if numeric, otherwise False. :rtype: bool
- is_primitive()
Returns whether this symbol represents a primitive type. :return: true if primitive, otherwise false. :rtype: bool
- print_nestml_type()
pynestml.symbols.predefined_functions module
pynestml.symbols.predefined_types module
pynestml.symbols.predefined_units module
pynestml.symbols.predefined_variables module
pynestml.symbols.real_type_symbol module
- class pynestml.symbols.real_type_symbol.RealTypeSymbol
Bases:
pynestml.symbols.type_symbol.TypeSymbol
- is_castable_to(_other_type)
Test castability of this SymbolType to _other_type.
The implementation of this function in TypeSymbol takes care of casting to `TemplateTypeSymbol`s, hence, any children that override this function need to always call the parent implementation, before doing their own castability checks. :return: True if castable, otherwise False :rtype: bool
- is_numeric()
Returns whether this symbol represents a numeric type. :return: True if numeric, otherwise False. :rtype: bool
- is_primitive()
Returns whether this symbol represents a primitive type. :return: true if primitive, otherwise false. :rtype: bool
- print_nestml_type()
pynestml.symbols.string_type_symbol module
- class pynestml.symbols.string_type_symbol.StringTypeSymbol
Bases:
pynestml.symbols.type_symbol.TypeSymbol
- is_castable_to(_other_type)
Test castability of this SymbolType to _other_type.
The implementation of this function in TypeSymbol takes care of casting to `TemplateTypeSymbol`s, hence, any children that override this function need to always call the parent implementation, before doing their own castability checks. :return: True if castable, otherwise False :rtype: bool
- is_numeric()
Returns whether this symbol represents a numeric type. :return: True if numeric, otherwise False. :rtype: bool
- is_primitive()
Returns whether this symbol represents a primitive type. :return: true if primitive, otherwise false. :rtype: bool
- print_nestml_type()
pynestml.symbols.symbol module
- class pynestml.symbols.symbol.Symbol(element_reference, scope, name, symbol_kind)
Bases:
object
This abstract class represents a super-class for all concrete symbols as stored in a symbol table. .. attribute:: element_reference
A reference to an AST node which defined this symbol. This has to be in the super-class, since variables as well as functions can be user defined.
- type
- scope
The scope in which this element is stored in.
- symbol_kind
The type of this symbol, i.e., either variable, function or type.
- Type
- get_comment()
Returns the comment of this symbol. :return: the comment. :rtype: list(str)
- get_corresponding_scope()
Returns the scope in which this symbol is embedded in. :return: a scope object. :rtype: Scope
- get_referenced_object()
Returns the referenced object. :return: the referenced object. :rtype: ASTObject
- get_symbol_kind()
Returns the type of this symbol. :return: the type of this symbol. :rtype: SymbolKind
- has_comment()
Indicates whether this symbols is commented. :return: True if comment is stored, otherwise False. :rtype: bool
- is_defined_before(source_position)
For a handed over source position, this method checks if this symbol has been defined before the handed over position. :param source_position: the position of a different element. :type source_position: ast_source_location :return: True, if defined before or at the source position, otherwise False. :rtype: bool
- abstract print_symbol()
Returns a string representation of this symbol.
- set_comment(comment)
Updates the comment of this element. :param comment: a list comment lines. :type comment: list(str)
pynestml.symbols.template_type_symbol module
- class pynestml.symbols.template_type_symbol.TemplateTypeSymbol(i)
Bases:
pynestml.symbols.type_symbol.TypeSymbol
Function type templates for predefined NESTML functions. This allows e.g. functions like max() and min() to have a return type equal to the type of their arguments, regardless of what type the arguments are (integers, meters, nanosiemens…)
Template type symbols are uniquely identified with an integer number i, i.e. TemplateTypeSymbol(n) == TemplateTypeSymbol(m) iff n == m.
- is_castable_to(_other_type)
Test castability of this SymbolType to _other_type.
The implementation of this function in TypeSymbol takes care of casting to `TemplateTypeSymbol`s, hence, any children that override this function need to always call the parent implementation, before doing their own castability checks. :return: True if castable, otherwise False :rtype: bool
- is_numeric()
Returns whether this symbol represents a numeric type. :return: True if numeric, otherwise False. :rtype: bool
- is_primitive()
Returns whether this symbol represents a primitive type. :return: true if primitive, otherwise false. :rtype: bool
- print_nestml_type()
pynestml.symbols.type_symbol module
- class pynestml.symbols.type_symbol.TypeSymbol(name)
Bases:
pynestml.symbols.symbol.Symbol
This class is used to represent a single type symbol which represents the type of a element, e.g., a variable. .. attribute:: is_buffer Indicates whether it is a buffer symbol.
- binary_operation_not_defined_error(_operator, _other)
- differs_only_in_magnitude(other_type)
Indicates whether both type represent the same unit but with different magnitudes. This case is still valid, e.g., mV can be assigned to volt. :param other_type: a type :type other_type: TypeSymbol :return: True if both elements equal or differ in magnitude, otherwise False. :rtype: bool
- equals(other)
Checks if the handed over type symbol object is equal to this (value-wise). :param other: a type symbol object. :type other: Symbol or subclass. :return: True if equal, otherwise False. :rtype: bool
- classmethod inverse_of_unit(other)
- Parameters
other (UnitTypeSymbol) – the unit to invert
- Returns
UnitTypeSymbol
- abstract is_castable_to(_other_type)
Test castability of this SymbolType to _other_type.
The implementation of this function in TypeSymbol takes care of casting to `TemplateTypeSymbol`s, hence, any children that override this function need to always call the parent implementation, before doing their own castability checks. :return: True if castable, otherwise False :rtype: bool
- is_instance_of(_other)
wrapper around isinstance to make things more readable/intuitive. instance checks abound for all members of the TypeSymbol hierarchy, (specifically the operator functions) though i have tried to limit them to situations that would otherwise have been covered by function overloading in e.g. Java -ptraeder
- abstract is_numeric()
Returns whether this symbol represents a numeric type. :return: True if numeric, otherwise False. :rtype: bool
- is_numeric_primitive()
Returns whether this symbol represents a primitive numeric type, i.e., real or integer. :return: True if numeric primitive, otherwise False. :rtype: bool
- abstract is_primitive()
Returns whether this symbol represents a primitive type. :return: true if primitive, otherwise false. :rtype: bool
- negate()
- abstract print_nestml_type()
- print_symbol()
Returns a string representation of this symbol. :return: a string representation. :rtype: str
- unary_operation_not_defined_error(_operator)
- warn_implicit_cast_from_to(_from, _to)
pynestml.symbols.unit_type_symbol module
pynestml.symbols.variable_symbol module
pynestml.symbols.void_type_symbol module
- class pynestml.symbols.void_type_symbol.VoidTypeSymbol
Bases:
pynestml.symbols.type_symbol.TypeSymbol
- is_castable_to(_other_type)
Test castability of this SymbolType to _other_type.
The implementation of this function in TypeSymbol takes care of casting to `TemplateTypeSymbol`s, hence, any children that override this function need to always call the parent implementation, before doing their own castability checks. :return: True if castable, otherwise False :rtype: bool
- is_numeric()
Returns whether this symbol represents a numeric type. :return: True if numeric, otherwise False. :rtype: bool
- is_primitive()
Returns whether this symbol represents a primitive type. :return: true if primitive, otherwise false. :rtype: bool
- print_nestml_type()