"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/langDefs/perl.lang" (12 May 2020, 6348 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 "perl.lang": 3.55_vs_3.56.

    1 
    2 Description="Perl"
    3 
    4 Categories = {"source", "script"}
    5 
    6 
    7 --[[============================================================================
    8                                       CHANGELOG
    9 ================================================================================
   10   (2019/01/11 | Highlight v3.49)
   11     - fixed Highlighting of variables
   12 
   13   (2018/01/03 | Highlight v3.42)
   14     - improved Perl6 support
   15     - allow _ in hereDoc delimiter
   16 --]]
   17 
   18 
   19 --TODO handle '
   20 Identifiers=[[ [a-zA-Z_][\-\w]* ]]
   21 
   22 Keywords={
   23   { Id=1,
   24     List={"if", "else", "elsif", "unless", "given", "when", "default", "while", "for", "foreach",
   25     "do", "until", "continue", "return", "last", "next", "redo", "goto", "break", "exit", "sub",
   26     "package", "use", "no", "dump", "require", "BEGIN", "CHECK", "INIT", "END", "UNITCHECK",
   27     "NEXT", "CATCH",  "loop", "class", "in", "say", "loop", "has", "method", "multi", "macro",
   28     "lazy", "gather", "take", "role", "is", "does", "rw" },
   29   },
   30   { Id=2,
   31     Regex=[[ [$@%]\#?[^(\s|\.|\=|\:|\-\>|\"|\'|\(|\[|\)|\]|\{|\}|>|<|\;)]+ ]],
   32   },
   33   { Id=3,
   34     List={"defined", "undef", "eq", "ne", "lt", "gt", "ge", "le", "cmp", "not",
   35     "and", "or", "xor", "bless", "ref", "my", "our", "local", "state", "chomp",
   36     "chop", "chr", "crypt", "index", "rindex", "lc", "lcfirst", "length", "ord",
   37     "pack", "print", "printf", "sprintf", "substr", "uc",
   38     "ucfirst", "pos", "quotemeta", "split", "study", "abs", "atan2", "cos",
   39     "exp", "hex", "int", "log", "oct", "rand", "sin", "sqrt", "srand", "splice",
   40     "unshift", "shift", "push", "pop", "join", "reverse", "grep", "map", "sort",
   41     "unpack", "pack", "delete", "each", "exists", "keys",
   42     "values", "syscall", "dbmopen", "dbmclose", "binmode", "close", "closedir",
   43     "eof", "fileno", "getc", "stat", "lstat", "read", "readdir", "readline", "pipe",
   44     "rewinddir", "say", "select", "tell", "telldir", "write", "fcntl", "flock",
   45     "ioctl", "open", "opendir", "seek", "seekdir",
   46     "sysopen", "sysread", "sysseek", "syswrite", "truncate", "chdir", "chmod",
   47     "chown", "chroot", "glob", "link", "mkdir", "readlink", "rename", "rmdir", "symlink",
   48     "umask", "unlink", "utime", "caller", "die", "wantarray", "vec", "alarm",
   49     "exec", "fork", "getpgrp", "getppid", "getpriority", "kill", "pipe", "setpgrp",
   50     "setpriority", "sleep", "system", "times", "wait", "waitpid", "accept", "bind",
   51     "connect", "getpeername", "getsockname",
   52     "getsockopt", "listen", "recv", "send", "setsockopt", "shutdown", "socket",
   53     "socketpair", "msgctl", "msgget", "msgrcv", "msgsnd", "semctl", "semget",
   54     "semop", "shmctl", "shmget", "shmread", "shmwrite", "gethostent", "getnetent",
   55     "getprotoent", "getservent", "setpwent",
   56     "setgrent", "sethostent", "setnetent", "setprotoent", "setservent",
   57     "endpwent", "endgrent", "endhostent", "endnetent", "endprotoent", "endservent",
   58     "gethostbyaddr", "gethostbyname", "getnetbyaddr", "getnetbyname",
   59     "getprotobyname", "getprotobynumber", "getservbyname",
   60     "getservbyport", "getpwuid", "getpwnam", "getgrgid", "getgrnam", "getlogin",
   61     "getpwent", "getgrent", "gmtime", "localtime", "time", "warn", "formline",
   62     "reset", "scalar", "prototype", "lock", "tied", "untie", "eval", "try", "constant" },
   63   },
   64   { Id=4,
   65   Regex=[[->([a-zA-Z0-9_]+)]],
   66   Group=1,
   67   },
   68 
   69   --# Still only covers more common usage but by far not all
   70     -- see OnStateChange below
   71   { Id=4,
   72     Regex=[[\/.*?\/[msixpodualgc]*|m\/.*?\/[msixpodualgc]*|qr\/.*?\/[msixpodual]*|s\/.*?\/.*?\/[msixpodualgcer]*|(?:tr|y)\/.*?\/.*?\/[cdsr]*|m!.*?![msixpodualgc]*|qr!.*?![msixpodual]*|s!.*?!.*?![msixpodualgcer]*|(?:tr|y)!.*?!.*?![cdsr]*|m\?.*?\?[msixpodualgc]*|m\{.*?\}[msixpodualgc]*|qr\{.*?\}[msixpodual]*|s\{.*?\}\s*\{.*?\}[msixpodualgcer]*|(?:tr|y)\{.*?\}\s*\{.*?\}[cdsr]*]],
   73     Group=0
   74   },
   75 
   76   { Id=4,
   77     Regex=[=[ q[qxwr]?[\[\{\(] ]=]
   78   },
   79 }
   80 
   81 -- hereDoc opening delimiter, see OnStateChange to handle end of string
   82 -- do not allow digits as heredoc delimiters
   83 Strings={
   84   Delimiter=[=["|'|`|<<["']?[\w_]+["']?]=],
   85   Interpolation=[[ [@\$%]\w+ ]],
   86 }
   87 
   88 IgnoreCase=false
   89 
   90 --sample: https://fossies.org/linux/Time-HiRes/HiRes.pm
   91 Comments={
   92   { Block=true,
   93     Nested=false,
   94     Delimiter = { [[(?:^=pod|^=head[1234]|^=over|^=item|^=back|^=begin|^=end|^=for|^=encoding)]], [[^=cut\s*\Z]] }  },
   95   { Block=false,
   96     Delimiter= { [[(?<!\\)#]] },
   97   },
   98 }
   99 
  100 --todo for 1..5
  101 Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\:|\&|<|>|\!|\@|~|\=|\/|\*|\+|\-|\$|\.|\^|\~|\%|\|]]
  102 
  103 Digits=[[ (?:0x|0X|0b)[0-9a-fA-F_]+|\d*[\.\_]?\d+(?:[eE][\-\+]?\d+)?[fFlLuU]? ]]
  104 
  105 -- fix recognition of $ and other Perl perversions
  106 function OnStateChange(oldState, newState, token, groupID)
  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 and groupID == 4 then
  110     return HL_REJECT
  111   end
  112 
  113   if  (string.sub(token,1,1) =="$" or string.sub(token,1,1) =="@" or string.sub(token,1,1) =="%")
  114     and oldState==HL_STRING and newState==HL_KEYWORD then
  115     return HL_INTERPOLATION
  116   end
  117 
  118   --recognize hereDoc multine strings
  119   --do not clear hereDoc if token is ",' or `
  120   if (oldState==HL_STANDARD or oldState==HL_STRING) and newState==HL_STRING
  121     and not string.find("\"'`", token) then
  122     hereDoc = string.match(token, "<<'?\"?([%a_]+)" )
  123   end
  124 
  125   if oldState==HL_STRING and token==hereDoc then
  126     hereDoc = nil
  127     return HL_STRING_END
  128   end
  129 
  130   -- fix issue in CGI.pm testcase (line 1060 ff)
  131   if oldState~=HL_STRING and oldState~=HL_INTERPOLATION and oldState~=HL_ESC_SEQ then
  132     qString=0
  133   end
  134 
  135   if newState==HL_KEYWORD and (token=="q{" or token=="qq{" or token=="qw{" or token=="qx{")  then
  136     qString=1
  137     return HL_STRING
  138   end
  139 
  140   if newState==HL_KEYWORD and (token=="q(" or token=="qq(" or token=="qw(" or token=="qx(")  then
  141     qString=2
  142     return HL_STRING
  143   end
  144 
  145   if newState==HL_KEYWORD and (token=="q[" or token=="qq[" or token=="qw[" or token=="qx[")  then
  146     qString=3
  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   return newState
  166 end