# -*- coding: utf-8 -*- ## frozen_string_literal: truemoduleRougemoduleLexersclassAwk<RegexLexertitle"Awk"desc"pattern-directed scanning and processing language"tag'awk'filenames'*.awk'mimetypes'application/x-awk'defself.detect?(text)returntrueiftext.shebang?('awk')endid=/[$a-zA-Z_][a-zA-Z0-9_]*/defself.keywords@keywords||=Set.new%w(
if else while for do break continue return next nextfile delete
exit print printf getline
)enddefself.declarations@declarations||=Set.new%w(function)enddefself.reserved@reserved||=Set.new%w(BEGIN END)enddefself.constants@constants||=Set.new%w(
CONVFMT FS NF NR FNR FILENAME RS OFS ORS OFMT SUBSEP ARGC ARGV
ENVIRON
)enddefself.builtins@builtins||=%w(
exp log sqrt sin cos atan2 length rand srand int substr index match
split sub gsub sprintf system tolower toupper
)endstate:comments_and_whitespacedorule/\s+/,Textrule%r(#.*?$),Comment::Singleendstate:expr_startdomixin:comments_and_whitespacerule%r(/)dotokenStr::Regexgoto:regexendrule//,Text,:pop!endstate:regexdorule%r(/)dotokenStr::Regexgoto:regex_endendrule%r([^/]\n),Error,:pop!rule/\n/,Error,:pop!rule/\[\^/,Str::Escape,:regex_grouprule/\[/,Str::Escape,:regex_grouprule/\\./,Str::Escaperule%r{[(][?][:=<!]},Str::Escaperule/[{][\d,]+[}]/,Str::Escaperule/[()?]/,Str::Escaperule/./,Str::Regexendstate:regex_enddorule(//){pop!}endstate:regex_groupdo# specially highlight / in a group to indicate that it doesn't# close the regexrule/\//,Str::Escaperule%r([^/]\n)dotokenErrorpop!2endrule/\]/,Str::Escape,:pop!rule/\\./,Str::Escaperule/./,Str::Regexendstate:bad_regexdorule/[^\n]+/,Error,:pop!endstate:rootdomixin:comments_and_whitespacerule%r((?<=\n)(?=\s|/)),Text,:expr_startrule%r([-<>+*/%\^!=]=?|in\b|\+\+|--|\|),Operator,:expr_startrule%r(&&|\|\||~!?),Operator,:expr_startrule/[(\[,]/,Punctuation,:expr_startrule/;/,Punctuation,:statementrule/[)\].]/,Punctuationrule/[?]/dotokenPunctuationpush:ternarypush:expr_startendrule/[{}]/,Punctuation,:statementruleiddo|m|ifself.class.keywords.include?m[0]tokenKeywordpush:expr_startelsifself.class.declarations.include?m[0]tokenKeyword::Declarationpush:expr_startelsifself.class.reserved.include?m[0]tokenKeyword::Reservedelsifself.class.constants.include?m[0]tokenKeyword::Constantelsifself.class.builtins.include?m[0]tokenName::Builtinelsifm[0]=~/^\$/tokenName::VariableelsetokenName::Otherendendrule/[0-9]+\.[0-9]+/,Num::Floatrule/[0-9]+/,Num::Integerrule/"(\\[\\"]|[^"])*"/,Str::Doublerule/:/,Punctuationendstate:statementdorule/[{}]/,Punctuationmixin:expr_startendstate:ternarydorule/:/dotokenPunctuationgoto:expr_startendmixin:rootendendendend