Sha256: c4e40bf39c733826a8da70d591ec1ceb633291c04e34488e5f8d0e3490d30b7b

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

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

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'

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

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

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

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

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

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

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

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

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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
rouge-3.2.1 lib/rouge/lexers/prolog.rb
rouge-3.2.0 lib/rouge/lexers/prolog.rb
rouge_ecl-0.0.1 lib/rouge/lexers/prolog.rb
rouge-3.1.1 lib/rouge/lexers/prolog.rb
rouge-3.1.0 lib/rouge/lexers/prolog.rb
rouge-3.0.0 lib/rouge/lexers/prolog.rb