diff options
-rw-r--r-- | pygments/lexers/_mapping.py | 1 | ||||
-rw-r--r-- | pygments/lexers/other.py | 62 | ||||
-rw-r--r-- | tests/examplefiles/test.pan | 54 |
3 files changed, 116 insertions, 1 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 20d3ce75..b2d5777a 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -245,6 +245,7 @@ LEXERS = { 'OocLexer': ('pygments.lexers.compiled', 'Ooc', ('ooc',), ('*.ooc',), ('text/x-ooc',)), 'OpaLexer': ('pygments.lexers.functional', 'Opa', ('opa',), ('*.opa',), ('text/x-opa',)), 'OpenEdgeLexer': ('pygments.lexers.other', 'OpenEdge ABL', ('openedge', 'abl', 'progress'), ('*.p', '*.cls'), ('text/x-openedge', 'application/x-openedge')), + 'PanLexer': ('pygments.lexers.other', 'Pan', ('pan',), ('*.pan',), ()), 'PawnLexer': ('pygments.lexers.other', 'Pawn', ('pawn',), ('*.p', '*.pwn', '*.inc'), ('text/x-pawn',)), 'Perl6Lexer': ('pygments.lexers.agile', 'Perl6', ('perl6', 'pl6'), ('*.pl', '*.pm', '*.nqp', '*.p6', '*.6pl', '*.p6l', '*.pl6', '*.6pm', '*.p6m', '*.pm6', '*.t'), ('text/x-perl6', 'application/x-perl6')), 'PerlLexer': ('pygments.lexers.agile', 'Perl', ('perl', 'pl'), ('*.pl', '*.pm', '*.t'), ('text/x-perl', 'application/x-perl')), diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 7dc8c8a6..91b3dd5d 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -38,7 +38,7 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer', 'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer', 'CbmBasicV2Lexer', 'AutoItLexer', 'RexxLexer', 'APLLexer', 'LSLLexer', 'AmbientTalkLexer', 'PawnLexer', 'VCTreeStatusLexer', - 'RslLexer'] + 'RslLexer', 'PanLexer'] class LSLLexer(RegexLexer): @@ -4176,3 +4176,63 @@ class RslLexer(RegexLexer): return 1.0 else: return 0.01 + + +class PanLexer(RegexLexer): + """ + Lexer for `pan <http://github.com/quattor/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), + ], + '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'), + ], + } diff --git a/tests/examplefiles/test.pan b/tests/examplefiles/test.pan new file mode 100644 index 00000000..56c8bd62 --- /dev/null +++ b/tests/examplefiles/test.pan @@ -0,0 +1,54 @@ +object template pantest; + +# Very simple pan test file +"/long/decimal" = 123; +"/long/octal" = 0755; +"/long/hexadecimal" = 0xFF; + +"/double/simple" = 0.01; +"/double/pi" = 3.14159; +"/double/exponent" = 1e-8; +"/double/scientific" = 1.3E10; + +"/string/single" = 'Faster, but escapes like \t, \n and \x3d don''t work, but '' should work.'; +"/string/double" = "Slower, but escapes like \t, \n and \x3d do work"; + +variable TEST = 2; + +"/x2" = to_string(TEST); +"/x2" ?= 'Default value'; + +"/x3" = 1 + 2 + value("/long/decimal"); + +"/x4" = undef; + +"/x5" = null; + +variable e ?= error("Test error message"); + +# include gmond config for services-monitoring +include { 'site/ganglia/gmond/services-monitoring' }; + +"/software/packages"=pkg_repl("httpd","2.2.3-43.sl5.3",PKG_ARCH_DEFAULT); +"/software/packages"=pkg_repl("php"); + +# Example function +function show_things_view_for_stuff = { + thing = ARGV[0]; + foreach( i; mything; STUFF ) { + if ( thing == mything ) { + return( true ); + } else { + return SELF; + }; + }; + false; +}; + +variable HERE = <<EOF; +; This example demonstrates an in-line heredoc style config file +[main] +awesome = true +EOF + +variable small = false;#This should be highlighted normally again. |