Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
V
VHDL Coding Style
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
VHDL Coding Style
Commits
6e8f53ca
Commit
6e8f53ca
authored
Aug 24, 2022
by
Nathan Pittet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip: port to new ghdl version
parent
a09ca352
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
41 deletions
+42
-41
setup.py
setup.py
+1
-1
rulesexec.py
vhdllint/rulesexec.py
+39
-37
utils.py
vhdllint/utils.py
+2
-3
No files found.
setup.py
View file @
6e8f53ca
...
...
@@ -47,6 +47,6 @@ setup(
packages
=
[
'vhdllint'
,
'vhdllint.filerules'
,
'vhdllint.lexrules'
,
'vhdllint.semrules'
,
'vhdllint.syntaxrules'
,
'vhdllint.synthrules'
],
install_requires
=
[
'
libghdl
'
],
install_requires
=
[
'
pyGHDL
'
],
**
kwargs
)
vhdllint/rulesexec.py
View file @
6e8f53ca
import
libghdl.thin
as
thin
import
libghdl.thinutils
as
thinutils
import
libghdl.tokens
as
tokens
import
libghdl.iirs
as
iirs
from
utils
import
Location
,
TokLocation
,
fatal
from
filerules
import
FileRule
from
lexrules
import
LexRule
from
syntaxrules
import
SyntaxRule
,
SyntaxNodeRule
from
semrules
import
SemRule
,
SemNodeRule
from
synthrules
import
SynthesisRule
import
pyGHDL.libghdl.vhdl.tokens
as
tokens
import
pyGHDL.libghdl.vhdl.nodes
as
nodes
import
pyGHDL.libghdl.libraries
as
libraries
import
pyGHDL.libghdl.vhdl.scanner
as
scanner
from
pyGHDL.libghdl.utils
import
chain_iter
,
nodes_iter
import
pyGHDL.libghdl.vhdl.nodes
from
vhdllint.utils
import
Location
,
TokLocation
,
fatal
from
vhdllint.filerules
import
FileRule
from
vhdllint.lexrules
import
LexRule
from
vhdllint.syntaxrules
import
SyntaxRule
,
SyntaxNodeRule
from
vhdllint.semrules
import
SemRule
,
SemNodeRule
from
vhdllint.synthrules
import
SynthesisRule
import
ctypes
import
os.path
import
sys
...
...
@@ -116,26 +118,26 @@ class RulesExec(object):
r
.
check
(
loc
,
flines
)
# Then tokens
thin
.
S
canner
.
Flag_Comment
.
value
=
True
s
canner
.
Flag_Comment
.
value
=
True
for
input
in
inputs
:
if
'import'
not
in
input
.
props
:
thin
.
S
canner
.
Set_File
(
input
.
fe
)
s
canner
.
Set_File
(
input
.
fe
)
filebuf
=
input
.
filebuf
while
True
:
thin
.
S
canner
.
Scan
()
tok
=
thin
.
S
canner
.
Current_Token
.
value
s
canner
.
Scan
()
tok
=
s
canner
.
Current_Token
.
value
loc
=
TokLocation
(
input
.
filename
,
thin
.
S
canner
.
Get_Current_Line
(),
thin
.
S
canner
.
Get_Token_Column
(),
thin
.
S
canner
.
Get_Token_Position
(),
thin
.
S
canner
.
Get_Position
())
s
canner
.
Get_Current_Line
(),
s
canner
.
Get_Token_Column
(),
s
canner
.
Get_Token_Position
(),
s
canner
.
Get_Position
())
if
tok
==
tokens
.
Tok
.
Comment
:
input
.
comments
[
loc
.
line
]
=
(
loc
.
start
,
loc
.
end
)
for
r
in
self
.
_lex_rules
:
r
.
check
(
loc
,
filebuf
,
tok
)
if
tok
==
tokens
.
Tok
.
Eof
:
break
thin
.
S
canner
.
Close_File
()
s
canner
.
Close_File
()
if
not
(
self
.
_syntax_rules
or
self
.
_syntax_node_rules
or
self
.
_sem_rules
or
self
.
_sem_node_rules
or
self
.
_synth_rules
):
...
...
@@ -143,27 +145,27 @@ class RulesExec(object):
# Then syntax
# The parser doesn't handle comments
thin
.
S
canner
.
Flag_Comment
.
value
=
False
s
canner
.
Flag_Comment
.
value
=
False
# Keep extra locations
thin
.
Flags
.
Flag_Elocations
.
value
=
True
# Keep all parenthesis
thin
.
Parse
.
Flag_Parse_Parenthesis
.
value
=
True
# Be sure to initialize std and work (and only once).
# Humm, not very elegant.
if
thin
.
Get_Libraries_Chain
()
==
thin
.
Null_Iir
:
if
thin
.
Get_Libraries_Chain
()
==
nodes
.
Null_Iir
:
thin
.
analyze_init
()
for
input
in
inputs
:
thin
.
S
canner
.
Set_File
(
input
.
fe
)
s
canner
.
Set_File
(
input
.
fe
)
loc
=
Location
(
input
.
filename
)
input
.
ast
=
thin
.
Parse
.
Parse_Design_File
()
if
'import'
not
in
input
.
props
:
for
r
in
self
.
_syntax_rules
:
r
.
check
(
input
,
input
.
ast
)
if
self
.
_syntax_node_rules
:
for
n
in
thinutils
.
nodes_iter
(
input
.
ast
):
for
n
in
nodes_iter
(
input
.
ast
):
for
r
in
self
.
_syntax_node_rules
:
r
.
check
(
loc
,
n
)
thin
.
S
canner
.
Close_File
()
s
canner
.
Close_File
()
# Then semantic
if
self
.
_sem_rules
or
self
.
_sem_node_rules
or
self
.
_synth_rules
:
...
...
@@ -174,11 +176,11 @@ class RulesExec(object):
# First add all units in the work library, so that they they are
# known by the analyzer.
for
input
in
inputs
:
unit_ast
=
iirs
.
Get_First_Design_Unit
(
input
.
ast
)
while
unit_ast
!=
thin
.
Null_Iir
:
unit_ast
=
Get_First_Design_Unit
(
input
.
ast
)
while
unit_ast
!=
nodes
.
Null_Iir
:
# Detach the unit from its design file
next_unit_ast
=
iirs
.
Get_Chain
(
unit_ast
)
iirs
.
Set_Chain
(
unit_ast
,
thin
.
Null_Iir
)
next_unit_ast
=
Get_Chain
(
unit_ast
)
Set_Chain
(
unit_ast
,
nodes
.
Null_Iir
)
# Add
thin
.
Add_Design_Unit_Into_Library
(
unit_ast
,
False
)
input
.
units_ast
.
append
(
unit_ast
)
...
...
@@ -187,26 +189,26 @@ class RulesExec(object):
for
input
in
inputs
:
if
'import'
not
in
input
.
props
:
for
unit
in
input
.
units_ast
:
if
iirs
.
Get_Library_Unit
(
unit
)
==
thin
.
Null_Iir
:
if
Get_Library_Unit
(
unit
)
==
nodes
.
Null_Iir
:
# Over-written.
# FIXME: remove from the list ?
continue
# Be sure the unit was analyzed. It could have been
# already analyzed if referenced. And a unit cannot be
# analyzed twice.
if
iirs
.
Get_Date_State
(
unit
)
==
iirs
.
Date_State
.
Parse
:
if
Get_Date_State
(
unit
)
==
Date_State
.
Parse
:
thin
.
Finish_Compilation
(
unit
,
False
)
iirs
.
Set_Date_State
(
unit
,
iirs
.
Date_State
.
Analyze
)
Set_Date_State
(
unit
,
Date_State
.
Analyze
)
for
r
in
self
.
_sem_rules
:
r
.
check
(
input
,
unit
)
for
n
in
thinutils
.
nodes_iter
(
unit
):
for
n
in
nodes_iter
(
unit
):
for
r
in
self
.
_sem_node_rules
:
r
.
check
(
input
,
n
)
for
input
in
inputs
:
if
'synth'
in
input
.
props
:
for
unit
in
input
.
units_ast
:
if
iirs
.
Get_Library_Unit
(
unit
)
==
thin
.
Null_Iir
:
if
Get_Library_Unit
(
unit
)
==
nodes
.
Null_Iir
:
# Over-written.
continue
for
r
in
self
.
_synth_rules
:
...
...
@@ -271,10 +273,10 @@ class TestRun(RulesExec):
os
.
path
.
join
(
basedir
,
f
),
files
)
# Be sure the work library is empty. This is brut force.
work
=
thin
.
Work_Library
.
value
if
work
!=
thin
.
Null_Iir
:
for
f
in
thinutils
.
chain_iter
(
iirs
.
Get_Design_File_Chain
(
work
)):
thin
.
Purge_Design_File
(
f
)
iirs
.
Set_Design_File_Chain
(
work
,
thin
.
Null_Iir
)
if
work
!=
nodes
.
Null_Iir
:
for
f
in
chain_iter
(
Get_Design_File_Chain
(
work
)):
libraries
.
Purge_Design_File
(
f
)
Set_Design_File_Chain
(
work
,
nodes
.
Null_Iir
)
self
.
add
(
rule
)
self
.
execute
(
files
)
if
not
self
.
is_ok
():
...
...
vhdllint/utils.py
View file @
6e8f53ca
import
sys
import
libghdl.iirs
as
iirs
import
libghdl.thin
as
thin
import
pyGHDL.libghdl.vhdl.nodes
def
Location_To_File_Line_Col
(
loc
):
...
...
@@ -27,7 +26,7 @@ class Location(object):
@
classmethod
def
from_node
(
cls
,
n
):
return
Location
.
from_location
(
iirs
.
Get_Location
(
n
))
return
Location
.
from_location
(
Get_Location
(
n
))
class
TokLocation
(
Location
):
...
...
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