"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/langDefs/crystal.lang" (12 May 2020, 3921 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 "crystal.lang": 3.53_vs_3.54.

    1 
    2 Description="Crystal"
    3 
    4 Categories = {"source"}
    5 
    6 Digits = [[ (?:0x|0X|0b)[0-9a-fA-F']+|\d*[\.]?\d+(?:[eE][\-\+]\d+)?[lLuU]* ]]
    7 
    8 Keywords={
    9   { Id=1,
   10     List={"abstract", "alias", "as", "as?", "asm", "begin", "break", "case", "class",
   11           "def", "do", "else", "elsif", "end", "ensure", "enum", "extend", "false",
   12           "for", "fun", "if", "in", "include", "instance_sizeof", "is_a?", "lib",
   13           "macro", "module", "next", "nil", "nil?", "of", "out", "pointerof", "private",
   14           "protected", "require", "rescue", "responds_to?", "return", "select", "self",
   15           "sizeof", "struct", "super", "then", "true", "type", "typeof",
   16           "unintialized", "union", "unless", "until", "verbatim", "when", "while",
   17           "with", "yield"},
   18   },
   19   { Id=2,
   20     List={"Nil", "Bool", "Char",
   21           "Float32", "Float64",
   22           "Int8", "Int16", "Int32", "Int64",
   23           "UInt8", "UInt16","UInt32","UInt64",
   24           "Number", "String", "Symbol",
   25           "Array", "Channel", "Hash", "NamedTuple", "Proc", "Tuple", "Set"},
   26   },
   27   { Id=3,
   28     Regex=[[ [\:@][a-z]\w+ ]]
   29   },
   30   { Id=4,
   31     Regex=[[(\w+)\s*\(]]
   32   }
   33 }
   34 
   35 Strings={
   36   Delimiter=[["""|'''|"|'|<<[\-~"'`]?[\w_]+["'`]?]],
   37   RawPrefix="r",
   38   Escape=[=[\\[ntvbrfa\\\?'"]|\\\d{3}|\\x[[:xdigit:]]{2}]=],
   39   Interpolation=[[ #\{\w+\} ]],
   40 
   41   DelimiterPairs= {
   42     { Open=[[%q\(]], Close=[[\)]] },
   43     { Open=[[%Q\(]], Close=[[\)]] },
   44 
   45 
   46     { Open=[[%\(]], Close=[[\)]] },
   47     { Open=[[%\{]], Close=[[\}]] },
   48 
   49 
   50     { Open=[[%\[]], Close=[=[ \] ]=] },
   51     { Open=[[%<]], Close=[[>]] },
   52     { Open=[[%\|]], Close=[[\|]] },
   53   }
   54 }
   55 
   56 Comments = {
   57   {
   58     Block=false,
   59     Delimiter = { [[ # ]] }
   60   }
   61 }
   62 
   63 IgnoreCase=false
   64 
   65 Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\.|\:|\&|<|>|\!|=|\/|\*|\%|\+|\-|\~|\||\^|\?]]
   66 
   67 function OnStateChange(oldState, newState, token, groupID)
   68 
   69 
   70 
   71   if oldState~=HL_STRING and newState==HL_INTERPOLATION then
   72       return HL_REJECT
   73   end
   74 
   75   if oldState==HL_STRING and token==hereDoc then
   76       hereDoc = nil
   77       return HL_STRING_END
   78   end
   79 
   80   if hereDoc~=nil then
   81     return HL_STRING
   82   end
   83 
   84   --resolve issue with #{} sequence within strings
   85   if oldState==HL_STRING and newState==HL_KEYWORD and groupID==5 then
   86       return HL_INTERPOLATION
   87   end
   88 
   89   -- resolve issue with regex expression which spans strings like "</i>" + VAR + "</i>"
   90   if string.sub(token,1,1)=="/" and oldState==HL_STRING and newState==HL_KEYWORD then
   91       return HL_REJECT
   92   end
   93 
   94   --recognize hereDoc multine strings (including squiggly heredoc)
   95   --do not clear hereDoc if token is ",' or `
   96   if (oldState==HL_STANDARD or oldState==HL_STRING) and newState==HL_STRING
   97       and not string.find("\"'`", token) then
   98       hereDoc = string.match(token, "<<[%-~\"'`]?([%a_]+)" )
   99   end
  100 
  101   -- fix quoted string termination
  102   --if oldState~=HL_STRING  then
  103   --   qString=0
  104   -- end
  105 
  106   if newState==HL_STRING and (token=="%q(" or token=="%Q("  ) then
  107       qString=1
  108       return HL_STRING
  109   end
  110 
  111 
  112   if newState==HL_STRING and  token=="%["  then
  113       qString=3
  114       return HL_STRING
  115   end
  116 
  117   if newState==HL_STRING and  token=="%<"  then
  118       qString=4
  119       return HL_STRING
  120   end
  121   if newState==HL_STRING and  token=="%|"  then
  122       qString=5
  123       return HL_STRING
  124   end
  125 
  126 
  127 
  128   if oldState==HL_STRING and qString==1 and token==")" then
  129       qString=0
  130       return HL_STRING_END
  131   end
  132 
  133 
  134   if oldState==HL_STRING and qString==3 and token=="]" then
  135       qString=0
  136       return HL_STRING_END
  137   end
  138 
  139   if oldState==HL_STRING and qString==4 and token==">" then
  140       qString=0
  141       return HL_STRING_END
  142   end
  143 
  144   if oldState==HL_STRING and qString==5 and token=="|" then
  145       qString=0
  146       return HL_STRING_END
  147   end
  148 
  149   -- https://fossies.org/linux/misc/puppet-5.3.2.tar.gz/puppet-5.3.2/lib/puppet/indirector/hiera.rb?m=t
  150 
  151   -- if token==")" or token=="}" or token=="{"  and oldState~=HL_STRING then
  152   --    return HL_OPERATOR
  153   -- end
  154 
  155   return newState
  156 end