# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Lexers class TOML < RegexLexer title "TOML" desc 'the TOML configuration format (https://github.com/toml-lang/toml)' tag 'toml' filenames '*.toml', 'Pipfile', 'poetry.lock' mimetypes 'text/x-toml' # bare keys and quoted keys identifier = %r/(?:\S+|"[^"]+"|'[^']+')/ state :basic do rule %r/\s+/, Text rule %r/#.*?$/, Comment rule %r/(true|false)/, Keyword::Constant rule %r/(#{identifier})(\s*)(=)(\s*)(\{)/ do groups Name::Namespace, Text, Operator, Text, Punctuation push :inline end rule %r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date rule %r/[+-]?\d+(?:_\d+)*\.\d+(?:_\d+)*(?:[eE][+-]?\d+(?:_\d+)*)?/, Num::Float rule %r/[+-]?\d+(?:_\d+)*[eE][+-]?\d+(?:_\d+)*/, Num::Float rule %r/[+-]?(?:nan|inf)/, Num::Float rule %r/0x\h+(?:_\h+)*/, Num::Hex rule %r/0o[0-7]+(?:_[0-7]+)*/, Num::Oct rule %r/0b[01]+(?:_[01]+)*/, Num::Bin rule %r/[+-]?\d+(?:_\d+)*/, Num::Integer end state :root do mixin :basic rule %r/(?