# -*- coding: utf-8 -*- #moduleRougemoduleLexersclassPuppet<RegexLexerdesc'The Puppet configuration management language (puppetlabs.org)'tag'puppet'aliases'pp'filenames'*.pp'defself.analyze_text(text)return1iftext.shebang?'puppet-apply'return1iftext.shebang?'puppet'enddefself.keywords@keywords||=Set.new%w(
and case class default define else elsif if in import inherits
node unless
)enddefself.constants@constants||=Set.new%w(
false true undef
)enddefself.metaparameters@metaparameters||=Set.new%w(
before require notify subscribe
)endid=/[a-z]\w*/cap_id=/[A-Z]\w*/qualname=/(::)?(#{id}::)*\w+/state:whitespacedorule/\s+/m,Textrule/#.*?\n/,Commentendstate:rootdomixin:whitespacerule/[$]#{qualname}/,Name::Variablerule/(#{id})(?=\s*[=+]>)/mdo|m|ifself.class.metaparameters.include?m[0]tokenKeyword::PseudoelsetokenName::Propertyendendrule/(#{qualname})(?=\s*[(])/m,Name::Functionrulecap_id,Name::Classrule/[+=|~-]>|<[|~-]/,Punctuationrule/[:}();\[\]]/,Punctuation# HACK for case statements and selectorsrule/{/,Punctuation,:regex_allowedrule/,/,Punctuation,:regex_allowedrule/(in|and|or)\b/,Operator::Wordrule/[=!<>]=/,Operatorrule/[=!]~/,Operator,:regex_allowedrule%r([<>!+*/-]),Operatorrule/(class|include)(\s*)(#{qualname})/dogroupsKeyword,Text,Name::Classendrule/node\b/,Keyword,:regex_allowedrule/'(\\[\\']|[^'])*'/m,Str::Singlerule/"/,Str::Double,:dquotesrule/\d+([.]\d+)?(e[+-]\d+)?/,Num# a valid regex. TODO: regexes are only allowed# in certain places in puppet.rulequalnamedo|m|ifself.class.keywords.include?m[0]tokenKeywordelsifself.class.constants.include?m[0]tokenKeyword::ConstantelsetokenNameendendendstate:regex_alloweddomixin:whitespacerule%r(/),Str::Regex,:regexrule(//){pop!}endstate:regexdorule%r(/),Str::Regex,:pop!rule/\\./,Str::Escaperule/[(){}]/,Str::Interpolrule/\[/,Str::Interpol,:regex_classrule/./,Str::Regexendstate:regex_classdorule/\]/,Str::Interpol,:pop!rule/(?<!\[)-(?=\])/,Str::Regexrule/-/,Str::Interpolrule/\\./,Str::Escaperule/[^\\\]-]+/,Str::Regexendstate:dquotesdorule/"/,Str::Double,:pop!rule/[^$\\"]+/m,Str::Doublerule/\\./m,Str::Escaperule/[$]#{qualname}/,Name::Variablerule/[$][{]#{qualname}[}]/,Name::Variableendendendend