blob: f02bf03b0a9dd6388c58226bb186e67017f34d03 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
\_codedecl \_hisyntaxlua {Syntax highlighting for Lua sources <2021-06-29>}
\_newtoks \_hisyntaxlua \_newtoks \_hicolorslua
\_global\_hicolorslua={% colors for the Lua language
\_hicolor K \Red % Keywords
\_hicolor S \Magenta % Strings
\_hicolor C \Green % Comments
\_hicolor N \Cyan % Numbers
\_hicolor P \Blue % Preprocessor
\_hicolor O \Blue % Other tokens
}
\_global\_hisyntaxlua={%
\_the\_hicolorslua
\_let\c=\_relax \_let\e=\_relax \_let\o=\_relax
\_replfromto {--[}{--]} {\x C{--[#1--]}}% multi line comment --[...--]
\_replfromto {--}{^^J} {\z C{--#1}^^J}% single line comment --...
\_replthis {\_string\"} {{\_string\"}}% \" protected inside strings
\_replthis {\_string\'} {{\_string\'}}% \' protected inside strings
\_replfromto {"}{"} {\x S{"#1"}}% "..."
\_replfromto {'}{'} {\x S{'#1'}}% "..."
% missing: [[, [=[, [==[ strings, " ' in string of other kind
\_edef\_tmpa {{<<}{>>}{//}{==}{\_string~=}{<=}{>=}{::}{...}{..}%
+-*/\_pcent^\_csstring\#\_string&\_string~|%
<>=()]\_string{\_string}[];:,.}% other tokens
\_ea \_foreach \_tmpa
\_do {\_replthis{#1}{\n\o{#1}\n}}%
\_foreach % keywords
{and}{break}{do}{else}{elseif}{end}{false}{for}{function}{goto}%
{if}{in}{local}{nil}{not}{or}{repeat}{return}{then}{true}{until}{while}%
\_do {\_replthis{\n#1\n}{\z K{#1}}}%
\_replthis{.}{\n.\n} % numbers
\_foreach 0123456789
\_do {\_replfromto{\n#1}{\n}{\c#1##1\e}}%
\_replthis{\e.\c}{.}%
\_replthis{\e.\n}{.\e}%
\_replthis{\n.\c}{\c.}%
\_replthis{e\e\o+\c}{e+}\_replthis{e\e\o-\c}{e-}%
\_replthis{E\e\o+\c}{E+}\_replthis{E\e\o-\c}{E-}%
\_def\o#1{\z O{#1}}%
\_def\c#1\e{\z N{#1}}%
}
\_endcode %------------------------------------------------
The list of keywords and special symbols comes from the Lua 5.3 Reference
Manual\fnote{\url{https://www.lua.org/manual/5.3/manual.html\#3}}, otherwise
this is mostly a port of `hisyntax-c.opm`.
\begtt \hisyntax{lua}
and break do else elseif end
false for function goto if in
local nil not or repeat return
then true until while
+ - * / % ^ #
& ~ | << >> //
== ~= <= >= < > =
( ) { } [ ] ::
; : , . .. ...
a = 'alo\n123"'
a = "alo\n123\""
a = '\97lo\10\04923"'
a = [[alo
123"]]
a = [==[
alo
123"]==]
3 345 0xff 0xBEBADA
3.0 3.1416 314.16e-2 0.31416E1 34e1
0x0.1E 0xA23p-4 0X1.921FB54442D18P+1
1+1 2+a
--[ multi line
comment
--]
print(1+1)
\endtt
|