summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2013-01-09 12:14:41 +0100
committerGeorg Brandl <georg@python.org>2013-01-09 12:14:41 +0100
commit689d5ffc5d5a38e6ca38ef22db1c3c4357cd0fbf (patch)
tree1dc4a937d3f7e10f09aef36b39bbac7b23a0dac4
parent5d312870aa17cd405fbcff1e117afa8689a563ab (diff)
downloadpygments-689d5ffc5d5a38e6ca38ef22db1c3c4357cd0fbf.tar.gz
Move Puppet lexer to other.py, add changelog entry.
-rw-r--r--CHANGES1
-rw-r--r--pygments/lexers/_mapping.py2
-rw-r--r--pygments/lexers/other.py93
-rw-r--r--pygments/lexers/puppet.py103
4 files changed, 94 insertions, 105 deletions
diff --git a/CHANGES b/CHANGES
index 13b06245..b671746b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -23,6 +23,7 @@ Version 1.6
* LiveScript (PR#84)
* Monkey (PR#117)
* Mscgen (PR#80)
+ * Puppet (PR#133)
* Racket (PR#94)
* Rdoc (PR#99)
* Robot Framework (PR#137)
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index a6090c75..9bc8c395 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -208,7 +208,7 @@ LEXERS = {
'PrologLexer': ('pygments.lexers.compiled', 'Prolog', ('prolog',), ('*.prolog', '*.pro', '*.pl'), ('text/x-prolog',)),
'PropertiesLexer': ('pygments.lexers.text', 'Properties', ('properties',), ('*.properties',), ('text/x-java-properties',)),
'ProtoBufLexer': ('pygments.lexers.other', 'Protocol Buffer', ('protobuf',), ('*.proto',), ()),
- 'PuppetLexer': ('pygments.lexers.puppet', 'Puppet', ('puppet',), ('*.pp',), ()),
+ 'PuppetLexer': ('pygments.lexers.other', 'Puppet', ('puppet',), ('*.pp',), ()),
'PyPyLogLexer': ('pygments.lexers.text', 'PyPy Log', ('pypylog', 'pypy'), ('*.pypylog',), ('application/x-pypylog',)),
'Python3Lexer': ('pygments.lexers.agile', 'Python 3', ('python3', 'py3'), (), ('text/x-python3', 'application/x-python3')),
'Python3TracebackLexer': ('pygments.lexers.agile', 'Python 3.0 Traceback', ('py3tb',), ('*.py3tb',), ('text/x-python3-traceback',)),
diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py
index 75a04a8a..e771475c 100644
--- a/pygments/lexers/other.py
+++ b/pygments/lexers/other.py
@@ -34,7 +34,7 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer',
'HybrisLexer', 'AwkLexer', 'Cfengine3Lexer', 'SnobolLexer',
'ECLLexer', 'UrbiscriptLexer', 'OpenEdgeLexer', 'BroLexer',
'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer',
- 'RobotFrameworkLexer']
+ 'RobotFrameworkLexer', 'PuppetLexer']
class ECLLexer(RegexLexer):
@@ -3161,3 +3161,94 @@ class SourcePawnLexer(RegexLexer):
elif value in self._functions:
token = Name.Builtin
yield index, token, value
+
+
+class PuppetLexer(RegexLexer):
+ """
+ For `Puppet <http://puppetlabs.com/>`__ configuration DSL.
+
+ *New in Pygments 1.6.*
+ """
+ name = 'Puppet'
+ aliases = ['puppet']
+ filenames = ['*.pp']
+
+ tokens = {
+ 'root': [
+ include('comments'),
+ include('keywords'),
+ include('names'),
+ include('numbers'),
+ include('operators'),
+ include('strings'),
+
+ (r'[]{}:(),;[]', Punctuation),
+ (r'[^\S\n]+', Text),
+ ],
+
+ 'comments': [
+ (r'\s*#.*$', Comment),
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
+ ],
+
+ 'operators': [
+ (r'(=>|\?|<|>|=|\+|-|\/|\*|~|!|\|)', Operator),
+ (r'\s+(in|and|or|not)\s+', Operator.Word),
+ ],
+
+ 'names': [
+ ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Attribute),
+ (r'(\$\S+)(\[)(\S+)(\])', bygroups(Name.Variable, Punctuation,
+ String, Punctuation)),
+ (r'\$\S+', Name.Variable),
+ ],
+
+ 'numbers': [
+ # Copypasta from the Python lexer
+ (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
+ (r'\d+[eE][+-]?[0-9]+j?', Number.Float),
+ (r'0[0-7]+j?', Number.Oct),
+ (r'0[xX][a-fA-F0-9]+', Number.Hex),
+ (r'\d+L', Number.Integer.Long),
+ (r'\d+j?', Number.Integer)
+ ],
+
+ 'keywords': [
+ # Left out 'group' and 'require'
+ # Since they're often used as attributes
+ (r'(?i)\s(absent|alert|alias|audit|augeas|before)\s', Keyword),
+ (r'(?i)\s(case|check|class|computer|configured)\s', Keyword),
+ (r'(?i)\s(contained|create_resources|crit|cron)\s', Keyword),
+ (r'(?i)\s(debug|default|define|defined|directory)\s', Keyword),
+ (r'(?i)\s(else|elsif|emerg|err|exec|extlookup)\s', Keyword),
+ (r'(?i)\s(fail|false|file|filebucket|fqdn_rand)\s', Keyword),
+ (r'(?i)\s(generate|host|if|import|include|info)\s', Keyword),
+ (r'(?i)\s(inherits|inline_template|installed)\s', Keyword),
+ (r'(?i)\s(interface|k5login|latest|link|loglevel)\s', Keyword),
+ (r'(?i)\s(macauthorization|mailalias|maillist)\s', Keyword),
+ (r'(?i)\s(mcx|md5|mount|mounted|nagios_command)\s', Keyword),
+ (r'(?i)\s(nagios_contact|nagios_contactgroup)\s', Keyword),
+ (r'(?i)\s(nagios_host|nagios_hostdependency)\s', Keyword),
+ (r'(?i)\s(nagios_hostescalation|nagios_hostextinfo)\s', Keyword),
+ (r'(?i)\s(nagios_hostgroup|nagios_service)\s', Keyword),
+ (r'(?i)\s(nagios_servicedependency)\s', Keyword),
+ (r'(?i)\s(nagios_serviceescalation)\s', Keyword),
+ (r'(?i)\s(nagios_serviceextinfo)\s', Keyword),
+ (r'(?i)\s(nagios_servicegroup|nagios_timeperiod)\s', Keyword),
+ (r'(?i)\s(node|noop|notice|notify)\s', Keyword),
+ (r'(?i)\s(package|present|purged|realize|regsubst)\s', Keyword),
+ (r'(?i)\s(resources|role|router|running)\s', Keyword),
+ (r'(?i)\s(schedule|scheduled_task|search|selboolean)\s', Keyword),
+ (r'(?i)\s(selmodule|service|sha1|shellquote|split)\s', Keyword),
+ (r'(?i)\s(sprintf|ssh_authorized_key|sshkey|stage)\s', Keyword),
+ (r'(?i)\s(stopped|subscribe|tag|tagged|template|tidy)\s', Keyword),
+ (r'(?i)\s(true|undef|unmounted|user|versioncmp|vlan)\s', Keyword),
+ (r'(?i)\s(warning|yumrepo|zfs|zone|zpool)\s', Keyword),
+ ],
+
+ 'strings': [
+ (r'"([^"])*"', String),
+ (r'\'([^\'])*\'', String),
+ ],
+
+ }
diff --git a/pygments/lexers/puppet.py b/pygments/lexers/puppet.py
deleted file mode 100644
index fefdb549..00000000
--- a/pygments/lexers/puppet.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- pygments.lexers.puppet
- ~~~~~~~~~~~~~~~~~~~~~~
-
- Lexer for the Puppet DSL.
-
- :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
-
-from pygments.lexer import RegexLexer, bygroups, include
-from pygments.token import Comment, Keyword, Name, Number, Operator
-from pygments.token import Punctuation, String, Text
-
-
-__all__ = ['PuppetLexer']
-
-
-class PuppetLexer(RegexLexer):
- name = 'Puppet'
- aliases = ['puppet']
- filenames = ['*.pp']
-
- tokens = {
- 'root': [
- include('comments'),
- include('keywords'),
- include('names'),
- include('numbers'),
- include('operators'),
- include('strings'),
-
- (r'[]{}:(),;[]', Punctuation),
- (r'[^\S\n]+', Text),
- ],
-
- 'comments': [
- (r'\s*#.*$', Comment),
- (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
- ],
-
- 'operators': [
- (r'(=>|\?|<|>|=|\+|-|\/|\*|~|!|\|)', Operator),
- (r'\s+(in|and|or|not)\s+', Operator.Word),
- ],
-
- 'names': [
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Attribute),
- (r'(\$\S+)(\[)(\S+)(\])', bygroups(Name.Variable, Punctuation,
- String, Punctuation)),
- (r'\$\S+', Name.Variable),
- ],
-
- 'numbers': [
- # Copypasta from the Python lexer
- (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
- (r'\d+[eE][+-]?[0-9]+j?', Number.Float),
- (r'0[0-7]+j?', Number.Oct),
- (r'0[xX][a-fA-F0-9]+', Number.Hex),
- (r'\d+L', Number.Integer.Long),
- (r'\d+j?', Number.Integer)
- ],
-
- 'keywords': [
- # Left out 'group' and 'require'
- # Since they're often used as attributes
- (r'(?i)\s(absent|alert|alias|audit|augeas|before)\s', Keyword),
- (r'(?i)\s(case|check|class|computer|configured)\s', Keyword),
- (r'(?i)\s(contained|create_resources|crit|cron)\s', Keyword),
- (r'(?i)\s(debug|default|define|defined|directory)\s', Keyword),
- (r'(?i)\s(else|elsif|emerg|err|exec|extlookup)\s', Keyword),
- (r'(?i)\s(fail|false|file|filebucket|fqdn_rand)\s', Keyword),
- (r'(?i)\s(generate|host|if|import|include|info)\s', Keyword),
- (r'(?i)\s(inherits|inline_template|installed)\s', Keyword),
- (r'(?i)\s(interface|k5login|latest|link|loglevel)\s', Keyword),
- (r'(?i)\s(macauthorization|mailalias|maillist)\s', Keyword),
- (r'(?i)\s(mcx|md5|mount|mounted|nagios_command)\s', Keyword),
- (r'(?i)\s(nagios_contact|nagios_contactgroup)\s', Keyword),
- (r'(?i)\s(nagios_host|nagios_hostdependency)\s', Keyword),
- (r'(?i)\s(nagios_hostescalation|nagios_hostextinfo)\s', Keyword),
- (r'(?i)\s(nagios_hostgroup|nagios_service)\s', Keyword),
- (r'(?i)\s(nagios_servicedependency)\s', Keyword),
- (r'(?i)\s(nagios_serviceescalation)\s', Keyword),
- (r'(?i)\s(nagios_serviceextinfo)\s', Keyword),
- (r'(?i)\s(nagios_servicegroup|nagios_timeperiod)\s', Keyword),
- (r'(?i)\s(node|noop|notice|notify)\s', Keyword),
- (r'(?i)\s(package|present|purged|realize|regsubst)\s', Keyword),
- (r'(?i)\s(resources|role|router|running)\s', Keyword),
- (r'(?i)\s(schedule|scheduled_task|search|selboolean)\s', Keyword),
- (r'(?i)\s(selmodule|service|sha1|shellquote|split)\s', Keyword),
- (r'(?i)\s(sprintf|ssh_authorized_key|sshkey|stage)\s', Keyword),
- (r'(?i)\s(stopped|subscribe|tag|tagged|template|tidy)\s', Keyword),
- (r'(?i)\s(true|undef|unmounted|user|versioncmp|vlan)\s', Keyword),
- (r'(?i)\s(warning|yumrepo|zfs|zone|zpool)\s', Keyword),
- ],
-
- 'strings': [
- (r'"([^"])*"', String),
- (r'\'([^\'])*\'', String),
- ],
-
- }