# -*- coding: utf-8 -*- ## frozen_string_literal: truemoduleRougemoduleLexersload_lexer'lua.rb'classMoonscript<RegexLexertitle"MoonScript"desc"Moonscript (http://www.moonscript.org)"tag'moonscript'aliases'moon'filenames'*.moon'mimetypes'text/x-moonscript','application/x-moonscript'option:function_highlighting,'Whether to highlight builtin functions (default: true)'option:disabled_modules,'builtin modules to disable'definitialize(*)super@function_highlighting=bool_option(:function_highlighting){true}@disabled_modules=list_option(:disabled_modules)enddefself.detect?(text)returntrueiftext.shebang?'moon'enddefbuiltinsreturn[]unless@function_highlighting@builtins||=Set.new.tapdo|builtins|Rouge::Lexers::Lua.builtins.eachdo|mod,fns|nextif@disabled_modules.include?modbuiltins.merge(fns)endendendstate:rootdorule%r(#!(.*?)$),Comment::Preproc# shebangrule%r//,Text,:mainendstate:basedoident='(?:\w\w*)'rule%r((?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?'),Num::Floatrule%r((?i)\d+e[+-]?\d+),Num::Floatrule%r((?i)0x[0-9a-f]*),Num::Hexrule%r(\d+),Num::Integerrule%r(@#{ident}*),Name::Variable::Instancerule%r([A-Z]\w*),Name::Classrule%r("?[^"]+":),Literal::String::Symbolrule%r(#{ident}:),Literal::String::Symbolrule%r(:#{ident}),Literal::String::Symbolrule%r(\s+),Text::Whitespacerule%r((==|~=|!=|<=|>=|\.\.\.|\.\.|->|=>|[=+\-*/%^<>#!\\])),Operatorrule%r([\[\]\{\}\(\)\.,:;]),Punctuationrule%r((and|or|not)\b),Operator::Wordkeywords=%w{
break class continue do else elseif end extends for if import in
repeat return switch super then unless until using when with while
}rule%r((#{keywords.join('|')})\b),Keywordrule%r((local|export)\b),Keyword::Declarationrule%r((true|false|nil)\b),Keyword::Constantrule%r([A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?)do|m|name=m[0]ifself.builtins.include?(name)tokenName::Builtinelsifname=~/\./a,b=name.split('.',2)tokenName,atokenPunctuation,'.'tokenName,belsetokenNameendendendstate:maindorule%r(--.*$),Comment::Singlerule%r(\[(=*)\[.*?\]\1\])m,Str::Heredocmixin:baserule%r('),Str::Single,:sqsrule%r("),Str::Double,:dqsendstate:sqsdorule%r('),Str::Single,:pop!rule%r([^']+),Str::Singleendstate:interpolationdorule%r(\}),Str::Interpol,:pop!mixin:baseendstate:dqsdorule%r(#\{),Str::Interpol,:interpolationrule%r("),Str::Double,:pop!rule%r(#[^{]),Str::Doublerule%r([^"#]+),Str::Doubleendendendend