# -*- 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%r/\s+/,Textrule%r(#.*?$),Comment::Singleendstate:expr_startdomixin:comments_and_whitespacerule%r(/)dotokenStr::Regexgoto:regexendrule%r//,Text,:pop!endstate:regexdorule%r(/)dotokenStr::Regexgoto:regex_endendrule%r([^/]\n),Error,:pop!rule%r/\n/,Error,:pop!rule%r/\[\^/,Str::Escape,:regex_grouprule%r/\[/,Str::Escape,:regex_grouprule%r/\\./,Str::Escaperule%r{[(][?][:=<!]},Str::Escaperule%r/[{][\d,]+[}]/,Str::Escaperule%r/[()?]/,Str::Escaperule%r/./,Str::Regexendstate:regex_enddorule(//){pop!}endstate:regex_groupdo# specially highlight / in a group to indicate that it doesn't# close the regexrule%r(/),Str::Escaperule%r([^/]\n)dotokenErrorpop!2endrule%r/\]/,Str::Escape,:pop!rule%r/\\./,Str::Escaperule%r/./,Str::Regexendstate:bad_regexdorule%r/[^\n]+/,Error,:pop!endstate:rootdomixin:comments_and_whitespacerule%r((?<=\n)(?=\s|/)),Text,:expr_startrule%r([-<>+*/%\^!=]=?|in\b|\+\+|--|\|),Operator,:expr_startrule%r(&&|\|\||~!?),Operator,:expr_startrule%r/[(\[,]/,Punctuation,:expr_startrule%r/;/,Punctuation,:statementrule%r/[)\].]/,Punctuationrule%r/[?]/dotokenPunctuationpush:ternarypush:expr_startendrule%r/[{}]/,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%r/[0-9]+\.[0-9]+/,Num::Floatrule%r/[0-9]+/,Num::Integerrule%r/"(\\[\\"]|[^"])*"/,Str::Doublerule%r/:/,Punctuationendstate:statementdorule%r/[{}]/,Punctuationmixin:expr_startendstate:ternarydorule%r/:/dotokenPunctuationgoto:expr_startendmixin:rootendendendend