# -*- coding: utf-8 -*- #moduleRougemoduleLexersclassLua<RegexLexerdesc"Lua (http://www.lua.org)"tag'lua'filenames'*.lua','*.wlua'mimetypes'text/x-lua','application/x-lua'definitialize(opts={})@function_highlighting=opts.delete(:function_highlighting){true}@disabled_modules=opts.delete(:disabled_modules){[]}super(opts)enddefself.analyze_text(text)return1iftext.shebang?'lua'enddefself.builtinsloadPathname.new(__FILE__).dirname.join('lua/builtins.rb')self.builtinsenddefbuiltinsreturn[]unless@function_highlighting@builtins||=Set.new.tapdo|builtins|self.class.builtins.eachdo|mod,fns|nextif@disabled_modules.include?modbuiltins.merge(fns)endendendstate:rootdo# lua allows a file to start with a shebangrule%r(#!(.*?)$),Comment::Preprocrule//,Text,:baseendstate:basedorule%r(--\[(=*)\[.*?\]\1\])m,Comment::Multilinerule%r(--.*$),Comment::Singlerule%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(\n),Textrule%r([^\S\n]),Text# multiline stringsrule%r(\[(=*)\[.*?\]\1\])m,Strrule%r((==|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#])),Operatorrule%r([\[\]\{\}\(\)\.,:;]),Punctuationrule%r((and|or|not)\b),Operator::Wordrule%r((break|do|else|elseif|end|for|if|in|repeat|return|then|until|while)\b),Keywordrule%r((local)\b),Keyword::Declarationrule%r((true|false|nil)\b),Keyword::Constantrule%r((function)\b),Keyword,:function_namerule%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,belsetokenNameendendrule%r('),Str::Single,:escape_sqsrule%r("),Str::Double,:escape_dqsendstate:function_namedorule/\s+/,Textrule%r((?:([A-Za-z_][A-Za-z0-9_]*)(\.))?([A-Za-z_][A-Za-z0-9_]*))dogroupsName::Class,Punctuation,Name::Functionpop!end# inline functionrule%r(\(),Punctuation,:pop!endstate:escape_sqsdomixin:string_escapemixin:sqsendstate:escape_dqsdomixin:string_escapemixin:dqsendstate:string_escapedorule%r(\\([abfnrtv\\"']|\d{1,3})),Str::Escapeendstate:sqsdorule%r('),Str::Single,:pop!rule%r([^']+),Str::Singleendstate:dqsdorule%r("),Str::Double,:pop!rule%r([^"]+),Str::Doubleendendendend