# -*- coding: utf-8 -*- # module Rouge module Lexers # Direct port of pygments Lexer. # See: https://bitbucket.org/birkenfeld/pygments-main/src/7304e4759ae65343d89a51359ca538912519cc31/pygments/lexers/functional.py?at=default#cl-2362 class Elixir < RegexLexer title "Elixir" desc "Elixir language (elixir-lang.org)" tag 'elixir' filenames '*.ex', '*.exs' mimetypes 'text/x-elixir', 'application/x-elixir' BRACES = [ ['\{', '\}', 'cb'], ['\[', '\]', 'sb'], ['\(', '\)', 'pa'], ['\<', '\>', 'lt'] ] state :root do rule /\s+/m, Text rule /#.*$/, Comment::Single rule %r{\b(case|cond|end|bc|lc|if|unless|try|loop|receive|fn|defmodule| defp?|defprotocol|defimpl|defrecord|defmacrop?|defdelegate| defexception|exit|raise|throw|unless|after|rescue|catch|else)\b(?![?!])| (?)\b}x, Keyword rule /\b(import|require|use|recur|quote|unquote|super|refer)\b(?![?!])/, Keyword::Namespace rule /(?|<(?!<|=)|>(?!<|=|>)|<=|>=|===|==|=~|!=|!~|(?=[\s\t])\?| (?<=[\s\t])!+|&(&&?|(?!\d))|\|\||\^|\*|\+|\-|/| \||\+\+|\-\-|\*\*|\/\/|\<\-|\<\>|<<|>>|=|\.|~~~}x, Operator rule %r{(?=]))?|\<\>|===?|>=?|<=?| <=>|&&?|%\(\)|%\[\]|%\{\}|\+\+?|\-\-?|\|\|?|\!|//|[%&`/\|]| \*\*?|=?~|<\-)|([a-zA-Z_]\w*([?!])?)(:)(?!:)}, Str::Symbol rule /:"/, Str::Symbol, :interpoling_symbol rule /\b(nil|true|false)\b(?![?!])|\b[A-Z]\w*\b/, Name::Constant rule /\b(__(FILE|LINE|MODULE|MAIN|FUNCTION)__)\b(?![?!])/, Name::Builtin::Pseudo rule /[a-zA-Z_!][\w_]*[!\?]?/, Name rule %r{::|[%(){};,/\|:\\\[\]]}, Punctuation rule /@[a-zA-Z_]\w*|&\d/, Name::Variable rule %r{\b(0[xX][0-9A-Fa-f]+|\d(_?\d)*(\.(?![^\d\s]) (_?\d)*)?([eE][-+]?\d(_?\d)*)?|0[bB][01]+)\b}x, Num rule %r{~r\/.*\/}, Str::Regex mixin :strings end state :strings do rule /(%[A-Ba-z])?"""(?:.|\n)*?"""/, Str::Doc rule /'''(?:.|\n)*?'''/, Str::Doc rule /"/, Str::Doc, :dqs rule /'.*?'/, Str::Single rule %r{(?