1% This file defines syntax highlighting for perl.
2% The original author is Lars Marowsky-Bree <lmb@pointer.in-minden.de>
3
4% Create and initialize the syntax tables.
5
6$1 = "perl";
7
8create_syntax_table ($1);
9define_syntax ("#", "", '%', $1);
10%define_syntax ("([{<", ")]}>", '(', $1);
11define_syntax ("([{", ")]}", '(', $1);
12define_syntax ('"', '"', $1);
13define_syntax ('\'', '\'', $1);
14define_syntax ('\\', '\\', $1);
15define_syntax ("$0-9a-zA-Z_", 'w', $1);        % words
16define_syntax ("-+0-9a-fA-F.xXL", '0', $1);   % Numbers
17define_syntax (",;.?:", ',', $1);
18define_syntax ("%-+/&*=<>|!~^", '+', $1);
19set_syntax_flags ($1, 4);
20
21#ifdef HAS_DFA_SYNTAX
22enable_highlight_cache("perl.dfa", $1);
23define_highlight_rule("#.*$", "comment", $1);
24define_highlight_rule("([\\$%&@\\*]|\\$#)[A-Za-z_0-9]+", "normal", $1);
25define_highlight_rule(strcat("\\$([_\\./,\"\\\\#\\*\\?\\]\\[;!@:\\$<>\\(\\)",
26			     "%=\\-~\\^\\|&`'\\+]|\\^[A-Z])"), "normal", $1);
27define_highlight_rule("[A-Za-z_][A-Za-z_0-9]*", "Knormal", $1);
28define_highlight_rule("[0-9]+(\\.[0-9]+)?([Ee][\\+\\-]?[0-9]*)?", "number",
29		      $1);
30define_highlight_rule("0[xX][0-9A-Fa-f]*", "number", $1);
31define_highlight_rule("[\\(\\[\\{\\<\\>\\}\\]\\),;\\.\\?:]", "delimiter", $1);
32define_highlight_rule("[%\\-\\+/&\\*=<>\\|!~\\^]", "operator", $1);
33define_highlight_rule("-[A-Za-z]", "keyword0", $1);
34define_highlight_rule("'[^']*'", "string", $1);
35define_highlight_rule("'[^']*$", "string", $1);
36define_highlight_rule("\"([^\"\\\\]|\\\\.)*\"", "string", $1);
37define_highlight_rule("\"([^\"\\\\]|\\\\.)*\\\\?$", "string", $1);
38define_highlight_rule("m?/([^/\\\\]|\\\\.)*/[gio]*", "string", $1);
39define_highlight_rule("m/([^/\\\\]|\\\\.)*\\\\?$", "string", $1);
40define_highlight_rule("s/([^/\\\\]|\\\\.)*(/([^/\\\\]|\\\\.)*)?/[geio]*",
41		      "string", $1);
42define_highlight_rule("s/([^/\\\\]|\\\\.)*(/([^/\\\\]|\\\\.)*)?\\\\?$",
43		      "string", $1);
44define_highlight_rule("(tr|y)/([^/\\\\]|\\\\.)*(/([^/\\\\]|\\\\.)*)?/[cds]*",
45		      "string", $1);
46define_highlight_rule("(tr|y)/([^/\\\\]|\\\\.)*(/([^/\\\\]|\\\\.)*)?\\\\?$",
47		      "string", $1);
48define_highlight_rule(".", "normal", $1);
49build_highlight_table ($1);
50#endif
51
52() = define_keywords ($1,
53		      strcat ("endhostentendserventgethostentgetservent",
54			       "getsockoptsethostentsetserventsetsockopt",
55			       "socketpair"),
56		      10);
57() = define_keywords ($1,
58		      strcat ("endprotoentgetpeernamegetprioritygetprotoent",
59			      "getsocknamesetprioritysetprotoent"),
60		      11);
61() = define_keywords ($1, "getnetbyaddrgetnetbyname", 12);
62() = define_keywords ($1,
63		      strcat ("gethostbyaddrgethostbynamegetservbyname",
64			      "getservbyport"),
65		      13);
66() = define_keywords ($1, "getprotobyname", 14);
67() = define_keywords ($1, "getprotobynumber", 16);
68() = define_keywords ($1, "-Xdoiflcm/mynoq/s/ucy/", 2);
69() = define_keywords ($1,
70		      strcat ("abschrcosdieeofexpforhexintlogmapoctordpoppos",
71			      "qq/qw/qx/refsintietr/usevec"),
72		      3);
73() = define_keywords ($1,
74		      strcat ("bindchopdumpeachelseevalexecexitforkgetcglobgoto",
75			      "grepjoinkeyskilllastlinknextopenpackpipepush",
76			      "randreadrecvredoseeksendsortsqrtstattelltime",
77			      "waitwarn"),
78		      4);
79() = define_keywords ($1,
80		      strcat ("alarmatan2blesschdirchmodchompchownclosecrypt",
81			       "elsiffcntlflockindexioctllocallstatmkdirprint",
82			       "resetrmdirsemopshiftsleepsplitsrandstudytimes",
83			       "umaskundefuntieuntilutimewhilewrite"),
84		      5);
85() = define_keywords ($1,
86		      strcat ("acceptcallerchrootdeleteexistsfilenogmtime",
87			       "importlengthlistenmsgctlmsggetmsgrcvmsgsnd",
88			       "printfrenamereturnrindexscalarselectsemctl",
89			       "semgetshmctlshmgetsocketsplicesubstrsystem",
90			       "unlinkunpackvalues"),
91		      6);
92() = define_keywords ($1,
93		      strcat ("binmodeconnectdbmopendefinedforeachgetpgrpgetppid",
94			       "lcfirstopendirreaddirrequirereverseseekdir",
95			       "setpgrpshmreadsprintfsymlinksyscallsysread",
96			       "telldirucfirstunshiftwaitpid"),
97		      7);
98() = define_keywords ($1,
99		      strcat ("closedirdbmcloseendgrentendpwentformline",
100			      "getgrentgetgrgidgetgrnamgetlogingetpwent",
101			      "getpwnamgetpwuidreadlinksetgrentsetpwent",
102			      "shmwriteshutdownsyswritetruncate"),
103		      8);
104() = define_keywords ($1,
105		      strcat ("endnetentgetnetentlocaltimequotemeta",
106			       "rewinddirsetnetentwantarray"),
107		      9);
108
109define perl_mode ()
110{
111   variable kmap = "perl";
112   set_mode (kmap, 4);
113   use_syntax_table (kmap);
114   runhooks("perl_mode_hook");
115}
116