diff --git a/pynestml/grammars/PyNestMLParser.g4 b/pynestml/grammars/PyNestMLParser.g4 index 4f56dcdf6..260f47528 100644 --- a/pynestml/grammars/PyNestMLParser.g4 +++ b/pynestml/grammars/PyNestMLParser.g4 @@ -205,7 +205,7 @@ parser grammar PyNestMLParser; ifStmt : ifClause elifClause* (elseClause)?; - ifClause : IF_KEYWORD expression COLON + ifClause : IF_KEYWORD expression COLON NEWLINE INDENT stmtsBody DEDENT; elifClause : ELIF_KEYWORD expression COLON diff --git a/pynestml/visitors/ast_builder_visitor.py b/pynestml/visitors/ast_builder_visitor.py index 85df12f7a..26f144a3f 100644 --- a/pynestml/visitors/ast_builder_visitor.py +++ b/pynestml/visitors/ast_builder_visitor.py @@ -348,7 +348,7 @@ def visitSmallStmt(self, ctx): function_call = self.visit(ctx.functionCall()) if ctx.functionCall() is not None else None declaration = self.visit(ctx.declaration()) if ctx.declaration() is not None else None return_stmt = self.visit(ctx.returnStmt()) if ctx.returnStmt() is not None else None - include_stmt = self.visit(ctx.includeStmt()) if ctx.includeStmt() is not None else None + include_stmt = None#self.visit(ctx.includeStmt()) if ctx.includeStmt() is not None else None node = ASTNodeFactory.create_ast_small_stmt(assignment=assignment, function_call=function_call, declaration=declaration, return_stmt=return_stmt, include_stmt=include_stmt, @@ -523,9 +523,9 @@ def visitModelBody(self, ctx): """ body_elements = list() # visit all var_block children - if ctx.includeStmt_newline() is not None: - for child in ctx.includeStmt_newline(): - body_elements.append(child) + # if ctx.includeStmt_newline() is not None: + # for child in ctx.includeStmt_newline(): + # body_elements.append(child) if ctx.onReceiveBlock() is not None: for child in ctx.onReceiveBlock(): body_elements.append(child) diff --git a/pynestml/visitors/ast_include_statement_visitor.py b/pynestml/visitors/ast_include_statement_visitor.py index b1b7a5e12..e35359d74 100644 --- a/pynestml/visitors/ast_include_statement_visitor.py +++ b/pynestml/visitors/ast_include_statement_visitor.py @@ -23,7 +23,6 @@ import os -from pynestml.meta_model.ast_block import ASTBlock from pynestml.meta_model.ast_block_with_variables import ASTBlockWithVariables from pynestml.meta_model.ast_equations_block import ASTEquationsBlock from pynestml.meta_model.ast_expression import ASTExpression @@ -31,6 +30,7 @@ from pynestml.meta_model.ast_model_body import ASTModelBody from pynestml.meta_model.ast_small_stmt import ASTSmallStmt from pynestml.meta_model.ast_stmt import ASTStmt +from pynestml.meta_model.ast_stmts_body import ASTStmtsBody from pynestml.meta_model.ast_update_block import ASTUpdateBlock from pynestml.symbols.boolean_type_symbol import BooleanTypeSymbol from pynestml.symbols.error_type_symbol import ErrorTypeSymbol @@ -82,7 +82,7 @@ def _handle_include_stmt(self, node: ASTIncludeStmt): new_stmts = parsed_included_file include_stmt = node.get_parent().get_parent() - if isinstance(include_stmt.get_parent(), ASTBlock): + if isinstance(include_stmt.get_parent(), ASTStmtsBody): self._replace_statements(include_stmt, new_stmts) elif isinstance(node.get_parent().get_parent(), ASTEquationsBlock): @@ -93,7 +93,7 @@ def _handle_include_stmt(self, node: ASTIncludeStmt): new_stmt = parsed_included_file include_stmt = node.get_parent().get_parent() - if isinstance(include_stmt.get_parent(), ASTBlock): + if isinstance(include_stmt.get_parent(), ASTStmtsBody): self._replace_statements(include_stmt, [new_stmt]) # elif isinstance(node.get_parent().get_parent(), ASTEquationsBlock):