# -*- coding: utf-8 -*- ## frozen_string_literal: truemoduleRougemoduleLexersclassCfscript<RegexLexertitle"CFScript"desc'CFScript, the CFML scripting language'tag'cfscript'aliases'cfc'filenames'*.cfc'defself.keywords@keywords||=%w(
if else var xml default break switch do try catch throw in continue for return while required
)enddefself.declarations@declarations||=%w(
component property function remote public package private
)enddefself.types@types||=%w(
any array binary boolean component date guid numeric query string struct uuid void xml
)endconstants=%w(application session client cookie super this variables arguments cgi)operators=%w(\+\+ -- && \|\| <= >= < > == != mod eq lt gt lte gte not is and or xor eqv imp equal contains \? )dotted_id=/[$a-zA-Z_][a-zA-Z0-9_.]*/state:rootdomixin:comments_and_whitespacerule%r/(?:#{operators.join('|')}|does not contain|greater than(?: or equal to)?|less than(?: or equal to)?)\b/i,Operator,:expr_startrule%r([-<>+*%&|\^/!=]=?),Operator,:expr_startrule%r/[(\[,]/,Punctuation,:expr_startrule%r/;/,Punctuation,:statementrule%r/[)\].]/,Punctuationrule%r/[?]/dotokenPunctuationpush:ternarypush:expr_startendrule%r/[{}]/,Punctuation,:statementrule%r/(?:#{constants.join('|')})\b/,Name::Constantrule%r/(?:true|false|null)\b/,Keyword::Constantrule%r/import\b/,Keyword::Namespace,:importrule%r/(#{dotted_id})(\s*)(:)(\s*)/dogroupsName,Text,Punctuation,Textpush:expr_startendrule%r/([A-Za-z_$][\w.]*)(\s*)(\()/do|m|ifself.class.keywords.include?m[1]tokenKeyword,m[1]tokenText,m[2]tokenPunctuation,m[3]elsetokenName::Function,m[1]tokenText,m[2]tokenPunctuation,m[3]endendruledotted_iddo|m|ifself.class.declarations.include?m[0]tokenKeyword::Declarationpush:expr_startelsifself.class.keywords.include?m[0]tokenKeywordpush:expr_startelsifself.class.types.include?m[0]tokenKeyword::Typepush:expr_startelsetokenName::Otherendendrule%r/[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?/,Num::Floatrule%r/0x[0-9a-fA-F]+/,Num::Hexrule%r/[0-9]+/,Num::Integerrule%r/"(\\\\|\\"|[^"])*"/,Str::Doublerule%r/'(\\\\|\\'|[^'])*'/,Str::Singleend# same as java, broken outstate:comments_and_whitespacedorule%r/\s+/,Textrule%r(//.*?$),Comment::Singlerule%r(/\*.*?\*/)m,Comment::Multilineendstate:expr_startdomixin:comments_and_whitespacerule%r/[{]/,Punctuation,:objectrule%r//,Text,:pop!endstate:statementdorule%r/[{}]/,Punctuationmixin:expr_startend# object literalsstate:objectdomixin:comments_and_whitespacerule%r/[}]/dotokenPunctuationpush:expr_startendrule%r/(#{dotted_id})(\s*)(:)/dogroupsName::Other,Text,Punctuationpush:expr_startendrule%r/:/,Punctuationmixin:rootend# ternary expressions, where <dotted_id>: is not a label!state:ternarydorule%r/:/dotokenPunctuationgoto:expr_startendmixin:rootendstate:importdorule%r/\s+/m,Textrule%r/[a-z0-9_.]+\*?/i,Name::Namespace,:pop!endendendend