forked from nest/nestml
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
C.A.P. Linssen
committed
Oct 7, 2024
1 parent
ac766f0
commit eecc955
Showing
11 changed files
with
310 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# ast_include_stmt.py | ||
# | ||
# This file is part of NEST. | ||
# | ||
# Copyright (C) 2004 The NEST Initiative | ||
# | ||
# NEST is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# NEST is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with NEST. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from typing import List | ||
|
||
from pynestml.meta_model.ast_node import ASTNode | ||
|
||
|
||
class ASTIncludeStmt(ASTNode): | ||
""" | ||
This class is used to store an include statement. | ||
""" | ||
|
||
def __init__(self, filename: str, *args, **kwargs): | ||
""" | ||
Standard constructor. | ||
Parameters for superclass (ASTNode) can be passed through :python:`*args` and :python:`**kwargs`. | ||
:param filename: the filename of the included file (can be a single file name, or file path) | ||
""" | ||
super(ASTIncludeStmt, self).__init__(*args, **kwargs) | ||
self.filename = filename | ||
|
||
def clone(self): | ||
""" | ||
Return a clone ("deep copy") of this node. | ||
:return: new AST node instance | ||
:rtype: ASTIncludeStmt | ||
""" | ||
dup = ASTIncludeStmt(filename=self.filename, | ||
# ASTNode common attributes: | ||
source_position=self.source_position, | ||
scope=self.scope, | ||
comment=self.comment, | ||
pre_comments=[s for s in self.pre_comments], | ||
in_comment=self.in_comment, | ||
implicit_conversion_factor=self.implicit_conversion_factor) | ||
|
||
return dup | ||
|
||
def get_filename(self) -> str: | ||
""" | ||
Returns the filename of the included file (can be a single file name, or file path). | ||
:return: filename | ||
""" | ||
return self.filename | ||
|
||
def equals(self, other: ASTNode) -> bool: | ||
r""" | ||
The equality method. | ||
""" | ||
if not isinstance(other, ASTIncludeStmt): | ||
return False | ||
|
||
return self.get_filename().equals(other.get_filename()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.