# -*- coding: utf-8 -*- ## frozen_string_literal: truemoduleRougemoduleLexersclassRML<RegexLexertitle"RML"desc"A system agnostic domain-specific language for runtime monitoring and verification (https://rmlatdibris.github.io/)"tag'rml'filenames'*.rml'defself.keywords@keywords||=Set.new%w(
matches not with empty
all if else true false
)enddefself.arithmetic_keywords@arithmetic_keywords||=Set.new%w(
abs sin cos tan min max
)endid_char=/[a-zA-Z0-9_]/uppercase_id=/[A-Z]#{id_char}*/lowercase_id=/[a-z]#{id_char}*/ellipsis=/(\.){3}/int=/[0-9]+/float=/#{int}\.#{int}/string=/'(\\'|[ a-zA-Z0-9_.])*'/whitespace=/[ \t\r\n]+/comment=/\/\/[^\r\n]*/state:common_rulesdorule%r/#{whitespace}/,Textrule%r/#{comment}/,Comment::Singlerule%r/#{string}/,Literal::Stringrule%r/#{float}/,Num::Floatrule%r/#{int}/,Num::Integerendstate:rootdomixin:common_rulesrule%r/(#{lowercase_id})(\()/dogroupsName::Function,Operatorpush:event_type_paramsendrule%r/#{lowercase_id}/do|m|ifm[0]=='with'tokenKeywordpush:data_expression_withelsifself.class.keywords.include?m[0]tokenKeywordelsetokenName::Functionendendrule%r/\(|\{|\[/,Operator,:event_type_paramsrule%r/[_\|]/,Operatorrule%r/#{uppercase_id}/,Name::Class,:equation_block_expressionrule%r/;/,Operatorendstate:event_type_paramsdomixin:common_rulesrule%r/\(|\{|\[/,Operator,:pushrule%r/\)|\}|\]/,Operator,:pop!rule%r/#{lowercase_id}(?=:)/,Name::Entityrule%r/(#{lowercase_id})/do|m|ifself.class.keywords.include?m[0]tokenKeywordelsetokenLiteral::String::Regexendendrule%r/#{ellipsis}/,Literal::String::Symbolrule%r/[_\|;,:]/,Operatorendstate:equation_block_expressiondomixin:common_rulesrule%r/[<,>]/,Operatorrule%r/#{lowercase_id}/,Literal::String::Regexrule%r/=/dotokenOperatorgoto:expendrule%r/;/,Operator,:pop!endstate:expdomixin:common_rulesrule%r/(if)(\()/dogroupsKeyword,Operatorpush:data_expressionendrule%r/let|var/,Keyword,:equation_block_expressionrule%r/(#{lowercase_id})(\()/dogroupsName::Function,Operatorpush:event_type_paramsendrule%r/(#{lowercase_id})/do|m|ifself.class.keywords.include?m[0]tokenKeywordelsetokenName::Functionendendrule%r/#{uppercase_id}(?=<)/,Name::Class,:data_expressionrule%r/#{uppercase_id}/,Name::Classrule%r/[=(){}*+\/\\\|!>?]/,Operatorrule%r/;/,Operator,:pop!endstate:data_expressiondomixin:common_rulesrule%r/#{lowercase_id}/do|m|if(self.class.arithmetic_keywords|self.class.keywords).include?m[0]tokenKeywordelsetokenLiteral::String::Regexendendrule%r/\(/,Operator,:pushrule%r/\)/,Operator,:pop!rule%r/(>)(?=[^A-Z;]+[A-Z;>])/,Operator,:pop!rule%r/[*^?!%&\[\]<>\|+=:,.\/\\_-]/,Operatorrule%r/;/,Operator,:pop!endstate:data_expression_withdomixin:common_rulesrule%r/>/,Operatormixin:data_expressionendendendend