Skip to content

Commit b31ba69

Browse files
committed
Change from print statements to using the logging module
Signed-off-by: Wouter van Verre <[email protected]>
1 parent d0ca8f0 commit b31ba69

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

hdlparse/minilexer.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
from __future__ import print_function
55

66
import re
7+
import logging
78

89
"""Minimalistic lexer engine inspired by the PyPigments RegexLexer"""
910

1011
__version__ = '1.0.7'
1112

13+
log = logging.getLogger(__name__)
14+
handler = logging.StreamHandler()
15+
handler.setFormatter(logging.Formatter('%(name)s - %(levelname)s - %(message)s'))
16+
log.addHandler(handler)
17+
1218

1319
class MiniLexer(object):
1420
"""Simple lexer state machine with regex matching rules"""
@@ -62,8 +68,8 @@ def run(self, text):
6268
m = pat.match(text, pos)
6369
if m:
6470
if action:
65-
# print('## MATCH: {} -> {}'.format(m.group(), action))
66-
# print(m.string[m.pos:m.endpos])
71+
log.debug('Match: {} -> {}'.format(m.group().strip(), action))
72+
6773
yield (pos, m.end() - 1), action, m.groups()
6874

6975
pos = m.end()
@@ -74,7 +80,6 @@ def run(self, text):
7480
else:
7581
stack.append(new_state)
7682

77-
# print('## CHANGE STATE:', pos, new_state, stack)
7883
patterns = self.tokens[stack[-1]]
7984

8085
break

hdlparse/verilog_parser.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ def parse_verilog(text):
149149
objects = []
150150

151151
for pos, action, groups in lex.run(text):
152-
153-
print(pos, action, groups)
154-
155152
if action == 'metacomment':
156153
comment = groups[0].strip()
157154
if last_item is None:

0 commit comments

Comments
 (0)