# -*- coding: utf-8 -*- ## frozen_string_literal: truemoduleRougemoduleLexersclassPuppet<RegexLexertitle"Puppet"desc'The Puppet configuration management language (puppetlabs.org)'tag'puppet'aliases'pp'filenames'*.pp'defself.detect?(text)returntrueiftext.shebang?'puppet-apply'returntrueiftext.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%r/\s+/m,Textrule%r/#.*?\n/,Commentendstate:rootdomixin:whitespacerule%r/[$]#{qualname}/,Name::Variablerule%r/(#{id})(?=\s*[=+]>)/mdo|m|ifself.class.metaparameters.include?m[0]tokenKeyword::PseudoelsetokenName::Propertyendendrule%r/(#{qualname})(?=\s*[(])/m,Name::Functionrulecap_id,Name::Classrule%r/[+=|~-]>|<[|~-]/,Punctuationrule%r/[|:}();\[\]]/,Punctuation# HACK for case statements and selectorsrule%r/{/,Punctuation,:regex_allowedrule%r/,/,Punctuation,:regex_allowedrule%r/(in|and|or)\b/,Operator::Wordrule%r/[=!<>]=/,Operatorrule%r/[=!]~/,Operator,:regex_allowedrule%r([.=<>!+*/-]),Operatorrule%r/(class|include)(\s*)(#{qualname})/dogroupsKeyword,Text,Name::Classendrule%r/node\b/,Keyword,:regex_allowedrule%r/'(\\[\\']|[^'])*'/m,Str::Singlerule%r/"/,Str::Double,:dquotesrule%r/\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%r/\\./,Str::Escaperule%r/[(){}]/,Str::Interpolrule%r/\[/,Str::Interpol,:regex_classrule%r/./,Str::Regexendstate:regex_classdorule%r/\]/,Str::Interpol,:pop!rule%r/(?<!\[)-(?=\])/,Str::Regexrule%r/-/,Str::Interpolrule%r/\\./,Str::Escaperule%r/[^\\\]-]+/,Str::Regexendstate:dquotesdorule%r/"/,Str::Double,:pop!rule%r/[^$\\"]+/m,Str::Doublerule%r/\\./m,Str::Escaperule%r/[$]#{qualname}/,Name::Variablerule%r/[$][{]#{qualname}[}]/,Name::Variableendendendend