pyVHDLModelTreesitter 0.3.1__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/PKG-INFO +36 -9
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/README.md +23 -4
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/pyproject.toml +33 -20
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/Association.py +97 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/Base.py +8 -10
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/Concurrent.py +110 -0
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/DesignUnit.py +468 -0
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/Expression.py +309 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/Interface.py +91 -132
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/Name.py +74 -0
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/Object.py +81 -0
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/Symbol.py +158 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/_Design.py +6 -8
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/_Document.py +34 -17
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/_Library.py +3 -7
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/__init__.py +3 -1
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/_errors.py +35 -6
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/_parse.py +375 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/__init__.py +8 -6
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/_base_class.py +10 -2
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/_utils.py +118 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/queries/adding_expression.scm +1 -1
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/queries/architecture_definition.scm +7 -0
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/queries/association_element.scm +4 -0
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/queries/association_elements.scm +7 -0
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/queries/component_instantiation_statement.scm +18 -0
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/queries/constant_declaration.scm +10 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/queries/constrained_1d_array.scm +2 -2
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/queries/entity_declaration.scm +2 -1
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/queries/function_call.scm +33 -0
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/queries/ignorable_parentheses.scm +11 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/queries/interface_declaration.scm +2 -2
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/queries/multiplying_expression.scm +5 -0
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/queries/package_declaration.scm +5 -0
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/queries/package_definition.scm +5 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/queries/simple_subtype.scm +2 -2
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/queries/type_conversion.scm +30 -0
- pyvhdlmodeltreesitter-0.5.0/src/pyVHDLModelTreesitter/treesitter/query.py +204 -0
- pyvhdlmodeltreesitter-0.3.1/src/pyVHDLModelTreesitter/DesignUnit.py +0 -270
- pyvhdlmodeltreesitter-0.3.1/src/pyVHDLModelTreesitter/Expression.py +0 -347
- pyvhdlmodeltreesitter-0.3.1/src/pyVHDLModelTreesitter/Name.py +0 -69
- pyvhdlmodeltreesitter-0.3.1/src/pyVHDLModelTreesitter/Symbol.py +0 -162
- pyvhdlmodeltreesitter-0.3.1/src/pyVHDLModelTreesitter/treesitter/_utils.py +0 -67
- pyvhdlmodeltreesitter-0.3.1/src/pyVHDLModelTreesitter/treesitter/query.py +0 -105
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/.gitignore +0 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/LICENSE +0 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/py.typed +0 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/queries/design_units.scm +0 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/queries/interface_declarations.scm +0 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/queries/library_clauses.scm +0 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/queries/library_namespaces.scm +0 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/queries/selected_names.scm +0 -0
- {pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/treesitter/queries/use_clauses.scm +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyVHDLModelTreesitter
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: An implementation of pyVHDLModel using treesitter
|
|
5
5
|
Project-URL: Repository, https://gitlab.com/dawalters/pyVHDLModelTreesitter
|
|
6
6
|
Author: Dominic Adam Walters
|
|
@@ -19,15 +19,23 @@ Requires-Dist: pyvhdlmodel>=0.32.0
|
|
|
19
19
|
Requires-Dist: tree-sitter-vhdl>=1.2.5
|
|
20
20
|
Requires-Dist: tree-sitter>=0.23.0
|
|
21
21
|
Provides-Extra: dev
|
|
22
|
-
Requires-Dist: coverage==7.
|
|
22
|
+
Requires-Dist: coverage==7.14.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: cryptography==48.0.0; extra == 'dev'
|
|
23
24
|
Requires-Dist: hatch==1.16.5; extra == 'dev'
|
|
24
|
-
Requires-Dist:
|
|
25
|
-
Requires-Dist:
|
|
25
|
+
Requires-Dist: idna==3.16; extra == 'dev'
|
|
26
|
+
Requires-Dist: jaraco-context==6.1.2; extra == 'dev'
|
|
27
|
+
Requires-Dist: mypy==2.1.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pre-commit==4.6.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pygments==2.20.0; extra == 'dev'
|
|
26
30
|
Requires-Dist: pytest-cov==7.1.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest-order==1.4.0; extra == 'dev'
|
|
27
32
|
Requires-Dist: pytest-sugar==1.1.1; extra == 'dev'
|
|
28
33
|
Requires-Dist: pytest-xdist==3.8.0; extra == 'dev'
|
|
29
34
|
Requires-Dist: pytest==9.0.3; extra == 'dev'
|
|
30
|
-
Requires-Dist:
|
|
35
|
+
Requires-Dist: rich==15.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff==0.15.14; extra == 'dev'
|
|
37
|
+
Requires-Dist: ty==0.0.39; extra == 'dev'
|
|
38
|
+
Requires-Dist: uv==0.11.16; extra == 'dev'
|
|
31
39
|
Description-Content-Type: text/markdown
|
|
32
40
|
|
|
33
41
|
# pyVHDLModelTreesitter
|
|
@@ -44,10 +52,6 @@ Description-Content-Type: text/markdown
|
|
|
44
52
|
> Disclaimer: This project is in early development and only implements a
|
|
45
53
|
fraction of the features of [`pyVHDLModel`][pyVHDLModel-github].
|
|
46
54
|
|
|
47
|
-
## Dependencies
|
|
48
|
-
|
|
49
|
-
- Python 3.10 or newer.
|
|
50
|
-
|
|
51
55
|
## Installation
|
|
52
56
|
|
|
53
57
|
### `pip`
|
|
@@ -78,6 +82,29 @@ document = pyVHDLModelTreesitter.Document.from_file("path/to/file.vhd")
|
|
|
78
82
|
|
|
79
83
|
Detailed documentation is currently unavailable.
|
|
80
84
|
|
|
85
|
+
## Setup for Development
|
|
86
|
+
|
|
87
|
+
### Dependencies
|
|
88
|
+
|
|
89
|
+
Developers aiming to contribute to this repository need the following tools:
|
|
90
|
+
|
|
91
|
+
- `make`
|
|
92
|
+
- `uv`
|
|
93
|
+
|
|
94
|
+
All other dependencies are automatically obtained.
|
|
95
|
+
|
|
96
|
+
### Initial setup
|
|
97
|
+
|
|
98
|
+
Simply:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
source ./settings.sh
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
You can `make help` to see what actions are available.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
81
108
|
[precommit-github]: https://github.com/pre-commit/pre-commit
|
|
82
109
|
[pyVHDLModel-Document]: https://vhdl.github.io/pyVHDLModel/pyVHDLModel/pyVHDLModel.html#pyVHDLModel.Document
|
|
83
110
|
[pyVHDLModel-github]: https://github.com/VHDL/pyVHDLModel
|
|
@@ -12,10 +12,6 @@
|
|
|
12
12
|
> Disclaimer: This project is in early development and only implements a
|
|
13
13
|
fraction of the features of [`pyVHDLModel`][pyVHDLModel-github].
|
|
14
14
|
|
|
15
|
-
## Dependencies
|
|
16
|
-
|
|
17
|
-
- Python 3.10 or newer.
|
|
18
|
-
|
|
19
15
|
## Installation
|
|
20
16
|
|
|
21
17
|
### `pip`
|
|
@@ -46,6 +42,29 @@ document = pyVHDLModelTreesitter.Document.from_file("path/to/file.vhd")
|
|
|
46
42
|
|
|
47
43
|
Detailed documentation is currently unavailable.
|
|
48
44
|
|
|
45
|
+
## Setup for Development
|
|
46
|
+
|
|
47
|
+
### Dependencies
|
|
48
|
+
|
|
49
|
+
Developers aiming to contribute to this repository need the following tools:
|
|
50
|
+
|
|
51
|
+
- `make`
|
|
52
|
+
- `uv`
|
|
53
|
+
|
|
54
|
+
All other dependencies are automatically obtained.
|
|
55
|
+
|
|
56
|
+
### Initial setup
|
|
57
|
+
|
|
58
|
+
Simply:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
source ./settings.sh
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
You can `make help` to see what actions are available.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
49
68
|
[precommit-github]: https://github.com/pre-commit/pre-commit
|
|
50
69
|
[pyVHDLModel-Document]: https://vhdl.github.io/pyVHDLModel/pyVHDLModel/pyVHDLModel.html#pyVHDLModel.Document
|
|
51
70
|
[pyVHDLModel-github]: https://github.com/VHDL/pyVHDLModel
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pyVHDLModelTreesitter"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.5.0"
|
|
8
8
|
description = "An implementation of pyVHDLModel using treesitter"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -18,28 +18,35 @@ authors = [
|
|
|
18
18
|
]
|
|
19
19
|
keywords = ["language", "model", "treesitter", "vhdl"]
|
|
20
20
|
classifiers = [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
"Development Status :: 3 - Alpha",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Programming Language :: Python :: 3.14",
|
|
28
|
+
"Intended Audience :: Developers",
|
|
29
29
|
]
|
|
30
30
|
|
|
31
31
|
[project.optional-dependencies]
|
|
32
32
|
dev = [
|
|
33
|
-
"coverage == 7.
|
|
33
|
+
"coverage == 7.14.0",
|
|
34
34
|
"hatch == 1.16.5",
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
"cryptography == 48.0.0", # forced to avoid CVE
|
|
36
|
+
"idna == 3.16", # forced to avoid CVE
|
|
37
|
+
"jaraco-context == 6.1.2", # forced to avoid CVE
|
|
38
|
+
"mypy == 2.1.0",
|
|
39
|
+
"pre-commit == 4.6.0",
|
|
37
40
|
"pytest == 9.0.3",
|
|
38
41
|
"pytest-cov == 7.1.0",
|
|
42
|
+
"pytest-order == 1.4.0",
|
|
39
43
|
"pytest-sugar == 1.1.1",
|
|
40
44
|
"pytest-xdist == 3.8.0",
|
|
41
|
-
"
|
|
42
|
-
|
|
45
|
+
"rich == 15.0.0",
|
|
46
|
+
"pygments == 2.20.0", # forced to avoid CVE
|
|
47
|
+
"ruff == 0.15.14",
|
|
48
|
+
"ty == 0.0.39",
|
|
49
|
+
"uv == 0.11.16",
|
|
43
50
|
]
|
|
44
51
|
|
|
45
52
|
[project.urls]
|
|
@@ -75,11 +82,7 @@ packages = ["src/pyVHDLModelTreesitter"]
|
|
|
75
82
|
|
|
76
83
|
[tool.hatch.envs.hatch-test]
|
|
77
84
|
dependencies = [
|
|
78
|
-
"
|
|
79
|
-
"pytest == 9.0.3",
|
|
80
|
-
"pytest-cov == 7.1.0",
|
|
81
|
-
"pytest-sugar == 1.1.1",
|
|
82
|
-
"pytest-xdist == 3.8.0",
|
|
85
|
+
"pyVHDLModelTreesitter[dev]",
|
|
83
86
|
]
|
|
84
87
|
|
|
85
88
|
[[tool.hatch.envs.hatch-test.matrix]]
|
|
@@ -92,6 +95,7 @@ implicit_reexport = true
|
|
|
92
95
|
|
|
93
96
|
[tool.pytest.ini_options]
|
|
94
97
|
addopts = "--capture=fd -n 0 --cov=pyVHDLModelTreesitter --cov-report html --cov-report xml --verbose --junitxml=.junit.xml -o junit_family=legacy"
|
|
98
|
+
norecursedirs = "oss/*"
|
|
95
99
|
testpaths = [
|
|
96
100
|
"tests",
|
|
97
101
|
]
|
|
@@ -120,7 +124,16 @@ unfixable = [
|
|
|
120
124
|
]
|
|
121
125
|
|
|
122
126
|
[tool.ruff.lint.flake8-self]
|
|
123
|
-
ignore-names = [
|
|
127
|
+
ignore-names = [
|
|
128
|
+
"_AddArchitecture",
|
|
129
|
+
"_AddEntity",
|
|
130
|
+
"_AddPackage",
|
|
131
|
+
"_AddPackageBody",
|
|
132
|
+
]
|
|
124
133
|
|
|
125
134
|
[tool.ruff.lint.isort]
|
|
126
135
|
required-imports = ["from __future__ import annotations"]
|
|
136
|
+
|
|
137
|
+
[tool.ruff.lint.per-file-ignores]
|
|
138
|
+
"tests/**/*.py" = ["S101"]
|
|
139
|
+
"tests/examples/local/**/*.py" = ["D100", "D103", "INP001", "TID252"]
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""Submodule mirroring modified aspects of pyVHDLModel.Association."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"AssociationItem",
|
|
7
|
+
"GenericAssociationItem",
|
|
8
|
+
"ParameterAssociationItem",
|
|
9
|
+
"PortAssociationItem",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
from typing import TYPE_CHECKING, Self
|
|
13
|
+
|
|
14
|
+
from pyVHDLModel.Association import AssociationItem as pyVHDLModel_AssociationItem
|
|
15
|
+
from pyVHDLModel.Association import (
|
|
16
|
+
GenericAssociationItem as pyVHDLModel_GenericAssociationItem,
|
|
17
|
+
)
|
|
18
|
+
from pyVHDLModel.Association import (
|
|
19
|
+
ParameterAssociationItem as pyVHDLModel_ParameterAssociationItem,
|
|
20
|
+
)
|
|
21
|
+
from pyVHDLModel.Association import (
|
|
22
|
+
PortAssociationItem as pyVHDLModel_PortAssociationItem,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
from pyVHDLModelTreesitter._parse import parse_conditional_expression
|
|
26
|
+
from pyVHDLModelTreesitter.Name import selected_or_simple_name
|
|
27
|
+
from pyVHDLModelTreesitter.Symbol import SimpleObjectOrFunctionCallSymbol
|
|
28
|
+
from pyVHDLModelTreesitter.treesitter import (
|
|
29
|
+
TreesitterNodeMixin,
|
|
30
|
+
get_node,
|
|
31
|
+
get_node_text,
|
|
32
|
+
)
|
|
33
|
+
from pyVHDLModelTreesitter.treesitter.query import AssociationElement
|
|
34
|
+
|
|
35
|
+
if TYPE_CHECKING:
|
|
36
|
+
import tree_sitter
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class AssociationItemMixin(TreesitterNodeMixin, pyVHDLModel_AssociationItem):
|
|
40
|
+
@classmethod
|
|
41
|
+
def from_treesitter_node(
|
|
42
|
+
cls,
|
|
43
|
+
node: tree_sitter.Node,
|
|
44
|
+
) -> list[Self]:
|
|
45
|
+
"""Create one or more AssociationItem from a treesitter node."""
|
|
46
|
+
captures = AssociationElement.capture_first_root(node)
|
|
47
|
+
formal_node = get_node(node, captures, "formal", optional=True)
|
|
48
|
+
formal = None
|
|
49
|
+
if formal_node is not None:
|
|
50
|
+
formal = SimpleObjectOrFunctionCallSymbol(
|
|
51
|
+
selected_or_simple_name(get_node_text(formal_node)),
|
|
52
|
+
)
|
|
53
|
+
actual_node = get_node(node, captures, "actual")
|
|
54
|
+
actual = parse_conditional_expression(actual_node)
|
|
55
|
+
if actual is None:
|
|
56
|
+
return []
|
|
57
|
+
return [cls(actual, formal, _treesitter_node=node)]
|
|
58
|
+
|
|
59
|
+
def __eq__(self, other: object) -> bool:
|
|
60
|
+
if not isinstance(other, self.__class__):
|
|
61
|
+
return False
|
|
62
|
+
return self._formal == other._formal and self._actual == other._actual
|
|
63
|
+
|
|
64
|
+
def __hash__(self) -> int:
|
|
65
|
+
return hash(
|
|
66
|
+
(
|
|
67
|
+
self._formal,
|
|
68
|
+
self._actual,
|
|
69
|
+
),
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
def __repr__(self) -> str:
|
|
73
|
+
return (
|
|
74
|
+
f"{self.__class__.__name__}("
|
|
75
|
+
f"_formal={self._formal!r}, "
|
|
76
|
+
f"_actual={self._actual!r}, "
|
|
77
|
+
")"
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class AssociationItem(AssociationItemMixin): # noqa: D101
|
|
82
|
+
pass
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class GenericAssociationItem(AssociationItemMixin, pyVHDLModel_GenericAssociationItem): # noqa: D101
|
|
86
|
+
pass
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class ParameterAssociationItem( # noqa: D101
|
|
90
|
+
AssociationItemMixin,
|
|
91
|
+
pyVHDLModel_ParameterAssociationItem,
|
|
92
|
+
):
|
|
93
|
+
pass
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class PortAssociationItem(AssociationItemMixin, pyVHDLModel_PortAssociationItem): # noqa: D101
|
|
97
|
+
pass
|
{pyvhdlmodeltreesitter-0.3.1 → pyvhdlmodeltreesitter-0.5.0}/src/pyVHDLModelTreesitter/Base.py
RENAMED
|
@@ -6,7 +6,7 @@ __all__ = [
|
|
|
6
6
|
"Range",
|
|
7
7
|
]
|
|
8
8
|
|
|
9
|
-
from typing import TYPE_CHECKING, Self
|
|
9
|
+
from typing import TYPE_CHECKING, Self
|
|
10
10
|
|
|
11
11
|
import pyVHDLModel
|
|
12
12
|
|
|
@@ -20,8 +20,8 @@ from pyVHDLModelTreesitter._errors import (
|
|
|
20
20
|
NodeTextIsNoneError,
|
|
21
21
|
NotImplementedWarning,
|
|
22
22
|
)
|
|
23
|
-
from pyVHDLModelTreesitter.
|
|
24
|
-
from pyVHDLModelTreesitter.treesitter import
|
|
23
|
+
from pyVHDLModelTreesitter._parse import parse_simple_expression
|
|
24
|
+
from pyVHDLModelTreesitter.treesitter import TreesitterNodeMixin
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
def parse_as_direction(string: str) -> pyVHDLModel.Base.Direction | None:
|
|
@@ -67,7 +67,7 @@ def parse_as_mode(string: str) -> pyVHDLModel.Base.Mode | None:
|
|
|
67
67
|
return None
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
class Range(
|
|
70
|
+
class Range(TreesitterNodeMixin, pyVHDLModel.Base.Range): # noqa: D101
|
|
71
71
|
@classmethod
|
|
72
72
|
def from_treesitter_node( # noqa: C901, PLR0912
|
|
73
73
|
cls,
|
|
@@ -98,7 +98,7 @@ class Range(BaseTreesitterNode, pyVHDLModel.Base.Range): # noqa: D101
|
|
|
98
98
|
if left is None:
|
|
99
99
|
raise NodeMissingChildError(node, "first-child")
|
|
100
100
|
if left.type != "simple_expression":
|
|
101
|
-
NotImplementedWarning.warn_child_type(left
|
|
101
|
+
NotImplementedWarning.warn_child_type(left)
|
|
102
102
|
return None
|
|
103
103
|
if left.text is None or len(left.text) == 0:
|
|
104
104
|
raise NodeTextIsNoneError(left)
|
|
@@ -106,7 +106,7 @@ class Range(BaseTreesitterNode, pyVHDLModel.Base.Range): # noqa: D101
|
|
|
106
106
|
if direction_node is None:
|
|
107
107
|
raise NodeMissingChildError(node, "second-child")
|
|
108
108
|
if len(direction_node.type) == 0:
|
|
109
|
-
NotImplementedWarning.warn_child_type(direction_node
|
|
109
|
+
NotImplementedWarning.warn_child_type(direction_node)
|
|
110
110
|
return None
|
|
111
111
|
if direction_node.text is None or len(direction_node.text) == 0:
|
|
112
112
|
raise NodeTextIsNoneError(direction_node)
|
|
@@ -115,7 +115,7 @@ class Range(BaseTreesitterNode, pyVHDLModel.Base.Range): # noqa: D101
|
|
|
115
115
|
if right is None:
|
|
116
116
|
raise NodeMissingChildError(node, "third-child")
|
|
117
117
|
if right.type != "simple_expression":
|
|
118
|
-
NotImplementedWarning.warn_child_type(right
|
|
118
|
+
NotImplementedWarning.warn_child_type(right)
|
|
119
119
|
return None
|
|
120
120
|
if right.text is None or len(right.text) == 0:
|
|
121
121
|
raise NodeTextIsNoneError(right)
|
|
@@ -134,10 +134,8 @@ class Range(BaseTreesitterNode, pyVHDLModel.Base.Range): # noqa: D101
|
|
|
134
134
|
return cls(left_expr, right_expr, direction, _treesitter_node=node)
|
|
135
135
|
|
|
136
136
|
def __eq__(self, other: object) -> bool: # noqa: D105
|
|
137
|
-
if not isinstance(other,
|
|
137
|
+
if not isinstance(other, self.__class__):
|
|
138
138
|
return False
|
|
139
|
-
# Required for LSP completions
|
|
140
|
-
other = cast("Range", other) # type: ignore[redundant-cast]
|
|
141
139
|
return (
|
|
142
140
|
self._leftBound == other._leftBound
|
|
143
141
|
and self._rightBound == other._rightBound
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""Submodule mirroring modified aspects of pyVHDLModel.Concurrent."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"EntityInstantiation",
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
from typing import TYPE_CHECKING, Self
|
|
10
|
+
|
|
11
|
+
from pyVHDLModel.Concurrent import (
|
|
12
|
+
EntityInstantiation as pyVHDLModel_EntityInstantiation,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
from pyVHDLModelTreesitter.Association import (
|
|
16
|
+
GenericAssociationItem,
|
|
17
|
+
PortAssociationItem,
|
|
18
|
+
)
|
|
19
|
+
from pyVHDLModelTreesitter.Name import selected_or_simple_name
|
|
20
|
+
from pyVHDLModelTreesitter.Symbol import ArchitectureSymbol, EntityInstantiationSymbol
|
|
21
|
+
from pyVHDLModelTreesitter.treesitter import (
|
|
22
|
+
TreesitterNodeMixin,
|
|
23
|
+
get_node,
|
|
24
|
+
get_node_text,
|
|
25
|
+
get_nodes,
|
|
26
|
+
)
|
|
27
|
+
from pyVHDLModelTreesitter.treesitter.query import ComponentInstantiationStatement
|
|
28
|
+
|
|
29
|
+
if TYPE_CHECKING:
|
|
30
|
+
import tree_sitter
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class EntityInstantiation(TreesitterNodeMixin, pyVHDLModel_EntityInstantiation): # noqa: D101
|
|
34
|
+
@classmethod
|
|
35
|
+
def from_treesitter_node(
|
|
36
|
+
cls,
|
|
37
|
+
node: tree_sitter.Node,
|
|
38
|
+
) -> list[Self]:
|
|
39
|
+
"""Create one or more `EntityInstantiation`s from a treesitter node."""
|
|
40
|
+
captures = ComponentInstantiationStatement.capture(node)
|
|
41
|
+
label_node = get_node(node, captures, "label")
|
|
42
|
+
label = get_node_text(label_node)
|
|
43
|
+
entity_str = ""
|
|
44
|
+
namespace_node = get_node(node, captures, "namespace", optional=True)
|
|
45
|
+
if namespace_node is not None:
|
|
46
|
+
entity_str = f"{get_node_text(namespace_node)}."
|
|
47
|
+
entity_node = get_node(node, captures, "entity")
|
|
48
|
+
entity_str += get_node_text(entity_node)
|
|
49
|
+
entity_symbol = EntityInstantiationSymbol(
|
|
50
|
+
selected_or_simple_name(entity_str),
|
|
51
|
+
)
|
|
52
|
+
architecture_node = get_node(node, captures, "architecture", optional=True)
|
|
53
|
+
architecture_symbol = None
|
|
54
|
+
if architecture_node is not None:
|
|
55
|
+
architecture_symbol = ArchitectureSymbol(
|
|
56
|
+
selected_or_simple_name(get_node_text(architecture_node)),
|
|
57
|
+
)
|
|
58
|
+
generic_associations = []
|
|
59
|
+
for association_node in get_nodes(node, captures, "generics", optional=True):
|
|
60
|
+
generic_associations.extend(
|
|
61
|
+
GenericAssociationItem.from_treesitter_node(association_node),
|
|
62
|
+
)
|
|
63
|
+
port_associations = []
|
|
64
|
+
for association_node in get_nodes(node, captures, "ports", optional=True):
|
|
65
|
+
port_associations.extend(
|
|
66
|
+
PortAssociationItem.from_treesitter_node(association_node),
|
|
67
|
+
)
|
|
68
|
+
return [
|
|
69
|
+
cls(
|
|
70
|
+
label=label,
|
|
71
|
+
entitySymbol=entity_symbol,
|
|
72
|
+
architectureSymbol=architecture_symbol,
|
|
73
|
+
genericAssociations=generic_associations,
|
|
74
|
+
portAssociations=port_associations,
|
|
75
|
+
_treesitter_node=node,
|
|
76
|
+
),
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
def __eq__(self, other: object) -> bool: # noqa: D105
|
|
80
|
+
if not isinstance(other, self.__class__):
|
|
81
|
+
return False
|
|
82
|
+
return (
|
|
83
|
+
self._label == other._label
|
|
84
|
+
and self._entity == other._entity
|
|
85
|
+
and self._architecture == other._architecture
|
|
86
|
+
and self._genericAssociations == other._genericAssociations
|
|
87
|
+
and self._portAssociations == other._portAssociations
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
def __hash__(self) -> int: # noqa: D105
|
|
91
|
+
return hash(
|
|
92
|
+
(
|
|
93
|
+
self._label,
|
|
94
|
+
self._entity,
|
|
95
|
+
self._architecture,
|
|
96
|
+
self._genericAssociations,
|
|
97
|
+
self._portAssociations,
|
|
98
|
+
),
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
def __repr__(self) -> str: # noqa: D105
|
|
102
|
+
return (
|
|
103
|
+
f"{self.__class__.__name__}("
|
|
104
|
+
f"_label={self._label!r}, "
|
|
105
|
+
f"_entity={self._entity!r}, "
|
|
106
|
+
f"_architecture={self._architecture!r}, "
|
|
107
|
+
f"_genericAssociations={self._genericAssociations!r}, "
|
|
108
|
+
f"_portAssociations={self._portAssociations!r}, "
|
|
109
|
+
")"
|
|
110
|
+
)
|