rouge 3.9.0 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/rouge/demos/apex +9 -0
 - data/lib/rouge/demos/clean +6 -0
 - data/lib/rouge/demos/csvs +8 -0
 - data/lib/rouge/demos/jsl +3 -0
 - data/lib/rouge/demos/liquid +0 -1
 - data/lib/rouge/demos/lustre +6 -0
 - data/lib/rouge/demos/lutin +18 -0
 - data/lib/rouge/demos/minizinc +23 -0
 - data/lib/rouge/demos/q +6 -0
 - data/lib/rouge/demos/robot_framework +27 -0
 - data/lib/rouge/demos/sparql +6 -0
 - data/lib/rouge/demos/ttcn3 +6 -0
 - data/lib/rouge/guessers/disambiguation.rb +5 -0
 - data/lib/rouge/lexer.rb +3 -0
 - data/lib/rouge/lexers/apex.rb +126 -0
 - data/lib/rouge/lexers/bpf.rb +20 -6
 - data/lib/rouge/lexers/clean.rb +156 -0
 - data/lib/rouge/lexers/common_lisp.rb +1 -1
 - data/lib/rouge/lexers/coq.rb +12 -9
 - data/lib/rouge/lexers/csvs.rb +44 -0
 - data/lib/rouge/lexers/eex.rb +2 -1
 - data/lib/rouge/lexers/http.rb +1 -1
 - data/lib/rouge/lexers/jsl.rb +55 -0
 - data/lib/rouge/lexers/json.rb +1 -1
 - data/lib/rouge/lexers/kotlin.rb +21 -28
 - data/lib/rouge/lexers/liquid.rb +82 -108
 - data/lib/rouge/lexers/lustre.rb +79 -0
 - data/lib/rouge/lexers/lutin.rb +33 -0
 - data/lib/rouge/lexers/markdown.rb +7 -1
 - data/lib/rouge/lexers/mason.rb +0 -5
 - data/lib/rouge/lexers/minizinc.rb +87 -0
 - data/lib/rouge/lexers/perl.rb +1 -1
 - data/lib/rouge/lexers/q.rb +2 -1
 - data/lib/rouge/lexers/robot_framework.rb +249 -0
 - data/lib/rouge/lexers/shell.rb +5 -3
 - data/lib/rouge/lexers/sparql.rb +129 -0
 - data/lib/rouge/lexers/swift.rb +1 -1
 - data/lib/rouge/lexers/ttcn3.rb +119 -0
 - data/lib/rouge/plugins/redcarpet.rb +7 -1
 - data/lib/rouge/version.rb +1 -1
 - metadata +22 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a05162378ada50863a8c1a08984934c22af14e5288510b83fef150bae1f6be77
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c3785466ac705a0acac1af6d60f73c0a697fa4b7504874b8d58db6a2efcaf21d
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: cffd7cde0caf543698b605bbdf64394a529c4fb11c025bd6ffa00d04d336f8a5cff8663d3d5a7e3f57a0f061d152d01914e2c3fbeaead37d6daf37ea491169bc
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: faefcadccccee11a7e896fc408dcbfddf858c73f44697b5961777285e4f7d878fcd7ee0eefd3d42a9cd5442946dfc9ded90d6875b5d12771a6bd1eb631b57c43
         
     | 
    
        data/lib/rouge/demos/jsl
    ADDED
    
    
    
        data/lib/rouge/demos/liquid
    CHANGED
    
    
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            node gen_x_v1() returns (x:real) = loop 0.0<x and x<42.0
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            node gen_x_v2() returns (x:real) = 
         
     | 
| 
      
 4 
     | 
    
         
            +
              loop { 0.0<x and x<42.0 fby loop [20] x = pre x }
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            node gen_x_v3() returns (target:real; x:real=0.0) =
         
     | 
| 
      
 7 
     | 
    
         
            +
              run target := gen_x_v2() in
         
     | 
| 
      
 8 
     | 
    
         
            +
              loop { x = (pre x + target) / 2.0 }
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            let inertia=0.6
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            node gen_x_v4()  returns (target:real; x:real=0.0) =
         
     | 
| 
      
 13 
     | 
    
         
            +
              run target := gen_x_v2() in
         
     | 
| 
      
 14 
     | 
    
         
            +
              exist px,ppx : real = 0.0 in
         
     | 
| 
      
 15 
     | 
    
         
            +
              loop { 
         
     | 
| 
      
 16 
     | 
    
         
            +
                  px = pre x and ppx = pre px and
         
     | 
| 
      
 17 
     | 
    
         
            +
                  x = (px+target) / 2.0+inertia*(px-ppx) 
         
     | 
| 
      
 18 
     | 
    
         
            +
              }
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            % from MiniZinc Handbook:
         
     | 
| 
      
 2 
     | 
    
         
            +
            % https://www.minizinc.org/doc-latest/en/modelling.html
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            % Colouring Australia using nc colours
         
     | 
| 
      
 5 
     | 
    
         
            +
            int: nc = 3;
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            var 1..nc: wa;   var 1..nc: nt;  var 1..nc: sa;   var 1..nc: q;
         
     | 
| 
      
 8 
     | 
    
         
            +
            var 1..nc: nsw;  var 1..nc: v;   var 1..nc: t;
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            constraint wa != nt;
         
     | 
| 
      
 11 
     | 
    
         
            +
            constraint wa != sa;
         
     | 
| 
      
 12 
     | 
    
         
            +
            constraint nt != sa;
         
     | 
| 
      
 13 
     | 
    
         
            +
            constraint nt != q;
         
     | 
| 
      
 14 
     | 
    
         
            +
            constraint sa != q;
         
     | 
| 
      
 15 
     | 
    
         
            +
            constraint sa != nsw;
         
     | 
| 
      
 16 
     | 
    
         
            +
            constraint sa != v;
         
     | 
| 
      
 17 
     | 
    
         
            +
            constraint q != nsw;
         
     | 
| 
      
 18 
     | 
    
         
            +
            constraint nsw != v;
         
     | 
| 
      
 19 
     | 
    
         
            +
            solve satisfy;
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            output ["wa=\(wa)\t nt=\(nt)\t sa=\(sa)\n",
         
     | 
| 
      
 22 
     | 
    
         
            +
                    "q=\(q)\t nsw=\(nsw)\t v=\(v)\n",
         
     | 
| 
      
 23 
     | 
    
         
            +
                     "t=", show(t),  "\n"];
         
     | 
    
        data/lib/rouge/demos/q
    CHANGED
    
    
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            *** Settings ***
         
     | 
| 
      
 2 
     | 
    
         
            +
            Document	  Example taken from http://robotframework.org/
         
     | 
| 
      
 3 
     | 
    
         
            +
            Suite Setup       Open Browser To Login Page
         
     | 
| 
      
 4 
     | 
    
         
            +
            Suite Teardown    Close Browser
         
     | 
| 
      
 5 
     | 
    
         
            +
            Test Setup        Go To Login Page
         
     | 
| 
      
 6 
     | 
    
         
            +
            Test Template     Login With Invalid Credentials Should Fail
         
     | 
| 
      
 7 
     | 
    
         
            +
            Resource          resource.txt
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            *** Test Cases ***               User Name        Password
         
     | 
| 
      
 10 
     | 
    
         
            +
            Invalid Username                 invalid          ${VALID PASSWORD}
         
     | 
| 
      
 11 
     | 
    
         
            +
            Invalid Password                 ${VALID USER}    invalid
         
     | 
| 
      
 12 
     | 
    
         
            +
            Invalid Username And Password    invalid          whatever
         
     | 
| 
      
 13 
     | 
    
         
            +
            Empty Username                   ${EMPTY}         ${VALID PASSWORD}
         
     | 
| 
      
 14 
     | 
    
         
            +
            Empty Password                   ${VALID USER}    ${EMPTY}
         
     | 
| 
      
 15 
     | 
    
         
            +
            Empty Username And Password      ${EMPTY}         ${EMPTY}
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            *** Keywords ***
         
     | 
| 
      
 18 
     | 
    
         
            +
            Login With Invalid Credentials Should Fail
         
     | 
| 
      
 19 
     | 
    
         
            +
                [Arguments]    ${username}    ${password}
         
     | 
| 
      
 20 
     | 
    
         
            +
                Input Username    ${username}
         
     | 
| 
      
 21 
     | 
    
         
            +
                Input Password    ${password}
         
     | 
| 
      
 22 
     | 
    
         
            +
                Submit Credentials
         
     | 
| 
      
 23 
     | 
    
         
            +
                Login Should Have Failed
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            Login Should Have Failed
         
     | 
| 
      
 26 
     | 
    
         
            +
                Location Should Be    ${ERROR URL}
         
     | 
| 
      
 27 
     | 
    
         
            +
                Title Should Be    Error Page
         
     | 
    
        data/lib/rouge/lexer.rb
    CHANGED
    
    | 
         @@ -49,6 +49,9 @@ module Rouge 
     | 
|
| 
       49 
49 
     | 
    
         
             
                  #
         
     | 
| 
       50 
50 
     | 
    
         
             
                  #     Lexer.find_fancy('guess', "#!/bin/bash\necho Hello, world")
         
     | 
| 
       51 
51 
     | 
    
         
             
                  #
         
     | 
| 
      
 52 
     | 
    
         
            +
                  #   If the code matches more than one lexer then Guesser::Ambiguous
         
     | 
| 
      
 53 
     | 
    
         
            +
                  #   is raised.
         
     | 
| 
      
 54 
     | 
    
         
            +
                  #
         
     | 
| 
       52 
55 
     | 
    
         
             
                  # This is used in the Redcarpet plugin as well as Rouge's own
         
     | 
| 
       53 
56 
     | 
    
         
             
                  # markdown lexer for highlighting internal code blocks.
         
     | 
| 
       54 
57 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -0,0 +1,126 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*- #
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Rouge
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Lexers
         
     | 
| 
      
 6 
     | 
    
         
            +
                class Apex < RegexLexer
         
     | 
| 
      
 7 
     | 
    
         
            +
                  title "Apex"
         
     | 
| 
      
 8 
     | 
    
         
            +
                  desc "The Apex programming language (provided by salesforce)"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  tag 'apex'
         
     | 
| 
      
 11 
     | 
    
         
            +
                  filenames '*.cls'
         
     | 
| 
      
 12 
     | 
    
         
            +
                  mimetypes 'text/x-apex'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def self.keywords
         
     | 
| 
      
 15 
     | 
    
         
            +
                    @keywords ||= Set.new %w(
         
     | 
| 
      
 16 
     | 
    
         
            +
                      assert break case catch continue default do else finally for if goto
         
     | 
| 
      
 17 
     | 
    
         
            +
                      instanceof new return switch this throw try while insert update
         
     | 
| 
      
 18 
     | 
    
         
            +
                      delete
         
     | 
| 
      
 19 
     | 
    
         
            +
                    )
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  def self.declarations
         
     | 
| 
      
 23 
     | 
    
         
            +
                    @declarations ||= Set.new %w(
         
     | 
| 
      
 24 
     | 
    
         
            +
                      abstract const enum extends final implements native private protected
         
     | 
| 
      
 25 
     | 
    
         
            +
                      public static super synchronized throws transient volatile with
         
     | 
| 
      
 26 
     | 
    
         
            +
                      sharing without inherited virtual global testmethod
         
     | 
| 
      
 27 
     | 
    
         
            +
                    )
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  def self.soql
         
     | 
| 
      
 31 
     | 
    
         
            +
                    @soql ||= Set.new %w(
         
     | 
| 
      
 32 
     | 
    
         
            +
                      SELECT FROM WHERE UPDATE LIKE TYPEOF END USING SCOPE WITH DATA
         
     | 
| 
      
 33 
     | 
    
         
            +
                      CATEGORY GROUP BY ROLLUP CUBE HAVING ORDER BY ASC DESC NULLS FIRST
         
     | 
| 
      
 34 
     | 
    
         
            +
                      LAST LIMIT OFFSET FOR VIEW REFERENCE UPDATE TRACKING VIEWSTAT OR AND
         
     | 
| 
      
 35 
     | 
    
         
            +
                    )
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                  def self.types
         
     | 
| 
      
 39 
     | 
    
         
            +
                    @types ||= Set.new %w(
         
     | 
| 
      
 40 
     | 
    
         
            +
                      String boolean byte char double float int long short var void
         
     | 
| 
      
 41 
     | 
    
         
            +
                    )
         
     | 
| 
      
 42 
     | 
    
         
            +
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                  def self.constants
         
     | 
| 
      
 45 
     | 
    
         
            +
                    @constants ||= Set.new %w(true false null)
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  id = /[a-z_][a-z0-9_]*/i
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  state :root do
         
     | 
| 
      
 51 
     | 
    
         
            +
                    rule %r/\s+/m, Text
         
     | 
| 
      
 52 
     | 
    
         
            +
                    
         
     | 
| 
      
 53 
     | 
    
         
            +
                    rule %r(//.*?$), Comment::Single
         
     | 
| 
      
 54 
     | 
    
         
            +
                    rule %r(/\*.*?\*/)m, Comment::Multiline
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                    rule %r/(?:class|interface)\b/, Keyword::Declaration, :class
         
     | 
| 
      
 57 
     | 
    
         
            +
                    rule %r/import\b/, Keyword::Namespace, :import
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                    rule %r/([@$.]?)(#{id})([:(]?)/io do |m|
         
     | 
| 
      
 60 
     | 
    
         
            +
                      if self.class.keywords.include? m[0].downcase
         
     | 
| 
      
 61 
     | 
    
         
            +
                        token Keyword
         
     | 
| 
      
 62 
     | 
    
         
            +
                      elsif self.class.soql.include? m[0].upcase
         
     | 
| 
      
 63 
     | 
    
         
            +
                        token Keyword
         
     | 
| 
      
 64 
     | 
    
         
            +
                      elsif self.class.declarations.include? m[0].downcase
         
     | 
| 
      
 65 
     | 
    
         
            +
                        token Keyword::Declaration
         
     | 
| 
      
 66 
     | 
    
         
            +
                      elsif self.class.types.include? m[0].downcase
         
     | 
| 
      
 67 
     | 
    
         
            +
                        token Keyword::Type
         
     | 
| 
      
 68 
     | 
    
         
            +
                      elsif self.class.constants.include? m[0].downcase
         
     | 
| 
      
 69 
     | 
    
         
            +
                        token Keyword::Constant
         
     | 
| 
      
 70 
     | 
    
         
            +
                      elsif 'package'.casecmp m[0]
         
     | 
| 
      
 71 
     | 
    
         
            +
                        token Keyword::Namespace
         
     | 
| 
      
 72 
     | 
    
         
            +
                      elsif m[1] == "@"
         
     | 
| 
      
 73 
     | 
    
         
            +
                        token Name::Decorator
         
     | 
| 
      
 74 
     | 
    
         
            +
                      elsif m[3] == ":"
         
     | 
| 
      
 75 
     | 
    
         
            +
                        groups Operator, Name::Label, Punctuation
         
     | 
| 
      
 76 
     | 
    
         
            +
                      elsif m[3] == "("
         
     | 
| 
      
 77 
     | 
    
         
            +
                        groups Operator, Name::Function, Punctuation
         
     | 
| 
      
 78 
     | 
    
         
            +
                      elsif m[1] == "."
         
     | 
| 
      
 79 
     | 
    
         
            +
                        groups Operator, Name::Property, Punctuation
         
     | 
| 
      
 80 
     | 
    
         
            +
                      else
         
     | 
| 
      
 81 
     | 
    
         
            +
                        token Name
         
     | 
| 
      
 82 
     | 
    
         
            +
                      end
         
     | 
| 
      
 83 
     | 
    
         
            +
                    end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                    rule %r/"/, Str::Double, :dq
         
     | 
| 
      
 86 
     | 
    
         
            +
                    rule %r/'/, Str::Single, :sq
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                    digit = /[0-9]_+[0-9]|[0-9]/
         
     | 
| 
      
 89 
     | 
    
         
            +
                    rule %r/#{digit}+\.#{digit}+([eE]#{digit}+)?[fd]?/, Num::Float
         
     | 
| 
      
 90 
     | 
    
         
            +
                    rule %r/0b(?:[01]_+[01]|[01])+/i, Num::Bin
         
     | 
| 
      
 91 
     | 
    
         
            +
                    rule %r/0x(?:\h_+\h|\h)+/i, Num::Hex
         
     | 
| 
      
 92 
     | 
    
         
            +
                    rule %r/0(?:[0-7]_+[0-7]|[0-7])+/, Num::Oct
         
     | 
| 
      
 93 
     | 
    
         
            +
                    rule %r/#{digit}+L?/, Num::Integer
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                    rule %r/[-+\/*~^!%&<>|=.?]/, Operator
         
     | 
| 
      
 96 
     | 
    
         
            +
                    rule %r/[\[\](){},:;]/, Punctuation;
         
     | 
| 
      
 97 
     | 
    
         
            +
                  end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                  state :class do
         
     | 
| 
      
 100 
     | 
    
         
            +
                    rule %r/\s+/m, Text
         
     | 
| 
      
 101 
     | 
    
         
            +
                    rule id, Name::Class, :pop!
         
     | 
| 
      
 102 
     | 
    
         
            +
                  end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                  state :import do
         
     | 
| 
      
 105 
     | 
    
         
            +
                    rule %r/\s+/m, Text
         
     | 
| 
      
 106 
     | 
    
         
            +
                    rule %r/[a-z0-9_.]+\*?/i, Name::Namespace, :pop!
         
     | 
| 
      
 107 
     | 
    
         
            +
                  end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                  state :escape do
         
     | 
| 
      
 110 
     | 
    
         
            +
                    rule %r/\\[btnfr\\"']/, Str::Escape
         
     | 
| 
      
 111 
     | 
    
         
            +
                  end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                  state :dq do
         
     | 
| 
      
 114 
     | 
    
         
            +
                    mixin :escape
         
     | 
| 
      
 115 
     | 
    
         
            +
                    rule %r/[^\\"]+/, Str::Double
         
     | 
| 
      
 116 
     | 
    
         
            +
                    rule %r/"/, Str::Double, :pop!
         
     | 
| 
      
 117 
     | 
    
         
            +
                  end
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                  state :sq do
         
     | 
| 
      
 120 
     | 
    
         
            +
                    mixin :escape
         
     | 
| 
      
 121 
     | 
    
         
            +
                    rule %r/[^\\']+/, Str::Double
         
     | 
| 
      
 122 
     | 
    
         
            +
                    rule %r/'/, Str::Double, :pop!
         
     | 
| 
      
 123 
     | 
    
         
            +
                  end
         
     | 
| 
      
 124 
     | 
    
         
            +
                end
         
     | 
| 
      
 125 
     | 
    
         
            +
              end
         
     | 
| 
      
 126 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/rouge/lexers/bpf.rb
    CHANGED
    
    | 
         @@ -13,14 +13,28 @@ module Rouge 
     | 
|
| 
       13 
13 
     | 
    
         
             
                  ).join('|')
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                  MISC_KEYWORDS = %w(
         
     | 
| 
       16 
     | 
    
         
            -
                    be16 be32 be64 exit lock
         
     | 
| 
      
 16 
     | 
    
         
            +
                    be16 be32 be64 exit lock map
         
     | 
| 
       17 
17 
     | 
    
         
             
                  ).join('|')
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                  state :root do
         
     | 
| 
      
 20 
     | 
    
         
            +
                    # Line numbers and hexadecimal output from bpftool/objdump
         
     | 
| 
      
 21 
     | 
    
         
            +
                    rule %r/(\d+)(:)(\s+)(\(\h{2}\))/i do
         
     | 
| 
      
 22 
     | 
    
         
            +
                      groups Generic::Lineno, Punctuation, Text::Whitespace, Generic
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
                    rule %r/(\d+)(:)(\s+)((?:\h{2} ){8})/i do
         
     | 
| 
      
 25 
     | 
    
         
            +
                      groups Generic::Lineno, Punctuation, Text::Whitespace, Generic
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
      
 27 
     | 
    
         
            +
                    rule %r/(\d+)(:)(\s+)/i do
         
     | 
| 
      
 28 
     | 
    
         
            +
                      groups Generic::Lineno, Punctuation, Text::Whitespace
         
     | 
| 
      
 29 
     | 
    
         
            +
                    end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       20 
31 
     | 
    
         
             
                    # Calls to helpers
         
     | 
| 
       21 
32 
     | 
    
         
             
                    rule %r/(call)(\s+)(\d+)/i do
         
     | 
| 
       22 
33 
     | 
    
         
             
                      groups Keyword, Text::Whitespace, Literal::Number::Integer
         
     | 
| 
       23 
34 
     | 
    
         
             
                    end
         
     | 
| 
      
 35 
     | 
    
         
            +
                    rule %r/(call)(\s+)(\w+)(#)(\d+)/i do
         
     | 
| 
      
 36 
     | 
    
         
            +
                      groups Keyword, Text::Whitespace, Name::Builtin, Punctuation, Literal::Number::Integer
         
     | 
| 
      
 37 
     | 
    
         
            +
                    end
         
     | 
| 
       24 
38 
     | 
    
         | 
| 
       25 
39 
     | 
    
         
             
                    # Unconditional jumps
         
     | 
| 
       26 
40 
     | 
    
         
             
                    rule %r/(goto)(\s*)(\+\d+)?(\s*)(<?\w+>?)/i do
         
     | 
| 
         @@ -28,10 +42,10 @@ module Rouge 
     | 
|
| 
       28 
42 
     | 
    
         
             
                    end
         
     | 
| 
       29 
43 
     | 
    
         | 
| 
       30 
44 
     | 
    
         
             
                    # Conditional jumps
         
     | 
| 
       31 
     | 
    
         
            -
                    rule %r/(if)(\s+)( 
     | 
| 
      
 45 
     | 
    
         
            +
                    rule %r/(if)(\s+)([rw]\d+)(\s*)([s!=<>]+)(\s*)(0x\h+|[-]?\d+)(\s*)(goto)(\s*)(\+\d+)?(\s*)(<?\w+>?)/i do
         
     | 
| 
       32 
46 
     | 
    
         
             
                      groups Keyword, Text::Whitespace, Name, Text::Whitespace, Operator, Text::Whitespace, Literal::Number, Text::Whitespace, Keyword, Text::Whitespace, Literal::Number::Integer, Text::Whitespace, Name::Label
         
     | 
| 
       33 
47 
     | 
    
         
             
                    end
         
     | 
| 
       34 
     | 
    
         
            -
                    rule %r/(if)(\s+)( 
     | 
| 
      
 48 
     | 
    
         
            +
                    rule %r/(if)(\s+)([rw]\d+)(\s*)([s!=<>]+)(\s*)([rw]\d+)(\s*)(goto)(\s*)(\+\d+)?(\s*)(<?\w+>?)/i do
         
     | 
| 
       35 
49 
     | 
    
         
             
                      groups Keyword, Text::Whitespace, Name, Text::Whitespace, Operator, Text::Whitespace, Name, Text::Whitespace, Keyword, Text::Whitespace, Literal::Number::Integer, Text::Whitespace, Name::Label
         
     | 
| 
       36 
50 
     | 
    
         
             
                    end
         
     | 
| 
       37 
51 
     | 
    
         | 
| 
         @@ -45,7 +59,7 @@ module Rouge 
     | 
|
| 
       45 
59 
     | 
    
         
             
                    rule %r/[+-\/\*&|><^s]{0,3}=/i, Operator
         
     | 
| 
       46 
60 
     | 
    
         | 
| 
       47 
61 
     | 
    
         
             
                    # Registers
         
     | 
| 
       48 
     | 
    
         
            -
                    rule %r/([+-]?)( 
     | 
| 
      
 62 
     | 
    
         
            +
                    rule %r/([+-]?)([rw]\d+)/i do
         
     | 
| 
       49 
63 
     | 
    
         
             
                      groups Punctuation, Name
         
     | 
| 
       50 
64 
     | 
    
         
             
                    end
         
     | 
| 
       51 
65 
     | 
    
         | 
| 
         @@ -73,7 +87,7 @@ module Rouge 
     | 
|
| 
       73 
87 
     | 
    
         | 
| 
       74 
88 
     | 
    
         
             
                  state :address do
         
     | 
| 
       75 
89 
     | 
    
         
             
                    # Address is offset from register
         
     | 
| 
       76 
     | 
    
         
            -
                    rule %r/(\()( 
     | 
| 
      
 90 
     | 
    
         
            +
                    rule %r/(\()([rw]\d+)(\s*)([+-])(\s*)(\d+)(\))/i do
         
     | 
| 
       77 
91 
     | 
    
         
             
                      groups Punctuation, Name, Text::Whitespace, Operator, Text::Whitespace, Literal::Number::Integer, Punctuation
         
     | 
| 
       78 
92 
     | 
    
         
             
                      pop!
         
     | 
| 
       79 
93 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -83,7 +97,7 @@ module Rouge 
     | 
|
| 
       83 
97 
     | 
    
         
             
                      groups Name, Punctuation, Literal::Number::Integer, Punctuation
         
     | 
| 
       84 
98 
     | 
    
         
             
                      pop!
         
     | 
| 
       85 
99 
     | 
    
         
             
                    end
         
     | 
| 
       86 
     | 
    
         
            -
                    rule %r/(\w+)(\[)( 
     | 
| 
      
 100 
     | 
    
         
            +
                    rule %r/(\w+)(\[)([rw]\d+)(\])/i do
         
     | 
| 
       87 
101 
     | 
    
         
             
                      groups Name, Punctuation, Name, Punctuation
         
     | 
| 
       88 
102 
     | 
    
         
             
                      pop!
         
     | 
| 
       89 
103 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -0,0 +1,156 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*- #
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Rouge
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Lexers
         
     | 
| 
      
 6 
     | 
    
         
            +
                class Clean < RegexLexer
         
     | 
| 
      
 7 
     | 
    
         
            +
                  title "Clean"
         
     | 
| 
      
 8 
     | 
    
         
            +
                  desc "The Clean programming language (clean.cs.ru.nl)"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  tag 'clean'
         
     | 
| 
      
 11 
     | 
    
         
            +
                  filenames '*.dcl', '*.icl'
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  def self.keywords
         
     | 
| 
      
 14 
     | 
    
         
            +
                    @keywords ||= Set.new %w(
         
     | 
| 
      
 15 
     | 
    
         
            +
                      if otherwise
         
     | 
| 
      
 16 
     | 
    
         
            +
                      let in
         
     | 
| 
      
 17 
     | 
    
         
            +
                      with where
         
     | 
| 
      
 18 
     | 
    
         
            +
                      case of
         
     | 
| 
      
 19 
     | 
    
         
            +
                      infix infixl infixr
         
     | 
| 
      
 20 
     | 
    
         
            +
                      class instance
         
     | 
| 
      
 21 
     | 
    
         
            +
                      generic derive
         
     | 
| 
      
 22 
     | 
    
         
            +
                      special
         
     | 
| 
      
 23 
     | 
    
         
            +
                      implementation definition system module
         
     | 
| 
      
 24 
     | 
    
         
            +
                      from import qualified as
         
     | 
| 
      
 25 
     | 
    
         
            +
                      dynamic
         
     | 
| 
      
 26 
     | 
    
         
            +
                      code inline foreign export ccall stdcall
         
     | 
| 
      
 27 
     | 
    
         
            +
                    )
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  # These are literal patterns common to the ABC intermediate language and
         
     | 
| 
      
 31 
     | 
    
         
            +
                  # Clean. Clean has more extensive literal patterns (see :basic below).
         
     | 
| 
      
 32 
     | 
    
         
            +
                  state :common_literals do
         
     | 
| 
      
 33 
     | 
    
         
            +
                    rule %r/'(?:[^'\\]|\\(?:x[0-9a-fA-F]+|\d+|.))'/, Str::Char
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                    rule %r/[+~-]?\d+\.\d+(?:E[+-]?\d+)?\b/, Num::Float
         
     | 
| 
      
 36 
     | 
    
         
            +
                    rule %r/[+~-]?\d+E[+-]?\d+\b/, Num::Float
         
     | 
| 
      
 37 
     | 
    
         
            +
                    rule %r/[+~-]?\d+/, Num::Integer
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    rule %r/"/, Str::Double, :string
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  state :basic do
         
     | 
| 
      
 43 
     | 
    
         
            +
                    rule %r/\s+/m, Text::Whitespace
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                    rule %r/\/\/\*.*/, Comment::Doc
         
     | 
| 
      
 46 
     | 
    
         
            +
                    rule %r/\/\/.*/, Comment::Single
         
     | 
| 
      
 47 
     | 
    
         
            +
                    rule %r/\/\*\*/, Comment::Doc, :comment_doc
         
     | 
| 
      
 48 
     | 
    
         
            +
                    rule %r/\/\*/, Comment::Multiline, :comment
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                    rule %r/[+~-]?0[0-7]+/, Num::Oct
         
     | 
| 
      
 51 
     | 
    
         
            +
                    rule %r/[+~-]?0x[0-9a-fA-F]+/, Num::Hex
         
     | 
| 
      
 52 
     | 
    
         
            +
                    mixin :common_literals
         
     | 
| 
      
 53 
     | 
    
         
            +
                    rule %r/(\[)(\s*)(')(?=.*?'\])/ do
         
     | 
| 
      
 54 
     | 
    
         
            +
                      groups Punctuation, Text::Whitespace, Str::Single, Punctuation
         
     | 
| 
      
 55 
     | 
    
         
            +
                      push :charlist
         
     | 
| 
      
 56 
     | 
    
         
            +
                    end
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  # nested commenting
         
     | 
| 
      
 60 
     | 
    
         
            +
                  state :comment_doc do
         
     | 
| 
      
 61 
     | 
    
         
            +
                    rule %r/\*\//, Comment::Doc, :pop!
         
     | 
| 
      
 62 
     | 
    
         
            +
                    rule %r/\/\/.*/, Comment::Doc # Singleline comments in multiline comments are skipped
         
     | 
| 
      
 63 
     | 
    
         
            +
                    rule %r/\/\*/, Comment::Doc, :comment
         
     | 
| 
      
 64 
     | 
    
         
            +
                    rule %r/[^*\/]+/, Comment::Doc
         
     | 
| 
      
 65 
     | 
    
         
            +
                    rule %r/[*\/]/, Comment::Doc
         
     | 
| 
      
 66 
     | 
    
         
            +
                  end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                  # This is the same as the above, but with Multiline instead of Doc
         
     | 
| 
      
 69 
     | 
    
         
            +
                  state :comment do
         
     | 
| 
      
 70 
     | 
    
         
            +
                    rule %r/\*\//, Comment::Multiline, :pop!
         
     | 
| 
      
 71 
     | 
    
         
            +
                    rule %r/\/\/.*/, Comment::Multiline # Singleline comments in multiline comments are skipped
         
     | 
| 
      
 72 
     | 
    
         
            +
                    rule %r/\/\*/, Comment::Multiline, :comment
         
     | 
| 
      
 73 
     | 
    
         
            +
                    rule %r/[^*\/]+/, Comment::Multiline
         
     | 
| 
      
 74 
     | 
    
         
            +
                    rule %r/[*\/]/, Comment::Multiline
         
     | 
| 
      
 75 
     | 
    
         
            +
                  end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                  state :root do
         
     | 
| 
      
 78 
     | 
    
         
            +
                    mixin :basic
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                    rule %r/code(\s+inline)?\s*{/, Comment::Preproc, :abc
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                    rule %r/_*[a-z][\w_`]*/ do |m|
         
     | 
| 
      
 83 
     | 
    
         
            +
                      if self.class.keywords.include?(m[0])
         
     | 
| 
      
 84 
     | 
    
         
            +
                        token Keyword
         
     | 
| 
      
 85 
     | 
    
         
            +
                      else
         
     | 
| 
      
 86 
     | 
    
         
            +
                        token Name
         
     | 
| 
      
 87 
     | 
    
         
            +
                      end
         
     | 
| 
      
 88 
     | 
    
         
            +
                    end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                    rule %r/_*[A-Z][\w_`]*/ do |m|
         
     | 
| 
      
 91 
     | 
    
         
            +
                      if m[0]=='True' || m[0]=='False'
         
     | 
| 
      
 92 
     | 
    
         
            +
                        token Keyword::Constant
         
     | 
| 
      
 93 
     | 
    
         
            +
                      else
         
     | 
| 
      
 94 
     | 
    
         
            +
                        token Keyword::Type
         
     | 
| 
      
 95 
     | 
    
         
            +
                      end
         
     | 
| 
      
 96 
     | 
    
         
            +
                    end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                    rule %r/[^\w_\s`]/, Punctuation
         
     | 
| 
      
 99 
     | 
    
         
            +
                    rule %r/_\b/, Punctuation
         
     | 
| 
      
 100 
     | 
    
         
            +
                  end
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                  state :escapes do
         
     | 
| 
      
 103 
     | 
    
         
            +
                    rule %r/\\x[0-9a-fA-F]{1,2}/i, Str::Escape
         
     | 
| 
      
 104 
     | 
    
         
            +
                    rule %r/\\d\d{0,3}/i, Str::Escape
         
     | 
| 
      
 105 
     | 
    
         
            +
                    rule %r/\\0[0-7]{0,3}/, Str::Escape
         
     | 
| 
      
 106 
     | 
    
         
            +
                    rule %r/\\[0-7]{1,3}/, Str::Escape
         
     | 
| 
      
 107 
     | 
    
         
            +
                    rule %r/\\[nrfbtv\\"']/, Str::Escape
         
     | 
| 
      
 108 
     | 
    
         
            +
                  end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                  state :string do
         
     | 
| 
      
 111 
     | 
    
         
            +
                    rule %r/"/, Str::Double, :pop!
         
     | 
| 
      
 112 
     | 
    
         
            +
                    mixin :escapes
         
     | 
| 
      
 113 
     | 
    
         
            +
                    rule %r/[^\\"]+/, Str::Double
         
     | 
| 
      
 114 
     | 
    
         
            +
                  end
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
                  state :charlist do
         
     | 
| 
      
 117 
     | 
    
         
            +
                    rule %r/(')(\])/ do
         
     | 
| 
      
 118 
     | 
    
         
            +
                      groups Str::Single, Punctuation
         
     | 
| 
      
 119 
     | 
    
         
            +
                      pop!
         
     | 
| 
      
 120 
     | 
    
         
            +
                    end
         
     | 
| 
      
 121 
     | 
    
         
            +
                    mixin :escapes
         
     | 
| 
      
 122 
     | 
    
         
            +
                    rule %r/[^\\']/, Str::Single
         
     | 
| 
      
 123 
     | 
    
         
            +
                  end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                  state :abc_basic do
         
     | 
| 
      
 126 
     | 
    
         
            +
                    rule %r/\s+/, Text::Whitespace
         
     | 
| 
      
 127 
     | 
    
         
            +
                    rule %r/\|.*/, Comment::Single
         
     | 
| 
      
 128 
     | 
    
         
            +
                    mixin :common_literals
         
     | 
| 
      
 129 
     | 
    
         
            +
                  end
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                  # The ABC intermediate language can be included, similar to C's inline
         
     | 
| 
      
 132 
     | 
    
         
            +
                  # assembly. For some information about ABC, see:
         
     | 
| 
      
 133 
     | 
    
         
            +
                  # https://en.wikipedia.org/wiki/Clean_(programming_language)#The_ABC-Machine
         
     | 
| 
      
 134 
     | 
    
         
            +
                  state :abc do
         
     | 
| 
      
 135 
     | 
    
         
            +
                    mixin :abc_basic
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
                    rule %r/}/, Comment::Preproc, :pop!
         
     | 
| 
      
 138 
     | 
    
         
            +
                    rule %r/\.\w*/, Keyword, :abc_rest_of_line
         
     | 
| 
      
 139 
     | 
    
         
            +
                    rule %r/[\w_]+/, Name::Builtin, :abc_rest_of_line
         
     | 
| 
      
 140 
     | 
    
         
            +
                  end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                  state :abc_rest_of_line do
         
     | 
| 
      
 143 
     | 
    
         
            +
                    rule %r/\n/, Text::Whitespace, :pop!
         
     | 
| 
      
 144 
     | 
    
         
            +
                    rule %r/}/ do
         
     | 
| 
      
 145 
     | 
    
         
            +
                      token Comment::Preproc
         
     | 
| 
      
 146 
     | 
    
         
            +
                      pop!
         
     | 
| 
      
 147 
     | 
    
         
            +
                      pop!
         
     | 
| 
      
 148 
     | 
    
         
            +
                    end
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
                    mixin :abc_basic
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                    rule %r/\S+/, Name
         
     | 
| 
      
 153 
     | 
    
         
            +
                  end
         
     | 
| 
      
 154 
     | 
    
         
            +
                end
         
     | 
| 
      
 155 
     | 
    
         
            +
              end
         
     | 
| 
      
 156 
     | 
    
         
            +
            end
         
     |