"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/langDefs/ruby.lang" (12 May 2020, 4596 Bytes) of package /windows/www/highlight-3.57-x64.zip:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "ruby.lang": 3.56_vs_3.57.

    1 
    2 Description="Ruby"
    3 
    4 Categories = {"script"}
    5 
    6 Identifiers=[[ [a-zA-Z_][\w\-]* ]]
    7 
    8 Digits=[[ (?:0x|0X|0b)[0-9a-fA-F]+|\d*[\.\_]?\d+(?:[eE][\-\+]\d+)?[lLuU]? ]]
    9 
   10 Keywords={
   11   { Id=1,
   12     List={"alias", "and", "begin", "begin", "break", "case", "class", "def",
   13           "defined", "loop", "do", "else", "elsif", "end", "end", "ensure",
   14           "false", "for", "if", "in", "module", "next", "nil", "not", "or",
   15           "redo", "rescue", "retry", "return", "require", "self", "super",
   16           "then", "true", "undef", "unless", "until", "when", "while",
   17           "yield", "true", "false", "nil", "stdin", "stdout", "stderr", "env",
   18           "argf", "argv", "data", "version", "ruby-release-date",
   19           "ruby-platform", "include", "extend", "eval", "private", "raise", "throw"},
   20   },
   21   { Id=3,
   22     List = {"TRUE","FALSE","NIL","STDIN","STDOUT","STDERR","ENV","ARGF","ARGV",
   23             "DATA","RUBY_VERSION","RUBY_RELEASE_DATE","RUBY_PLATFORM"}
   24   },
   25   { Id=2,
   26     Regex=[[[\$\@][\/\w]+]],
   27   },
   28 
   29   -- see OnStateChange below
   30   { Id=3,
   31     Regex=[[m?\/.*?\/|(s|tr)\/.*?\/.*?\/[cegimosx]*]],
   32     Group=0,
   33   },
   34   { Id=3,
   35     Regex=[[\:\:?\w+]],
   36   },
   37   { Id=4,
   38     Regex=[[(\w+)\s*\(]],
   39   },
   40 
   41   --see OnStateChange
   42   { Id=5,
   43     Regex = [[ [#]\{[^}]*?\} ]],
   44   },
   45 }
   46 
   47 -- hereDoc opening delimiter, see OnStateChange to handle end of string
   48 Strings={
   49   Delimiter=[["|'|`|<<[\-~"'`]?[\w_]+["'`]?]],
   50   Interpolation = [[ [%]\{[^}]*?\} ]],
   51 
   52   DelimiterPairs= {
   53     { Open=[[%q\(]], Close=[[\)]] },
   54     { Open=[[%Q\(]], Close=[[\)]] },
   55 
   56     { Open=[[%Q\!]], Close=[[\!]] },
   57     { Open=[[%Q\+]], Close=[[\+]] },
   58     { Open=[[%Q\[]], Close=[=[ \] ]=] },
   59 
   60 
   61     { Open=[[%\(]], Close=[[\)]] },
   62     { Open=[[%x\(]], Close=[[\)]] },
   63     { Open=[[%q\{]], Close=[[\}]] },
   64     { Open=[[%Q\{]], Close=[[\}]] },
   65     { Open=[[%\{]], Close=[[\}]] },
   66     { Open=[[%x\{]], Close=[[\}]] },
   67   }
   68 
   69 }
   70 
   71 IgnoreCase=false
   72 
   73 Comments={
   74   { Block=false,
   75     Delimiter= { [[#]] },
   76   },
   77   { Block=true,
   78     Nested=false,
   79     Delimiter= { [[\=begin]],[[\=end]] }
   80   }
   81 }
   82 
   83 Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\:|\.|\&|<|>|\!|\-|\+|\/|\*|\=|\?|\%|\|]]
   84 
   85 -- resolve issue with # which starts comments and extrapolation sequences in strings
   86 function OnStateChange(oldState, newState, token, groupID)
   87 
   88 
   89 
   90   if oldState~=HL_STRING and newState==HL_INTERPOLATION then
   91     return HL_REJECT
   92   end
   93 
   94   if oldState==HL_STRING and token==hereDoc then
   95     hereDoc = nil
   96     return HL_STRING_END
   97   end
   98 
   99   if hereDoc~=nil then
  100     return HL_STRING
  101   end
  102 
  103   --resolve issue with #{} sequence within strings
  104   if oldState==HL_STRING and newState==HL_KEYWORD and groupID==5 then
  105     return HL_INTERPOLATION
  106   end
  107 
  108   -- resolve issue with regex expression which spans strings like "</i>" + VAR + "</i>"
  109   if string.sub(token,1,1)=="/" and oldState==HL_STRING and newState==HL_KEYWORD then
  110     return HL_REJECT
  111   end
  112 
  113   --recognize hereDoc multine strings (including squiggly heredoc)
  114   --do not clear hereDoc if token is ",' or `
  115   if (oldState==HL_STANDARD or oldState==HL_STRING) and newState==HL_STRING
  116       and not string.find("\"'`", token) then
  117       hereDoc = string.match(token, "<<[%-~\"'`]?([%a_]+)" )
  118   end
  119 
  120   -- fix quoted string termination
  121   --if oldState~=HL_STRING  then
  122   --   qString=0
  123   -- end
  124 
  125   if newState==HL_STRING and (token=="%q(" or token=="%Q(" or token=="%(" or token=="%x(" ) then
  126       qString=1
  127       return HL_STRING
  128   end
  129 
  130   if newState==HL_STRING and (token=="%q{" or token=="%Q{" or token=="%{" or token=="%x{" ) then
  131       qString=2
  132       return HL_STRING
  133   end
  134 
  135   if newState==HL_STRING and  token=="%Q!"  then
  136       qString=3
  137       return HL_STRING
  138   end
  139 
  140   if newState==HL_STRING and  token=="%Q["  then
  141     qString=4
  142     return HL_STRING
  143   end
  144 
  145   if newState==HL_STRING and  token=="%Q+"  then
  146     qString=5
  147     return HL_STRING
  148   end
  149 
  150   if oldState==HL_STRING and qString==1 and token==")" then
  151     qString=0
  152     return HL_STRING_END
  153   end
  154 
  155   if oldState==HL_STRING and qString==2 and token=="}" then
  156     qString=0
  157     return HL_STRING_END
  158   end
  159 
  160   if oldState==HL_STRING and qString==3 and token=="!" then
  161     qString=0
  162     return HL_STRING_END
  163   end
  164 
  165   if oldState==HL_STRING and qString==4 and token=="]" then
  166     qString=0
  167     return HL_STRING_END
  168   end
  169 
  170   if oldState==HL_STRING and qString==5 and token=="+" then
  171     qString=0
  172     return HL_STRING_END
  173   end
  174 
  175   -- https://fossies.org/linux/misc/puppet-5.3.2.tar.gz/puppet-5.3.2/lib/puppet/indirector/hiera.rb?m=t
  176 
  177   if token==")" or token=="}"  or token=="]" or token=="{"  and oldState~=HL_STRING then
  178     return HL_OPERATOR
  179   end
  180   return newState
  181 end