Skip to content

Commit

Permalink
Add missing support for preprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
amykyta3 committed Sep 17, 2020
1 parent 7f047d7 commit 212d28b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: python
python:
- 3.8

stages:
# Only execute deployment stage on tagged release commits in the form of "v1.2.3"
# and from your repository (e.g. not PRs).
# Also allows alpha/beta releases such as "v1.2.3b2"
- name: deploy
if: repo = SystemRDL/pygments-systemrdl AND tag =~ ^v\d+\.\d+\.\w+$

jobs:
include:
# Deploy source distribution
- stage: deploy
name: Deploy source distribution
install: python -m pip install twine
script: python setup.py sdist --formats=gztar
after_success: python -m twine upload --skip-existing dist/*.tar.gz
1 change: 1 addition & 0 deletions rdl_pygments/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.2.0"
25 changes: 13 additions & 12 deletions rdl_pygments/rdllexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,22 @@ class SystemRDLLexer(lexer.RegexLexer):
(lexer.words((
'external', 'abstract', 'alias', 'unsigned'
), suffix=r'\b'), token.Keyword),

(lexer.words((
'bit', 'boolean', 'onreadtype', 'onwritetype', 'string',
'accesstype', 'addressingtype', 'component',
'accesstype', 'addressingtype', 'component', 'longint'
), suffix=r'\b'), token.Keyword.Type),

lexer.include('literals'),
(r'[#{}()\[\],.;\']', token.Punctuation),
(r'[~!%^&*+-=|?:<>/-@]', token.Operator),
(r'[a-zA-Z][\w]*', token.Name),
(r'\s', token.Text)
(r'\\\r?\n', token.Text),
(r'\s', token.Text),
],

'comments': [
(r'(?s)/\*.*\*/', token.Comment.Multiline),
(r'(?s)/\*.*?\*/', token.Comment.Multiline),
(r'//.*?$', token.Comment.Single),
],

Expand All @@ -47,13 +48,13 @@ class SystemRDLLexer(lexer.RegexLexer):
],

'verilog_pp': [
(r'`[ \t]*include[ \t]+(<[^"\r\n]+>|"[^"\r\n]+")', token.Comment.Preproc),
(r'`[ \t]*define', token.Comment.Preproc, 'verilog_define')
],
'verilog_define':[
(r'\n', token.Comment.Preproc, '#pop'),
(r'\\\n', token.Comment.Preproc),
(r'[^\\\n]+', token.Comment.Preproc), # all other characters
(r'`[ \t]*include', token.Comment.Preproc),
(r'`[ \t]*(ifdef|ifndef|elsif)', token.Comment.Preproc),
(r'`[ \t]*(else|endif)', token.Comment.Preproc),
(r'`[ \t]*undef', token.Comment.Preproc),
(r'`[ \t]*line', token.Comment.Preproc),
(r'`[ \t]*define', token.Comment.Preproc),
(r'`[ \t]*\w+', token.Comment.Preproc),
],

'literals': [
Expand All @@ -74,11 +75,11 @@ class SystemRDLLexer(lexer.RegexLexer):
],

'prop-assign': [
#(r'(\w+)\s*(;)', lexer.bygroups(token.Name.Attribute, token.Operator)),
(r'(\w+)(\s*)(=)', lexer.bygroups(token.Name.Attribute, token.Text, token.Operator)),
(r'(->)(\s*)(\w+)(\s*)(=)', lexer.bygroups(
token.Operator, token.Text, token.Name.Attribute, token.Text, token.Operator
)),
#(r'(\w+)\s*(;)', lexer.bygroups(token.Name.Attribute, token.Operator)),
],

'comp-def': [
Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
with open("README.md", "r") as fh:
long_description = fh.read()

with open(os.path.join("rdl_pygments", "__about__.py")) as f:
v_dict = {}
exec(f.read(), v_dict)
version = v_dict['__version__']

setuptools.setup (
name='pygments-systemrdl',
version="1.1.0",
version=version,
author="Alex Mykyta",
author_email="[email protected]",
description="SystemRDL 2.0 lexer extension for Pygments",
Expand Down

0 comments on commit 212d28b

Please sign in to comment.