Skip to content

Commit

Permalink
merge hdl#10
Browse files Browse the repository at this point in the history
  • Loading branch information
iDoka committed Feb 20, 2024
1 parent 216ce76 commit 269f743
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 51 deletions.
2 changes: 2 additions & 0 deletions hdlparse/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"""Parse Verilog and VHDL files"""
__version__ = '1.1.0'
18 changes: 9 additions & 9 deletions hdlparse/minilexer.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright © 2017 Kevin Thibedeau
# Distributed under the terms of the MIT license
"""Minimalistic lexer engine inspired by the PyPigments RegexLexer"""
import re
import logging

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

__version__ = '1.0.7'

log = logging.getLogger(__name__)
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('%(name)s - %(levelname)s - %(message)s'))
log.addHandler(handler)

if not log.handlers: # only add the handler if no handlers are already registered
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('%(name)s - %(levelname)s - %(message)s'))
log.addHandler(handler)


class MiniLexer(object):
class MiniLexer():
"""Simple lexer state machine with regex matching rules"""

def __init__(self, tokens, flags=re.MULTILINE):
Expand Down Expand Up @@ -53,7 +53,7 @@ def run(self, text):
text (str): Text to apply lexer to
Yields:
A sequence of lexer matches.
A sequence of lexer matches
"""

stack = ['root']
Expand All @@ -66,7 +66,7 @@ def run(self, text):
m = pat.match(text, pos)
if m:
if action:
log.debug(f"Match: {m.group().strip()} -> {action}")
log.debug("Match: %s -> %s", m.group().strip(), action)

yield (pos, m.end() - 1), action, m.groups()

Expand Down
39 changes: 39 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[metadata]
name = hdlparse
author = Kevin Thibedeau
author_email = [email protected]
url = http://kevinpt.github.io/hdlparse
download_url = http://kevinpt.github.io/hdlparse
description = HDL parser
long_description = file: README.rst
description_file = README.rst
version = attr: hdlparse.__version__
license = MIT
keywords = HDL parser
classifiers =
Development Status :: 5 - Production/Stable
Operating System :: OS Independent
Intended Audience :: Developers
Topic :: Text Processing :: General
Natural Language :: English
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License

[options]
packages = hdlparse
py_modules =
install_requires =
include_package_data = True

[pycodestyle]
max_line_length = 120
ignore = E501

[pydocstyle]
ignore = D100,D102,D103,D105,D202,D203,D213,D400,D405,D406,D407,D413,D415

[pylint]
disable =
C0103,C0301,C0103,C0116,R0201,R0801,R0903,R0912,R0913,R0914,R0915,W0702
ignore-docstrings = yes
output-format = colorized
43 changes: 1 addition & 42 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,3 @@
from setuptools import setup

# Use README.rst for the long description
with open('README.rst') as fh:
long_description = fh.read()

# Scan the script for the version string
version_file = 'hdlparse/minilexer.py'
version = None
with open(version_file) as fh:
try:
version = [line.split('=')[1].strip().strip("'") for line in fh if
line.startswith('__version__')][0]
except IndexError:
pass

if version is None:
raise RuntimeError('Unable to find version string in file: {0}'.format(version_file))

setup(name='hdlparse',
version=version,
author='Kevin Thibedeau',
author_email='[email protected]',
url='http://kevinpt.github.io/hdlparse',
download_url='http://kevinpt.github.io/hdlparse',
description='HDL parser',
long_description=long_description,
platforms=['Any'],
install_requires=[],
packages=['hdlparse'],
py_modules=[],
include_package_data=True,

keywords='HDL parser',
license='MIT',
classifiers=['Development Status :: 5 - Production/Stable',
'Operating System :: OS Independent',
'Intended Audience :: Developers',
'Topic :: Text Processing :: General',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License'
]
)
setup()

0 comments on commit 269f743

Please sign in to comment.