Sha256: ad968750978f9d78e55f23218fedd2870fc2f839d4e844dea6c883f04dcb3b7b

Contents?: true

Size: 1.88 KB

Versions: 19

Compression:

Stored size: 1.88 KB

Contents

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

module Rouge
  module Lexers
    class JSL < RegexLexer
      title "JSL"
      desc "The JMP Scripting Language (JSL) (jmp.com)"

      tag 'jsl'
      filenames '*.jsl'

      state :root do
        rule %r/\s+/m, Text::Whitespace

        rule %r(//.*?$), Comment::Single
        rule %r'/[*].*?', Comment::Multiline, :comment # multiline block comment

        # messages
        rule %r/<</, Operator, :message

        # covers built-in and custom functions
        rule %r/(::|:)?([a-z_][\w\s'%.\\]*)(\()/i do |m|
          groups Punctuation, Keyword, Punctuation
        end

        rule %r/\d{2}(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d{2}(\d{2})?(:\d{2}:\d{2}(:\d{2}(\.\d*)?)?)?/i, Literal::Date

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

        rule %r/(::|:)?([a-z_][\w\s'%.\\]*|"(?:\\!"|[^"])*?"n)/i do |m|
          groups Punctuation, Name::Variable
        end

        rule %r/(")(\\\[)(.*?)(\]\\)(")/m do
          groups Str::Double, Str::Escape, Str::Double, Str::Escape, Str::Double  # escaped string
        end
        rule %r/"/, Str::Double, :dq

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

      state :message do
        rule %r/\s+/m, Text::Whitespace
        rule %r/[a-z_][\w\s'%.\\]*/i, Name::Function
        rule %r/[(),;]/, Punctuation, :pop!
        rule %r/[&|!=<>]/, Operator, :pop!
      end

      state :dq do
        rule %r/\\![btrnNf0\\"]/, Str::Escape
        rule %r/\\/, Str::Double
        rule %r/"/, Str::Double, :pop!
        rule %r/[^\\"]+/m, Str::Double
      end

      state :comment do
        rule %r'/[*]', Comment::Multiline, :comment
        rule %r'[*]/', Comment::Multiline, :pop!
        rule %r'[^/*]+', Comment::Multiline
        rule %r'[/*]', Comment::Multiline
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

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