Add a lexer for Pygments (a generic syntax highlighter in Python)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4807 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
cacf875ca9
commit
56e269d2c1
|
@ -0,0 +1,16 @@
|
|||
from setuptools import find_packages, setup
|
||||
|
||||
setup(
|
||||
name='warzone-pygments',
|
||||
version='0.1',
|
||||
packages=find_packages(exclude=['*.tests*']),
|
||||
author="Giel van Schijndel",
|
||||
author_email="me@mortis.eu",
|
||||
description="This plugin adds the capability to Pygments to lex Warzone Resource Files (WRF).",
|
||||
license="GPL",
|
||||
url="http://wz2100.net/",
|
||||
entry_points = """
|
||||
[pygments.lexers]
|
||||
wrflexer = warzone:WRFLexer
|
||||
"""
|
||||
)
|
|
@ -0,0 +1,26 @@
|
|||
from pygments.lexer import RegexLexer
|
||||
from pygments.token import *
|
||||
|
||||
class WRFLexer(RegexLexer):
|
||||
name = 'WRF'
|
||||
aliases = ['wrf']
|
||||
filenames = ['*.wrf']
|
||||
|
||||
tokens = {
|
||||
'root': [
|
||||
(r'/\*', Comment.Multiline, 'comment'),
|
||||
(r'\bdirectory\b', Keyword),
|
||||
(r'\bfile\b', Keyword, 'file_line'),
|
||||
(r'"[^"]*"', String),
|
||||
(r'[ \t\n\x0d\x0a]+', Whitespace),
|
||||
],
|
||||
'comment': [
|
||||
(r'[^*]+', Comment.Multiline),
|
||||
(r'\*/', Comment.Multiline, '#pop'),
|
||||
(r'\*[^/]', Comment.Multiline),
|
||||
],
|
||||
'file_line': [
|
||||
(r'[ \t\n\x0d\x0a]+', Whitespace),
|
||||
(r'[^ \t\n\x0d\x0a]+', Literal, '#pop'),
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue