Sha256: 048ab47c0d410e11b2c3310301c86d764afeaaba5c61fb72b1d2025ac322614c

Contents?: true

Size: 1.94 KB

Versions: 44

Compression:

Stored size: 1.94 KB

Contents

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

module Rouge
  module Lexers
    load_lexer 'javascript.rb'

    class Qml < Javascript
      title "QML"
      desc 'QML, a UI markup language'
      tag 'qml'
      aliases 'qml'
      filenames '*.qml'

      mimetypes 'application/x-qml', 'text/x-qml'

      id_with_dots = /[$a-zA-Z_][a-zA-Z0-9_.]*/

      prepend :root do
        rule %r/(#{id_with_dots})(\s*)({)/ do
          groups Keyword::Type, Text, Punctuation
          push :type_block
        end
        rule %r/(#{id_with_dots})(\s+)(on)(\s+)(#{id_with_dots})(\s*)({)/ do
          groups Keyword::Type, Text, Keyword, Text, Name::Label, Text, Punctuation
          push :type_block
        end

        rule %r/[{]/, Punctuation, :push
      end

      state :type_block do
        rule %r/(id)(\s*)(:)(\s*)(#{id_with_dots})/ do
          groups Name::Label, Text, Punctuation, Text, Keyword::Declaration
        end

        rule %r/(#{id_with_dots})(\s*)(:)/ do
          groups Name::Label, Text, Punctuation
          push :expr_start
        end

        rule %r/(signal)(\s+)(#{id_with_dots})/ do
          groups Keyword::Declaration, Text, Name::Label
          push :signal
        end

        rule %r/(property)(\s+)(#{id_with_dots})(\s+)(#{id_with_dots})(\s*)(:?)/ do
          groups Keyword::Declaration, Text, Keyword::Type, Text, Name::Label, Text, Punctuation
          push :expr_start
        end

        rule %r/[}]/, Punctuation, :pop!
        mixin :root
      end

      state :signal do
        mixin :comments_and_whitespace
        rule %r/\(/ do
          token Punctuation
          goto :signal_args
        end
        rule %r//, Text, :pop!
      end

      state :signal_args do
        mixin :comments_and_whitespace
        rule %r/(#{id_with_dots})(\s+)(#{id_with_dots})(\s*)(,?)/ do
          groups Keyword::Type, Text, Name, Text, Punctuation
        end
        rule %r/\)/ , Punctuation, :pop!
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 2 rubygems

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