Sha256: e3bc38a199db964d0c566ea7ca336064b59c50a41b3fdb8d201ce3ce30dc66dc

Contents?: true

Size: 1.64 KB

Versions: 26

Compression:

Stored size: 1.64 KB

Contents

# -*- coding: utf-8 -*- #

module Rouge
  module Lexers
    class IO < RegexLexer
      tag 'io'
      title "Io"
      desc 'The IO programming language (http://iolanguage.com)'
      mimetypes 'text/x-iosrc'
      filenames '*.io'

      def self.analyze_text(text)
        return 1 if text.shebang? 'io'
      end

      def self.constants
        @constants ||= Set.new %w(nil false true)
      end

      def self.builtins
        @builtins ||= Set.new %w(
          args call clone do doFile doString else elseif for if list
          method return super then
        )
      end

      state :root do
        rule /\s+/m, Text
        rule %r(//.*?\n), Comment::Single
        rule %r(#.*?\n), Comment::Single
        rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
        rule %r(/[+]), Comment::Multiline, :nested_comment

        rule /"(\\\\|\\"|[^"])*"/, Str

        rule %r(:?:=), Keyword
        rule /[()]/, Punctuation

        rule %r([-=;,*+><!/|^.%&\[\]{}]), Operator

        rule /[A-Z]\w*/, Name::Class

        rule /[a-z_]\w*/ do |m|
          name = m[0]

          if self.class.constants.include? name
            token Keyword::Constant
          elsif self.class.builtins.include? name
            token Name::Builtin
          else
            token Name
          end
        end

        rule %r((\d+[.]?\d*|\d*[.]\d+)(e[+-]?[0-9]+)?)i, Num::Float
        rule /\d+/, Num::Integer

        rule /@@?/, Keyword
      end

      state :nested_comment do
        rule %r([^/+]+)m, Comment::Multiline
        rule %r(/[+]), Comment::Multiline, :nested_comment
        rule %r([+]/), Comment::Multiline, :pop!
      end
    end
  end
end

Version data entries

26 entries across 24 versions & 6 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/rouge-2.2.1/lib/rouge/lexers/io.rb
rouge_ecl-1.0.0 lib/rouge/lexers/io.rb
rouge-2.2.1 lib/rouge/lexers/io.rb
rouge-2.2.0 lib/rouge/lexers/io.rb
rougegal-2.1.2 lib/rouge/lexers/io.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/rouge-2.0.7/lib/rouge/lexers/io.rb
tdiary-5.0.5 vendor/bundle/gems/rouge-2.1.1/lib/rouge/lexers/io.rb
tdiary-5.0.5 vendor/bundle/gems/rouge-2.0.7/lib/rouge/lexers/io.rb
rouge-2.1.1 lib/rouge/lexers/io.rb
rouge-2.1.0 lib/rouge/lexers/io.rb
tdiary-5.0.4 vendor/bundle/gems/rouge-2.0.7/lib/rouge/lexers/io.rb
rouge-2.0.7 lib/rouge/lexers/io.rb
rouge-2.0.6 lib/rouge/lexers/io.rb
rouge-2.0.5 lib/rouge/lexers/io.rb
rouge-2.0.3 lib/rouge/lexers/io.rb
rouge-2.0.2 lib/rouge/lexers/io.rb
rouge-2.0.1 lib/rouge/lexers/io.rb
rouge-2.0.0 lib/rouge/lexers/io.rb
rouge-1.11.1 lib/rouge/lexers/io.rb
rouge-1.11.0 lib/rouge/lexers/io.rb