Skip to content

Commit

Permalink
fix special handling of NEST delay and weight variables in synapse
Browse files Browse the repository at this point in the history
  • Loading branch information
C.A.P. Linssen committed Apr 30, 2024
1 parent db48b95 commit 71605d3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
8 changes: 8 additions & 0 deletions pynestml/symbols/variable_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ def get_decorators(self):
"""
return self.decorators

def get_namespace_decorators(self):
return self.namespace_decorators

def get_namespace_decorator(self, namespace):
if namespace in self.namespace_decorators.keys():
return self.namespace_decorators[namespace]
return ''

def has_vector_parameter(self):
"""
Returns whether this variable symbol has a vector parameter.
Expand Down
1 change: 0 additions & 1 deletion pynestml/utils/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class MessageCode(Enum):
PRIORITY_DEFINED_FOR_ONLY_ONE_EVENT_HANDLER = 82
REPEATED_PRIORITY_VALUE = 83
DELAY_VARIABLE = 84
NEST_DELAY_DECORATOR_NOT_FOUND = 85
INPUT_PORT_SIZE_NOT_INTEGER = 86
INPUT_PORT_SIZE_NOT_GREATER_THAN_ZERO = 87
INSTALL_PATH_INFO = 88
Expand Down
14 changes: 12 additions & 2 deletions pynestml/visitors/ast_builder_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,14 +492,24 @@ def visitModel(self, ctx):

return model

def visitNamespaceDecoratorNamespace(self, ctx):
return str(ctx.NAME())

def visitNamespaceDecoratorName(self, ctx):
return str(ctx.NAME())

def visitAnyDecorator(self, ctx):
from pynestml.generated.PyNestMLLexer import PyNestMLLexer
if ctx.getToken(PyNestMLLexer.DECORATOR_HETEROGENEOUS, 0) is not None:
return PyNestMLLexer.DECORATOR_HETEROGENEOUS
elif ctx.getToken(PyNestMLLexer.DECORATOR_HOMOGENEOUS, 0) is not None:
return PyNestMLLexer.DECORATOR_HOMOGENEOUS

return None
elif ctx.getToken(PyNestMLLexer.AT, 0) is not None:
namespaceDecoratorNamespace = self.visit(ctx.namespaceDecoratorNamespace()) if ctx.namespaceDecoratorNamespace() is not None else None
namespaceDecoratorName = self.visit(ctx.namespaceDecoratorName()) if ctx.namespaceDecoratorName() is not None else None
return ASTNodeFactory.create_ast_namespace_decorator(namespaceDecoratorNamespace, namespaceDecoratorName, source_position=create_source_pos(ctx))
else:
return None

# Visit a parse tree produced by PyNESTMLParser#modelBody.
def visitModelBody(self, ctx):
Expand Down

0 comments on commit 71605d3

Please sign in to comment.