summaryrefslogtreecommitdiff
path: root/pygments/lexers/other.py
diff options
context:
space:
mode:
authorJames Adams <james.adams@stfc.ac.uk>2013-03-08 12:02:46 +0100
committerJames Adams <james.adams@stfc.ac.uk>2013-03-08 12:02:46 +0100
commitb79ef2d68d605e55dae074cbf9a97260d76785e3 (patch)
tree80d553b08175c04ef8c5f4154ec09b9b98ed3b02 /pygments/lexers/other.py
parent9e8024c742cbdbc8a2bb975f4ee2add6b76bf20c (diff)
downloadpygments-b79ef2d68d605e55dae074cbf9a97260d76785e3.tar.gz
Initial version of lexer for the pan language.
Diffstat (limited to 'pygments/lexers/other.py')
-rw-r--r--pygments/lexers/other.py62
1 files changed, 61 insertions, 1 deletions
diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py
index c8557922..83771a93 100644
--- a/pygments/lexers/other.py
+++ b/pygments/lexers/other.py
@@ -35,7 +35,7 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer',
'ECLLexer', 'UrbiscriptLexer', 'OpenEdgeLexer', 'BroLexer',
'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer',
'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer',
- 'CbmBasicV2Lexer', 'AutoItLexer']
+ 'CbmBasicV2Lexer', 'AutoItLexer', 'PanLexer']
class ECLLexer(RegexLexer):
@@ -3665,3 +3665,63 @@ class AutoItLexer(RegexLexer):
(r'[^\S\n]', Text),
],
}
+
+class PanLexer(RegexLexer):
+ """
+ Lexer for pan source files.
+
+ Based on tcsh lexer.
+ """
+
+ name = 'Pan'
+ aliases = ['pan']
+ filenames = ['*.pan']
+
+ tokens = {
+ 'root': [
+ include('basic'),
+ (r'\$\(', Keyword, 'paren'),
+ (r'\${#?', Keyword, 'curly'),
+ include('data'),
+ ],
+ 'basic': [
+ (r'\b(if|for|with|else|type|bind|while|valid|final|prefix|unique|'
+ r'object|foreach|include|template|function|variable|structure|'
+ r'extensible|declaration)\s*\b',
+ Keyword),
+ (r'\b(file_contents|format|index|length|match|matches|replace|'
+ r'splice|split|substr|to_lowercase|to_uppercase|debug|error|'
+ r'traceback|deprecated|base64_decode|base64_encode|digest|escape|'
+ r'unescape|append|create|first|nlist|key|length|list|merge|next|'
+ r'prepend|splice|is_boolean|is_defined|is_double|is_list|is_long|'
+ r'is_nlist|is_null|is_number|is_property|is_resource|is_string|'
+ r'to_boolean|to_double|to_long|to_string|clone|delete|exists|'
+ r'path_exists|if_exists|return|value)\s*\b',
+ Name.Builtin),
+ (r'#.*\n', Comment),
+ (r'\\[\w\W]', String.Escape),
+ (r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Text, Operator)),
+ (r'[\[\]{}()=]+', Operator),
+ (r'<<\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
+ ],
+ 'data': [
+ (r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
+ (r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
+ (r'\s+', Text),
+ (r'[^=\s\[\]{}()$"\'`\\]+', Text),
+ (r'\d+(?= |\Z)', Number),
+ (r'\$#?(\w+|.)', Name.Variable),
+ ],
+ 'curly': [
+ (r'}', Keyword, '#pop'),
+ (r':-', Keyword),
+ (r'[a-zA-Z0-9_]+', Name.Variable),
+ (r'[^}:"\'`$]+', Punctuation),
+ (r':', Punctuation),
+ include('root'),
+ ],
+ 'paren': [
+ (r'\)', Keyword, '#pop'),
+ include('root'),
+ ],
+ }