pynestml.visitors package
Submodules
pynestml.visitors.ast_binary_logic_visitor module
rhs: left=rhs logicalOperator right=rhs
- class pynestml.visitors.ast_binary_logic_visitor.ASTBinaryLogicVisitor
Bases:
ASTVisitor
Visits a single binary logical operator rhs and updates its types.
- visit_expression(node)
Visits an expression which uses a binary logic operator and updates the type. :param node: a single expression. :type node: ast_expression
pynestml.visitors.ast_boolean_literal_visitor module
simpleExpression : BOOLEAN_LITERAL // true & false ;
- class pynestml.visitors.ast_boolean_literal_visitor.ASTBooleanLiteralVisitor
Bases:
ASTVisitor
Visits a single boolean literal and updates its type.
- visit_simple_expression(node)
Visits a single simple rhs containing a boolean literal and updates its type. :param node: a simple rhs. :type node: ast_simple_expression
pynestml.visitors.ast_builder_visitor module
- class pynestml.visitors.ast_builder_visitor.ASTBuilderVisitor(tokens)
Bases:
PyNestMLParserVisitor
This class is used to create an internal representation of the model by means of an abstract syntax tree.
- visitAnyDecorator(ctx)
- visitAssignment(ctx)
- visitBitOperator(ctx)
- visitBlock(ctx)
- visitBlockWithVariables(ctx)
- visitComparisonOperator(ctx)
- visitCompoundStmt(ctx)
- visitContinuousInputPort(ctx)
- visitDataType(ctx)
- visitDeclaration(ctx)
- visitElifClause(ctx)
- visitElseClause(ctx)
- visitEquationsBlock(ctx)
- visitExpression(ctx)
- visitForStmt(ctx)
- visitFunction(ctx)
- visitFunctionCall(ctx)
- visitIfClause(ctx)
- visitIfStmt(ctx)
- visitInlineExpression(ctx)
- visitInputBlock(ctx)
- visitInputQualifier(ctx)
- visitKernel(ctx)
- visitLogicalOperator(ctx)
- visitNamespaceDecoratorName(ctx)
- visitNamespaceDecoratorNamespace(ctx)
- visitNestMLCompilationUnit(ctx)
- visitNeuron(ctx)
- visitNeuronBody(ctx)
Here, in order to ensure that the correct order of elements is kept, we use a method which inspects a list of elements and returns the one with the smallest source line.
- visitOdeEquation(ctx)
- visitOnReceiveBlock(ctx)
- visitOutputBlock(ctx)
- visitParameter(ctx)
- visitReturnStmt(ctx)
- visitSimpleExpression(ctx)
- visitSmallStmt(ctx)
- visitSpikeInputPort(ctx)
- visitStmt(ctx)
- visitSynapse(ctx)
- visitSynapseBody(ctx)
Here, in order to ensure that the correct order of elements is kept, we use a method which inspects a list of elements and returns the one with the smallest source line.
- visitUnaryOperator(ctx)
- visitUnitType(ctx)
- visitUpdateBlock(ctx)
- visitVariable(ctx)
- visitWhileStmt(ctx)
- pynestml.visitors.ast_builder_visitor.create_source_pos(ctx)
Returns a new source location object. Used in order to avoid code duplication. :param ctx: a context variable :return: ctx
- pynestml.visitors.ast_builder_visitor.get_next(_elements=[])
This method is used to get the next element according to its source position. :type _elements: a list of elements :return: the next element :rtype: object
- pynestml.visitors.ast_builder_visitor.update_node_comments(node, comments)
pynestml.visitors.ast_comparison_operator_visitor module
- class pynestml.visitors.ast_comparison_operator_visitor.ASTComparisonOperatorVisitor
Bases:
ASTVisitor
Visits a single rhs consisting of a binary comparison operator.
- visit_expression(expr)
Visits a single comparison operator expression and updates the type. :param expr: an expression :type expr: ast_expression
pynestml.visitors.ast_condition_visitor module
rhs : condition=rhs ‘?’ ifTrue=rhs ‘:’ ifNot=rhs
- class pynestml.visitors.ast_condition_visitor.ASTConditionVisitor
Bases:
ASTVisitor
This visitor is used to derive the correct type of a ternary operator, i.e., of all its subexpressions.
- visit_expression(node)
Visits an rhs consisting of the ternary operator and updates its type. :param node: a single rhs :type node: ast_expression
pynestml.visitors.ast_data_type_visitor module
- class pynestml.visitors.ast_data_type_visitor.ASTDataTypeVisitor
Bases:
ASTVisitor
This class represents a visitor which inspects a handed over data type, checks if correct typing has been used (e.g., no computation between primitive and non primitive data types etc.) and finally updates the type symbols of the datatype meta_model.
- endvisit_data_type(node)
Used to endvisit a single data-type. :param node: a data-type. :type node: ASTDataType
- endvisit_unit_type(node)
Used to endvisit a single unit-type. :param node: a unit type. :type node: ASTUnitType
- visit_data_type(node)
Visits a single data type meta_model node and updates, checks correctness and updates its type symbol. This visitor can also be used to derive the original name of the unit. :param node: a single datatype node. :type node: ast_data_type
- visit_unit_type(node)
Visits a single unit type element, checks for correct usage of units and builds the corresponding combined unit. :param node: a single unit type meta_model. :type node: ASTUnitType :return: a new type symbol representing this unit type. :rtype: type_symbol
- pynestml.visitors.ast_data_type_visitor.handle_unit(unit_type)
Handles a handed over unit by creating the corresponding unit-type, storing it in the list of predefined units, creating a type symbol and returning it. :param unit_type: astropy unit object :type unit_type: astropy.units.core.Unit :return: a new type symbol :rtype: TypeSymbol
pynestml.visitors.ast_dot_operator_visitor module
rhs : left=rhs (timesOp=’*’ | divOp=’/’ | moduloOp=’%’) right=rhs
- class pynestml.visitors.ast_dot_operator_visitor.ASTDotOperatorVisitor
Bases:
ASTVisitor
This visitor is used to derive the correct type of expressions which use a binary dot operator.
- visit_expression(node)
Visits a single rhs and updates the type. :param node: a single rhs :type node: ast_expression
pynestml.visitors.ast_equations_with_delay_vars_visitor module
- class pynestml.visitors.ast_equations_with_delay_vars_visitor.ASTEquationsWithDelayVarsVisitor
Bases:
ASTVisitor
A visitor that converts the delay variables parsed as function calls to ASTVariable and collects all the equations that have these delay variables.
- endvisit_ode_equation(node: ASTOdeEquation)
Used to endvisit a single ode-equation. :param node: a single ode-equation. :type node: ASTOdeEquation
- visit_simple_expression(node: ASTSimpleExpression)
Used to visit a single simple rhs. :param node: a simple rhs. :type node: ASTSimpleExpression
pynestml.visitors.ast_equations_with_vector_variables module
- class pynestml.visitors.ast_equations_with_vector_variables.ASTEquationsWithVectorVariablesVisitor
Bases:
ASTVisitor
A visitor that collects all the equations that contain vector variables.
- visit_ode_equation(node: ASTOdeEquation)
Used to visit a single ode-equation. :param node: a single ode-equation. :type node: ASTOdeEquation
pynestml.visitors.ast_expression_type_visitor module
- class pynestml.visitors.ast_expression_type_visitor.ASTExpressionTypeVisitor
Bases:
ASTVisitor
This is the main visitor as used to derive the type of an expression. By using different sub-visitors and real-self it is possible to adapt to different types of sub-expressions.
- binary_logic_visitor = <pynestml.visitors.ast_binary_logic_visitor.ASTBinaryLogicVisitor object>
- boolean_literal_visitor = <pynestml.visitors.ast_boolean_literal_visitor.ASTBooleanLiteralVisitor object>
- comparison_operator_visitor = <pynestml.visitors.ast_comparison_operator_visitor.ASTComparisonOperatorVisitor object>
- condition_visitor = <pynestml.visitors.ast_condition_visitor.ASTConditionVisitor object>
- dot_operator_visitor = <pynestml.visitors.ast_dot_operator_visitor.ASTDotOperatorVisitor object>
- function_call_visitor = <pynestml.visitors.ast_function_call_visitor.ASTFunctionCallVisitor object>
- handle(_node)
Handles the handed over node and executes the required sub routines. :param _node: a meta_model node. :type _node: AST_
- inf_visitor = <pynestml.visitors.ast_inf_visitor.ASTInfVisitor object>
- line_operator_visitor = <pynestml.visitors.ast_line_operation_visitor.ASTLineOperatorVisitor object>
- logical_not_visitor = <pynestml.visitors.ast_logical_not_visitor.ASTLogicalNotVisitor object>
- no_semantics = <pynestml.visitors.ast_no_semantics_visitor.ASTNoSemanticsVisitor object>
- numeric_literal_visitor = <pynestml.visitors.ast_numeric_literal_visitor.ASTNumericLiteralVisitor object>
- parentheses_visitor = <pynestml.visitors.ast_parentheses_visitor.ASTParenthesesVisitor object>
- pow_visitor = <pynestml.visitors.ast_power_visitor.ASTPowerVisitor object>
- string_literal_visitor = <pynestml.visitors.ast_string_literal_visitor.ASTStringLiteralVisitor object>
- traverse_expression(_node)
Traverses an expression and executes the required sub-routines. :param _node: a single meta_model node :type _node: ASTExpression
- traverse_simple_expression(node)
Traverses a simple expression and invokes required subroutines. :param node: a single node. :type node: ASTSimpleExpression
- unary_visitor = <pynestml.visitors.ast_unary_visitor.ASTUnaryVisitor object>
- variable_visitor = <pynestml.visitors.ast_variable_visitor.ASTVariableVisitor object>
pynestml.visitors.ast_function_call_visitor module
- class pynestml.visitors.ast_function_call_visitor.ASTFunctionCallVisitor
Bases:
ASTVisitor
Visits a single function call and updates its type.
- visit_simple_expression(node: ASTSimpleExpression) None
Visits a single function call as stored in a simple expression and derives the correct type of all its parameters. :param node: a simple expression
pynestml.visitors.ast_higher_order_visitor module
- class pynestml.visitors.ast_higher_order_visitor.ASTHigherOrderVisitor(visit_funcs=[], endvisit_funcs=[])
Bases:
ASTVisitor
This visitor is used to visit each node of the meta_model and and preform an arbitrary on it..
- endvisit(node)
Dispatcher for endvisit. :param node: The ASTElement to endvisit :type node: ASTElement or inherited
- visit(node)
Dispatcher for visitor pattern. :param node: The ASTElement to visit :type node: ASTElement or inherited
pynestml.visitors.ast_inf_visitor module
simpleExpression : isInf=’inf’
- class pynestml.visitors.ast_inf_visitor.ASTInfVisitor
Bases:
ASTVisitor
Visits a inf rhs and updates the type accordingly.
- visit_simple_expression(node)
Visits a single simple rhs containing an inf literal and updates its type. :param node: a simple rhs :type node: ast_simple_expression
pynestml.visitors.ast_line_operation_visitor module
rhs : left=rhs (plusOp=’+’ | minusOp=’-’) right=rhs
- class pynestml.visitors.ast_line_operation_visitor.ASTLineOperatorVisitor
Bases:
ASTVisitor
Visits a single binary operation consisting of + or - and updates the type accordingly.
- visit_expression(node)
Visits a single expression containing a plus or minus operator and updates its type. :param node: a single expression :type node: ast_expression
pynestml.visitors.ast_logical_not_visitor module
rhs: logicalNot=’not’ term=rhs
- class pynestml.visitors.ast_logical_not_visitor.ASTLogicalNotVisitor
Bases:
ASTVisitor
Visits a single rhs and updates the type of the sub-rhs.
- visit_expression(node)
Visits a single rhs with a logical operator and updates the type. :param node: a single rhs :type node: ast_expression
pynestml.visitors.ast_mark_delay_vars_visitor module
- class pynestml.visitors.ast_mark_delay_vars_visitor.ASTMarkDelayVarsVisitor
Bases:
ASTVisitor
A visitor that marks has_delay value in ASTExpression and ASTSimpleExpression nodes to True
- visit_expression(node: ASTExpression)
Used to visit a single rhs. :param node: an rhs. :type node: ASTExpression
- visit_simple_expression(node: ASTSimpleExpression)
Used to visit a single simple rhs. :param node: a simple rhs. :type node: ASTSimpleExpression
- visit_variable(node: ASTVariable)
Used to visit a single variable. :param node: a single variable. :type node: ASTVariable
pynestml.visitors.ast_no_semantics_visitor module
Placeholder for rhs productions that are not implemented
- class pynestml.visitors.ast_no_semantics_visitor.ASTNoSemanticsVisitor
Bases:
ASTVisitor
A visitor which indicates that there a no semantics for the given node.
- visit_expression(node)
Visits a single rhs but does not execute any steps besides printing a message. This visitor indicates that no functionality has been implemented for this type of nodes. :param node: a single rhs :type node: ast_expression or ast_simple_expression
pynestml.visitors.ast_numeric_literal_visitor module
simpleExpression : (UNSIGNED_INTEGER | FLOAT) (variable)?
- class pynestml.visitors.ast_numeric_literal_visitor.ASTNumericLiteralVisitor
Bases:
ASTVisitor
Visits a single numeric literal and updates its type.
- visit_simple_expression(node)
Visit a simple rhs and update the type of a numeric literal. :param node: a single meta_model node :type node: ast_node :return: no value returned, the type is updated in-place :rtype: void
pynestml.visitors.ast_parent_aware_visitor module
- class pynestml.visitors.ast_parent_aware_visitor.ASTParentAwareVisitor
Bases:
ASTVisitor
The parent aware visitor storing a trace. This visitor enables a given visitor to inspect the corresponding parent node. .. attribute:: parents type
A stack containing the predecessor of this node.
- type:
Stack
- handle(_node)
pynestml.visitors.ast_parentheses_visitor module
rhs : leftParentheses=’(’ term=rhs rightParentheses=’)’
- class pynestml.visitors.ast_parentheses_visitor.ASTParenthesesVisitor
Bases:
ASTVisitor
Visits a single rhs encapsulated in brackets and updates its type.
- visit_expression(node)
Visits a single rhs encapsulated in parenthesis and updates its type. :param node: a single rhs :type node: ast_expression
pynestml.visitors.ast_power_visitor module
rhs : <assoc=right> left=rhs powOp=’**’ right=rhs
- class pynestml.visitors.ast_power_visitor.ASTPowerVisitor
Bases:
ASTVisitor
Visits a single power rhs and updates its types accordingly.
- calculate_numeric_value(expr)
Calculates the numeric value of a exponent. :param expr: a single expression :type expr: ASTSimpleExpression or ASTExpression :return: a numeric value or unit type
- try_to_calculate_resulting_unit(expr)
- visit_expression(node)
Visits a single power expression and updates the types. :param node: a single expression. :type node: ASTExpression
pynestml.visitors.ast_random_number_generator_visitor module
- class pynestml.visitors.ast_random_number_generator_visitor.ASTRandomNumberGeneratorVisitor
Bases:
ASTVisitor
Visits a single function call and updates its type.
- visit_simple_expression(node)
Visits a single function call as stored in a simple expression and checks to see whether any calls are made to generate a random number. If so, set a flag so that the necessary initialisers can be called at the right time in the generated code.
pynestml.visitors.ast_set_vector_parameter_in_update_expressions module
- class pynestml.visitors.ast_set_vector_parameter_in_update_expressions.ASTSetVectorParameterInUpdateExpressionVisitor(var: ASTVariable)
Bases:
ASTVisitor
Sets the vector parameter in the update expression to the value that was originally provided in the ODE in the equations block.
- visit_variable(node: ASTVariable)
Set the vector parameter if present. :param node: variable in the expression
pynestml.visitors.ast_string_literal_visitor module
simpleExpression : string=STRING_LITERAL
- class pynestml.visitors.ast_string_literal_visitor.ASTStringLiteralVisitor
Bases:
ASTVisitor
Visits a string literal and updates its type.
- visit_simple_expression(node)
Visits a singe simple rhs which consists of a string literal and updates the type. :param node: a simple rhs containing a string literal :type node: ast_simple_expression
pynestml.visitors.ast_symbol_table_visitor module
- class pynestml.visitors.ast_symbol_table_visitor.ASTSymbolTableVisitor
Bases:
ASTVisitor
This class is used to create a symbol table from a handed over AST.
- endvisit_block_with_variables(node)
Used to endvisit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- endvisit_function(node)
Used to endvisit a single function block. :param node: a function block object. :type node: ASTFunction
- endvisit_input_port(node)
Used to endvisit a single input port. :param node: a single input port. :type node: ASTInputPort
- endvisit_neuron(node)
Used to endvisit a single neuron. :return: a single neuron. :rtype: ASTNeuron
- endvisit_on_receive_block(node=None)
Used to endvisit a onReceive block.
- endvisit_synapse(node)
Used to endvisit a single synapse. :return: a single synapse. :rtype: ASTSynapse
- endvisit_synapse_body(node)
- endvisit_update_block(node=None)
Used to endvisit a single update block. :param node: an update block object. :type node: ASTDynamics
- visit_assignment(node)
Private method: Used to visit a single node and update its corresponding scope. :param node: an node object. :type node: ast_assignment :return: no return value, since neither scope nor symbol is created
- visit_block(node)
Private method: Used to visit a single block of statements, create and update the corresponding scope. :param node: a block object. :type node: ast_block
- visit_block_with_variables(node)
Private method: Used to visit a single block of variables and update its scope. :param node: a block with declared variables. :type node: ast_block_with_variables
- visit_compound_stmt(node)
Private method: Used to visit a single compound statement and create the corresponding sub-scope. :param node: a single compound statement. :type node: ASTCompoundStatement
- visit_data_type(node)
Private method: Used to visit a single data-type and update its scope. :param node: a data-type. :type node: ast_data_type
- visit_declaration(node: ASTDeclaration) None
Private method: Used to visit a single declaration, update its scope and return the corresponding set of symbols :param node: a declaration AST node :return: the scope is updated without a return value.
- visit_elif_clause(node)
Private method: Used to visit a single elif-clause, update its scope and create the corresponding sub-scope. :param node: an elif clause. :type node: ast_elif_clause
- visit_else_clause(node)
Private method: Used to visit a single else-clause, update its scope and create the corresponding sub-scope. :param node: an else clause. :type node: ast_else_clause
- visit_equations_block(node)
Private method: Used to visit a single equations block and update its scope. :param node: a single equations block. :type node: ast_equations_block
- visit_expression(node)
Private method: Used to visit a single rhs and update its scope. :param node: an rhs. :type node: ast_expression
- visit_for_stmt(node)
Private method: Used to visit a single for-stmt, update its scope and create the corresponding sub-scope. :param node: a for-statement. :type node: ast_for_stmt
- visit_function(node)
Private method: Used to visit a single function block and create the corresponding scope. :param node: a function block object. :type node: ast_function
- visit_function_call(node)
Private method: Used to visit a single function call and update its corresponding scope. :param node: a function call object. :type node: ast_function_call :return: no return value, since neither scope nor symbol is created
- visit_if_clause(node)
Private method: Used to visit a single if-clause, update its scope and create the corresponding sub-scope. :param node: an if clause. :type node: ast_if_clause
- visit_if_stmt(node)
Private method: Used to visit a single if-statement, update its scope and create the corresponding sub-scope. :param node: an if-statement object. :type node: ast_if_stmt
- visit_inline_expression(node)
Private method: Used to visit a single ode-function, create the corresponding symbol and update the scope. :param node: a single inline expression. :type node: ASTInlineExpression
- visit_input_block(node)
Private method: Used to visit a single input block and update its scope. :param node: a single input block. :type node: ast_input_block
- visit_input_port(node)
Private method: Used to visit a single input port, create the corresponding symbol and update the scope. :param node: a single input port. :type node: ASTInputPort
- visit_kernel(node)
Private method: Used to visit a single kernel, create the corresponding symbol and update the scope. :param node: a kernel. :type node: ASTKernel
- visit_neuron(node)
Private method: Used to visit a single neuron and create the corresponding global as well as local scopes. :return: a single neuron. :rtype: ast_neuron
- visit_neuron_or_synapse_body(node)
Private method: Used to visit a single neuron body and create the corresponding scope. :param node: a single body element. :type node: ast_body
- visit_ode_equation(node)
Private method: Used to visit a single ode-equation and update the corresponding scope. :param node: a single ode-equation. :type node: ast_ode_equation
- visit_on_receive_block(node)
Private method: Used to visit a single onReceive block and create the corresponding scope. :param node: an onReceive block object. :type node: ASTOnReceiveBlock
- visit_return_stmt(node)
Private method: Used to visit a single return statement and update its scope. :param node: a return statement object. :type node: ast_return_stmt
- visit_simple_expression(node)
Private method: Used to visit a single simple rhs and update its scope. :param node: a simple rhs. :type node: ast_simple_expression
- visit_small_stmt(node)
Private method: Used to visit a single small statement and create the corresponding sub-scope. :param node: a single small statement. :type node: ASTSmallStatement
- visit_stmt(node: ASTStmt)
Private method: Used to visit a single stmt and update its scope. :param node: a single statement
- visit_synapse(node)
Private method: Used to visit a single synapse and create the corresponding global as well as local scopes. :return: a single synapse. :rtype: ast_synapse
- visit_synapse_body(node)
Private method: Used to visit a single synapse body and create the corresponding scope. :param node: a single body element. :type node: ast_body
- visit_unit_type(node)
Private method: Used to visit a single unit-type and update its scope. :param node: a unit type. :type node: ast_unit_type
- visit_update_block(node)
Private method: Used to visit a single update block and create the corresponding scope. :param node: an update block object. :type node: ASTDynamics
- visit_variable(node: ASTVariable)
Used to visit a single variable. :param node: a single variable. :type node: ASTVariable
- visit_while_stmt(node)
Private method: Used to visit a single while-stmt, update its scope and create the corresponding sub-scope. :param node: a while-statement. :type node: ast_while_stmt
pynestml.visitors.ast_unary_visitor module
Expr = unaryOperator term=rhs unaryOperator : (unaryPlus=’+’ | unaryMinus=’-’ | unaryTilde=’~’);
- class pynestml.visitors.ast_unary_visitor.ASTUnaryVisitor
Bases:
ASTVisitor
Visits an rhs consisting of a unary operator, e.g., -, and a sub-rhs.
- visit_expression(node)
Visits a single unary operator and updates the type of the corresponding expression. :param node: a single expression :type node: ast_expression
pynestml.visitors.ast_variable_visitor module
- class pynestml.visitors.ast_variable_visitor.ASTVariableVisitor
Bases:
ASTVisitor
This visitor visits a single variable and updates its type.
- visit_expression(node)
Used to visit a single rhs. :param node: an rhs. :type node: ASTExpression
- visit_simple_expression(node)
Visits a single variable as contained in a simple expression and derives its type. :param node: a single simple expression :type node: ASTSimpleExpression
pynestml.visitors.ast_visitor module
- class pynestml.visitors.ast_visitor.ASTVisitor
Bases:
object
This class represents a standard implementation of a visitor as used to create concrete instances. .. attribute:: real_self
The visitor which will be used during the visiting of a node.
- type:
ASTVisitor
- endvisit(node)
Dispatcher for endvisit. :param node: The ASTElement to endvisit :type node: ASTElement or inherited
- endvisit_arithmetic_operator(node)
Used to endvisit a single arithmetic operator. :param node: a single arithmetic operator. :type node: ASTArithmeticOperator
- endvisit_assignment(node)
Used to endvisit a single assignment. :param node: an assignment object. :type node: ASTAssignment
- endvisit_bit_operator(node)
Used to endvisit a single unary operator. :param node: a single bit operator. :type node: ASTBitOperator
- endvisit_block(node)
Used to endvisit a single block of statements. :param node: a block object. :type node: ASTBlock
- endvisit_block_with_variables(node)
Used to endvisit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- endvisit_comparison_operator(node)
Used to endvisit a single comparison operator. :param node: a single comparison operator. :type node: ASTComparisonOperator
- endvisit_compilation_unit(node)
Visits a single compilation unit, thus all neurons. :param node: a single compilation unit. :type node: ASTNestMLCompilationUnit
- endvisit_compound_stmt(node)
Used to endvisit a single compound statement. :param node: a single compound statement. :type node: ASTCompoundStatement
- endvisit_data_type(node)
Used to endvisit a single data-type. :param node: a data-type. :type node: ASTDataType
- endvisit_declaration(node)
Used to endvisit a single declaration. :param node: a declaration object. :type node: ASTDeclaration
- endvisit_elif_clause(node)
Used to endvisit a single elif-clause. :param node: an elif clause. :type node: ASTElifClause
- endvisit_else_clause(node)
Used to endvisit a single else-clause. :param node: an else clause. :type node: ASTElseClause
- endvisit_equations_block(node)
Used to endvisit a single equations block. :param node: a single equations block. :type node: ASTEquationsBlock
- endvisit_expression(node)
Used to endvisit a single rhs. :param node: an rhs. :type node: ASTExpression
- endvisit_for_stmt(node)
Private method: Used to endvisit a single for-stmt. :param node: a for-statement. :type node: ASTForStmt
- endvisit_function(node)
Used to endvisit a single function block. :param node: a function block object. :type node: ASTFunction
- endvisit_function_call(node)
Private method: Used to endvisit a single function call and update its corresponding scope. :param node: a function call object. :type node: ASTFunctionCall
- endvisit_if_clause(node)
Used to endvisit a single if-clause. :param node: an if clause. :type node: ASTIfClause
- endvisit_if_stmt(node)
Used to endvisit a single if-statement. :param node: an if-statement object. :type node: ASTIfStmt
- endvisit_inline_expression(node)
Used to endvisit a single inline expression. :param node: a single inline expression :type node: ASTInlineExpression
- endvisit_input_block(node)
Used to endvisit a single input block. :param node: a single input block. :type node: ASTInputBlock
- endvisit_input_port(node)
Used to endvisit a single input port. :param node: a single input port. :type node: ASTInputPort
- endvisit_input_qualifier(node)
Used to endvisit a single input port qualifier. :param node: a single input port qualifier node. :type node: ASTInputQualifer
- endvisit_kernel(node)
Used to endvisit a single kernel. :param node: a single kernel. :type node: ASTKernel
- endvisit_logical_operator(node)
Used to endvisit a single logical operator. :param node: a single logical operator. :type node: ASTLogicalOperator
- endvisit_neuron(node)
Used to endvisit a single neuron. :return: a single neuron. :rtype: ASTNeuron
- endvisit_neuron_or_synapse_body(node)
Used to endvisit a single neuron body. :param node: a single body element. :type node: ASTNeuronOrSynapseBody
- endvisit_ode_equation(node)
Used to endvisit a single ode-equation. :param node: a single ode-equation. :type node: ASTOdeEquation
- endvisit_on_receive_block(node)
Used to endvisit a onReceive block.
- endvisit_output_block(node)
Used to endvisit a single output block. :param node: a single output block. :type node: ASTOutputBlock
- endvisit_parameter(node)
Used to endvisit a single parameter. :param node: a single parameter. :type node: ASTParameter
- endvisit_return_stmt(node)
Used to endvisit a single return statement. :param node: a return statement object. :type node: ASTReturnStmt
- endvisit_simple_expression(node)
Used to endvisit a single simple rhs. :param node: a simple rhs. :type node: ASTSimpleExpression
- endvisit_small_stmt(node)
Used to endvisit a single small statement. :param node: a single small statement. :type node: ASTSmallStatement
- endvisit_stmt(node)
Used to endvisit a single stmt. :param node: a single stmt :return: ASTStmt
- endvisit_synapse(node)
Used to endvisit a single synapse. :return: a single synapse. :rtype: ASTSynapse
- endvisit_unary_operator(node)
Used to endvisit a single unary operator. :param node: a single unary operator. :type node: ASTUnaryOperator
- endvisit_unit_type(node)
Used to endvisit a single unit-type. :param node: a unit type. :type node: ASTUnitType
- endvisit_update_block(node)
Used to endvisit a single update block. :param node: an update block object. :type node: ASTDynamics
- endvisit_variable(node)
Used to endvisit a single variable. :param node: a single variable. :type node: ASTVariable
- endvisit_while_stmt(node)
Used to endvisit a single while-stmt. :param node: a while-statement. :type node: ASTWhileStmt
- get_real_self()
- handle(_node)
- set_real_self(_visitor)
- traverse(node)
Dispatcher for traverse method. :param node: The ASTElement to visit :type node: Inherited from ASTElement
- traverse_arithmetic_operator(node)
- traverse_assignment(node)
- traverse_bit_operator(node)
- traverse_block(node)
- traverse_block_with_variables(_node)
- traverse_comparison_operator(node)
- traverse_compilation_unit(node)
- traverse_compound_stmt(node)
- traverse_data_type(node)
- traverse_declaration(node)
- traverse_elif_clause(node)
- traverse_else_clause(node)
- traverse_equations_block(node)
- traverse_expression(node)
- traverse_for_stmt(node)
- traverse_function(node)
- traverse_function_call(node)
- traverse_if_clause(node)
- traverse_if_stmt(node)
- traverse_inline_expression(node)
- traverse_input_block(node)
- traverse_input_port(node)
- traverse_input_qualifier(node)
- traverse_kernel(node)
- traverse_logical_operator(node)
- traverse_neuron(node)
- traverse_neuron_or_synapse_body(node)
- traverse_ode_equation(node)
- traverse_on_receive_block(node)
- traverse_output_block(node)
- traverse_parameter(node)
- traverse_return_stmt(node)
- traverse_simple_expression(node)
- traverse_small_stmt(node)
- traverse_stmt(node)
- traverse_synapse(node)
- traverse_synapse_body(node)
- traverse_unary_operator(_node)
- traverse_unit_type(node)
- traverse_update_block(node)
- traverse_variable(node)
- traverse_while_stmt(node)
- visit(node)
Dispatcher for visitor pattern. :param node: The ASTElement to visit :type node: ASTElement or inherited
- visit_arithmetic_operator(node)
Used to visit a single arithmetic operator. :param node: a single arithmetic operator. :type node: ASTArithmeticOperator
- visit_assignment(node)
Used to visit a single assignment. :param node: an assignment object. :type node: ASTAssignment
- visit_bit_operator(node)
Used to visit a single unary operator. :param node: a single bit operator. :type node: ASTBitOperator
- visit_block(node)
Used to visit a single block of statements. :param node: a block object. :type node: ASTBlock
- visit_block_with_variables(node)
Used to visit a single block of variables. :param node: a block with declared variables. :type node: ASTBlockWithVariables
- visit_comparison_operator(node)
Used to visit a single comparison operator. :param node: a single comparison operator. :type node: ASTComparisonOperator
- visit_compilation_unit(node)
Visits a single compilation unit, thus all neurons. :param node: a single compilation unit. :type node: ASTNestMLCompilationUnit
- visit_compound_stmt(node)
Used to visit a single compound statement. :param node: a single compound statement. :type node: ASTCompoundStatement
- visit_data_type(node)
Used to visit a single data-type. :param node: a data-type. :type node: ASTDataType
- visit_declaration(node)
Used to visit a single declaration. :param node: a declaration object. :type node: ASTDeclaration
- visit_elif_clause(node)
Used to visit a single elif-clause. :param node: an elif clause. :type node: ASTElifClause
- visit_else_clause(node)
Used to visit a single else-clause. :param node: an else clause. :type node: ASTElseClause
- visit_equations_block(node)
Used to visit a single equations block. :param node: a single equations block. :type node: ASTEquationsBlock
- visit_expression(node)
Used to visit a single rhs. :param node: an rhs. :type node: ASTExpression
- visit_for_stmt(node)
Private method: Used to visit a single for-stmt. :param node: a for-statement. :type node: ASTForStmt
- visit_function(node)
Used to visit a single function block. :param node: a function block object. :type node: ASTFunction
- visit_function_call(node)
Private method: Used to visit a single function call and update its corresponding scope. :param node: a function call object. :type node: ASTFunctionCall
- visit_if_clause(node)
Used to visit a single if-clause. :param node: an if clause. :type node: ASTIfClause
- visit_if_stmt(node)
Used to visit a single if-statement. :param node: an if-statement object. :type node: ASTIfStmt
- visit_inline_expression(node)
Used to visit a single inline expression. :param node: a single inline expression. :type node: ASTInlineExpression
- visit_input_block(node)
Used to visit a single input block. :param node: a single input block. :type node: ASTInputBlock
- visit_input_port(node)
Used to visit a single input port. :param node: a single input port. :type node: ASTInputPort
- visit_input_qualifier(node)
Used to visit a single input port qualifier. :param node: a single input port qualifier node. :type node: ASTInputQualifier
- visit_kernel(node)
Used to visit a single kernel. :param node: a single kernel. :type node: ASTKernel
- visit_logical_operator(node)
Used to visit a single logical operator. :param node: a single logical operator. :type node: ASTLogicalOperator
- visit_neuron(node)
Used to visit a single neuron. :return: a single neuron. :rtype: ASTNeuron
- visit_neuron_or_synapse_body(node)
Used to visit a single neuron body. :param node: a single body element. :type node: ASTNeuronOrSynapseBody
- visit_ode_equation(node)
Used to visit a single ode-equation. :param node: a single ode-equation. :type node: ASTOdeEquation
- visit_on_receive_block(node)
Used to visit a single onReceive block. :type node: ASTOnReceiveBlock
- visit_output_block(node)
Used to visit a single output block. :param node: a single output block. :type node: ASTOutputBlock
- visit_parameter(node)
Used to visit a single parameter. :param node: a single parameter. :type node: ASTParameter
- visit_return_stmt(node)
Used to visit a single return statement. :param node: a return statement object. :type node: ASTReturnStmt
- visit_simple_expression(node)
Used to visit a single simple rhs. :param node: a simple rhs. :type node: ASTSimpleExpression
- visit_small_stmt(node)
Used to visit a single small statement. :param node: a single small statement. :type node: ASTSmallStatement
- visit_stmt(node)
- visit_synapse(node)
Used to visit a single synapse. :return: a single synapse. :rtype: ASTSynapse
- visit_unary_operator(node)
Used to visit a single unary operator. :param node: a single unary operator. :type node: ASTUnaryOperator
- visit_unit_type(node)
Used to visit a single unit-type. :param node: a unit type. :type node: ASTUnitType
- visit_update_block(node)
Used to visit a single update block. :param node: an update block object. :type node: ASTDynamics
- visit_variable(node)
Used to visit a single variable. :param node: a single variable. :type node: ASTVariable
- visit_while_stmt(node)
Used to visit a single while-stmt. :param node: a while-statement. :type node: ASTWhileStmt
pynestml.visitors.comment_collector_visitor module
- class pynestml.visitors.comment_collector_visitor.CommentCollectorVisitor(tokens, strip_delim: bool = True)
Bases:
PyNestMLParserVisitor
This visitor iterates over a given parse tree and inspects the corresponding stream of tokens in order to update all nodes by their corresponding tokens. Attributes:
- visitAssignment(ctx)
- visitBlock(ctx)
- visitBlockWithVariables(ctx)
- visitCompoundStmt(ctx)
- visitContinuousInputPort(ctx)
- visitDeclaration(ctx)
- visitElifClause(ctx)
- visitElseClause(ctx)
- visitEquationsBlock(ctx)
- visitForStmt(ctx)
- visitFunction(ctx)
- visitFunctionCall(ctx)
- visitIfClause(ctx)
- visitInlineExpression(ctx)
- visitInputBlock(ctx)
- visitKernel(ctx)
- visitNeuron(ctx)
- visitOdeEquation(ctx)
- visitOnReceiveBlock(ctx)
- visitOutputBlock(ctx)
- visitSmallStmt(ctx)
- visitSpikeInputPort(ctx)
- visitStmt(ctx)
- visitSynapse(ctx)
- visitUpdateBlock(ctx)
- visitWhileStmt(ctx)
- pynestml.visitors.comment_collector_visitor.get_comments(ctx, tokens, strip_delim: bool = True) List[str]
Returns all pre- and inline comments. :param ctx: a context :type ctx: ctx :param tokens: list of token objects :type tokens: list(Tokens) :return: a list of comments
- pynestml.visitors.comment_collector_visitor.get_in_comment(ctx, tokens, strip_delim: bool = True) str | None
Returns the sole comment if one is defined in the same line, e.g.
a = 10 mV # comment
:param ctx: a context :type ctx: ctx :param tokens: list of token objects :type tokens: list(Tokens) :return: a comment
- pynestml.visitors.comment_collector_visitor.get_pre_comments(ctx, tokens, strip_delim: bool = True) List[str]
Returns the comment which has been started before this element but also before the next previous token. :param ctx: a context :type ctx: ctx :param tokens: list of token objects :type tokens: list(Tokens) :return: the corresponding comments
- pynestml.visitors.comment_collector_visitor.is_dedent(tok)
- pynestml.visitors.comment_collector_visitor.is_indent(tok)
- pynestml.visitors.comment_collector_visitor.is_newline(tok)