Sha256: c09c6a40d98274ea359fbb035e31da5c7f5fcda164d78a7b493c6d307c74b460

Contents?: true

Size: 1.6 KB

Versions: 44

Compression:

Stored size: 1.6 KB

Contents

# -*- coding: utf-8 -*- #
# frozen_string_literal: true

module Rouge
  module Lexers
    class Prolog < RegexLexer
      title "Prolog"
      desc "The Prolog programming language (http://en.wikipedia.org/wiki/Prolog)"
      tag 'prolog'
      aliases 'prolog'
      filenames '*.pro', '*.P', '*.prolog', '*.pl'
      mimetypes 'text/x-prolog'

      start { push :bol }

      state :bol do
        rule %r/#.*/, Comment::Single
        rule(//) { pop! }
      end

      state :basic do
        rule %r/\s+/, Text
        rule %r/%.*/, Comment::Single
        rule %r/\/\*/, Comment::Multiline, :nested_comment

        rule %r/[\[\](){}|.,;!]/, Punctuation
        rule %r/:-|-->/, Punctuation

        rule %r/"[^"]*"/, Str::Double

        rule %r/\d+\.\d+/, Num::Float
        rule %r/\d+/, Num
      end

      state :atoms do
        rule %r/[[:lower:]]([[:word:]])*/, Str::Symbol
        rule %r/'[^']*'/, Str::Symbol
      end

      state :operators do
        rule %r/(<|>|=<|>=|==|=:=|=|\/|\/\/|\*|\+|-)(?=\s|[a-zA-Z0-9\[])/,
          Operator
        rule %r/is/, Operator
        rule %r/(mod|div|not)/, Operator
        rule %r/[#&*+-.\/:<=>?@^~]+/, Operator
      end

      state :variables do
        rule %r/[A-Z]+\w*/, Name::Variable
        rule %r/_[[:word:]]*/, Name::Variable
      end

      state :root do
        mixin :basic
        mixin :atoms
        mixin :variables
        mixin :operators
      end

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

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
rouge-4.5.1 lib/rouge/lexers/prolog.rb
rouge-4.5.0 lib/rouge/lexers/prolog.rb
rouge-4.4.0 lib/rouge/lexers/prolog.rb
rouge-4.3.0 lib/rouge/lexers/prolog.rb
rouge-4.2.1 lib/rouge/lexers/prolog.rb
rouge-4.2.0 lib/rouge/lexers/prolog.rb
rouge-4.1.3 lib/rouge/lexers/prolog.rb
rouge-4.1.2 lib/rouge/lexers/prolog.rb
rouge-4.1.1 lib/rouge/lexers/prolog.rb
mumukit-content-type-1.12.1 vendor/bundle/ruby/2.7.0/gems/rouge-3.30.0/lib/rouge/lexers/prolog.rb
mumukit-content-type-1.12.0 vendor/bundle/ruby/2.7.0/gems/rouge-3.30.0/lib/rouge/lexers/prolog.rb
rouge-4.1.0 lib/rouge/lexers/prolog.rb
rouge-4.0.1 lib/rouge/lexers/prolog.rb
rouge-4.0.0 lib/rouge/lexers/prolog.rb
rouge-3.30.0 lib/rouge/lexers/prolog.rb
rouge-3.29.0 lib/rouge/lexers/prolog.rb
rouge-3.28.0 lib/rouge/lexers/prolog.rb
rouge-3.27.0 lib/rouge/lexers/prolog.rb
rouge-3.26.1 lib/rouge/lexers/prolog.rb
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/rouge-3.26.0/lib/rouge/lexers/prolog.rb