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-861f7616d084
master
Giel van Schijndel 2008-04-26 23:38:28 +00:00
parent cacf875ca9
commit 56e269d2c1
2 changed files with 42 additions and 0 deletions

View File

@ -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
"""
)

View File

@ -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'),
]
}