# -*- coding: utf-8 -*- ## frozen_string_literal: truemoduleRougemoduleLexersclassElm<RegexLexertitle"Elm"desc"The Elm programming language (http://elm-lang.org/)"tag'elm'filenames'*.elm'mimetypes'text/x-elm'# Keywords are logically grouped by lineskeywords=%w(
module exposing port
import as
type alias
if then else
case of
let in
)state:rootdo# Whitespacesrule%r/\s+/m,Text# Single line commentsrule%r/--.*/,Comment::Single# Multiline commentsrule%r/{-/,Comment::Multiline,:multiline_comment# Keywordsrule%r/\b(#{keywords.join('|')})\b/,Keyword# Variable or a functionrule%r/[a-z]\w*/,Name# Underscore is a name for a variable, when it won't be used laterrule%r/_/,Name# Typerule%r/[A-Z]\w*/,Keyword::Type# Two symbol operators: -> :: // .. && || ++ |> <| << >> == /= <= >=rule%r/(->|::|\/\/|\.\.|&&|\|\||\+\+|\|>|<\||>>|<<|==|\/=|<=|>=)/,Operator# One symbol operators: + - / * % = < > ^ | !rule%r/[+-\/*%=<>^\|!]/,Operator# Lambda operatorrule%r/\\/,Operator# Not standard Elm operators, but these symbols can be used for custom inflix operators. We need to highlight them as operators as well.rule%r/[@\#$&~?]/,Operator# Single, double quotes, and triple double quotesrule%r/"""/,Str,:multiline_stringrule%r/'(\\.|.)'/,Str::Charrule%r/"/,Str,:double_quote# Numbersrule%r/0x[\da-f]+/i,Num::Hexrule%r/\d+e[+-]?\d+/i,Num::Floatrule%r/\d+\.\d+(e[+-]?\d+)?/i,Num::Floatrule%r/\d+/,Num::Integer# Punctuation: [ ] ( ) , ; ` { } :rule%r/[\[\](),;`{}:]/,Punctuationend# Multiline and nested commentingstate:multiline_commentdorule%r/-}/,Comment::Multiline,:pop!rule%r/{-/,Comment::Multiline,:multiline_commentrule%r/[^-{}]+/,Comment::Multilinerule%r/[-{}]/,Comment::Multilineend# Double quotesstate:double_quotedorule%r/[^\\"]+/,Str::Doublerule%r/\\"/,Str::Escaperule%r/"/,Str::Double,:pop!end# Multiple line string with triple double quotes, e.g. """ multi """state:multiline_stringdorule%r/\\"/,Str::Escaperule%r/"""/,Str,:pop!rule%r/[^"]+/,Strrule%r/"/,Strendendendend