# frozen_string_literal: true module Rouge module Lexers class Tulip < RegexLexer desc 'the tulip programming language (twitter.com/tuliplang)' tag 'tulip' aliases 'tulip' filenames '*.tlp' mimetypes 'text/x-tulip', 'application/x-tulip' def self.detect?(text) return true if text.shebang? 'tulip' end id = /[a-z][\w-]*/i upper_id = /[A-Z][\w-]*/ state :comments_and_whitespace do rule /\s+/, Text rule /#.*?$/, Comment end state :root do mixin :comments_and_whitespace rule /@#{id}/, Keyword rule /(\\#{id})([{])/ do groups Name::Function, Str push :nested_string end rule /([+]#{id})([{])/ do groups Name::Decorator, Str push :nested_string end rule /\\#{id}/, Name::Function rule /[+]#{id}/, Name::Decorator rule /"[{]/, Str, :dqi rule /"/, Str, :dq rule /'{/, Str, :nested_string rule /'#{id}/, Str rule /[.]#{id}/, Name::Tag rule /[$]#{id}?/, Name::Variable rule /-#{id}:?/, Name::Label rule /%#{id}/, Name::Function rule /`#{id}/, Operator::Word rule /[?~%._>,!\[\]:{}()=;\/-]/, Punctuation rule /[0-9]+([.][0-9]+)?/, Num rule /#{id}/, Name rule //, Comment::Preproc, :pop! rule /[*:]/, Punctuation rule /#{upper_id}/, Keyword::Type rule /#{id}/, Name::Variable end end end end