Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
Hdlmake
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
15
Issues
15
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Hdlmake
Commits
cbc99517
Commit
cbc99517
authored
Mar 05, 2020
by
Christos Gentsos
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vhdl_parser: handle context declarations and specifications
parent
eb09e8ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
dep_file.py
hdlmake/sourcefiles/dep_file.py
+3
-0
vhdl_parser.py
hdlmake/sourcefiles/vhdl_parser.py
+39
-0
No files found.
hdlmake/sourcefiles/dep_file.py
View file @
cbc99517
...
...
@@ -39,6 +39,7 @@ class DepRelation(object):
ENTITY
=
1
PACKAGE
=
2
ARCHITECTURE
=
3
CONTEXT
=
4
MODULE
=
ENTITY
def
__init__
(
self
,
obj_name
,
lib_name
,
rel_type
):
...
...
@@ -46,6 +47,7 @@ class DepRelation(object):
DepRelation
.
ENTITY
,
DepRelation
.
PACKAGE
,
DepRelation
.
ARCHITECTURE
,
DepRelation
.
CONTEXT
,
DepRelation
.
MODULE
]
self
.
rel_type
=
rel_type
self
.
obj_name
=
obj_name
.
lower
()
...
...
@@ -62,6 +64,7 @@ class DepRelation(object):
self
.
ENTITY
:
"entity"
,
self
.
PACKAGE
:
"package"
,
self
.
ARCHITECTURE
:
"architecture"
,
self
.
CONTEXT
:
"context"
,
self
.
MODULE
:
"module"
}
return
"
%
s '
%
s.
%
s'"
%
(
ostr
[
self
.
rel_type
],
self
.
lib_name
or
''
,
...
...
hdlmake/sourcefiles/vhdl_parser.py
View file @
cbc99517
...
...
@@ -77,6 +77,45 @@ class VHDLParser(DepParser):
return
"<hdlmake use_pattern
%
s.
%
s>"
%
(
lib_name
,
pkg_name
)
buf
=
re
.
sub
(
use_pattern
,
do_use
,
buf
)
use_context_pattern
=
re
.
compile
(
r"^\s*context\s+(\w+)\s*\.\s*(\w+)\s*;"
,
re
.
DOTALL
|
re
.
MULTILINE
|
re
.
IGNORECASE
)
def
do_use_context
(
text
):
"""Function to be applied by re.sub to every match of the
context_pattern in the VHDL code -- group() returns positive matches
as indexed plain strings. It adds the found CONTEXT relations to the
file"""
lib_name
=
text
.
group
(
1
)
.
lower
()
pkg_name
=
text
.
group
(
2
)
.
lower
()
if
lib_name
==
"work"
:
# Work is an alias for the current library
lib_name
=
dep_file
.
library
logging
.
debug
(
"use package
%
s.
%
s"
,
lib_name
,
pkg_name
)
dep_file
.
add_require
(
DepRelation
(
pkg_name
,
lib_name
,
DepRelation
.
CONTEXT
))
return
"<hdlmake use_pattern
%
s.
%
s>"
%
(
lib_name
,
pkg_name
)
buf
=
re
.
sub
(
use_context_pattern
,
do_use_context
,
buf
)
context_declaration_pattern
=
re
.
compile
(
r"^\s*context\s+(?P<name>\w+)\s+is\s+"
r".*?"
r"end\s*(context\s*)?(?P=name)?\s*;"
,
re
.
DOTALL
|
re
.
MULTILINE
|
re
.
IGNORECASE
)
def
do_context_declaration
(
text
):
"""Function to be applied by re.sub to every match of the
context_declaration_pattern in the VHDL code -- group() returns
positive matches as indexed plain strings. It adds the found PROVIDE
relations to the file
"""
ctx_name
=
text
.
group
(
1
)
logging
.
debug
(
"found entity
%
s.
%
s"
,
dep_file
.
library
,
ctx_name
)
dep_file
.
add_provide
(
DepRelation
(
ctx_name
,
dep_file
.
library
,
DepRelation
.
CONTEXT
))
return
"<hdlmake entity_pattern
%
s.
%
s>"
%
(
dep_file
.
library
,
ctx_name
)
buf
=
re
.
sub
(
context_declaration_pattern
,
do_context_declaration
,
buf
)
# new entity
entity_pattern
=
re
.
compile
(
r"^\s*entity\s+(?P<name>\w+)\s+is\s+"
...
...
Christos Gentsos
@cgentsos
mentioned in commit
e6ab358e
·
Apr 06, 2020
mentioned in commit
e6ab358e
mentioned in commit e6ab358eddf7ced1b442546404f7a59ef794f861
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment