diff --git a/autotests/html/highlight.lua.html b/autotests/html/highlight.lua.html index 6ea0df4..7226f6b 100644 --- a/autotests/html/highlight.lua.html +++ b/autotests/html/highlight.lua.html @@ -1,167 +1,167 @@ highlight.lua
 #!/usr/bin/env lua
 
 -- Metatables
 t = {
-    __add=function(a,b)return a+b end,
-    __sub=function(a,b)return a-b end,
-    __mul=function(a,b)return a*b end,
-    __div=function(a,b)return a/b end,
-    __mod=function(a,b)return a%b end,
-    __pow=function(a,b)return a^b end,
-    __unm=function(a)return -a end,
-    __idiv=function(a,b)return a//b end,
-    __band=function(a,b)return a&b end,
-    __bor=function(a,b)return a|b end,
-    __bxor=function(a,b)return a~b end,
-    __bnot=function(a)return ~a end,
-    __shl=function(a,b)return a<<b end,
-    __shr=function(a,b)return a>>b end,
-    __concat=function(a,b)return a..b end,
-    __len=function(a)return #a end,
-    __eq=function(a,b)return a==b end,
-    __lt=function(a,b)return a<b end,
-    __le=function(a,b)return a<=b end,
-    __index=function(t,k)return t[k] end,
-    __newindex=function(t,k,v)return t[k]=v end,
-    __call=function(f, ...)return f(...) end,
-
-   __tostring=function(a)return tostring(a) end,
-   __pairs=function(t)return pairs(a) end,
+    __add=function(a,b)return a+b end,
+    __sub=function(a,b)return a-b end,
+    __mul=function(a,b)return a*b end,
+    __div=function(a,b)return a/b end,
+    __mod=function(a,b)return a%b end,
+    __pow=function(a,b)return a^b end,
+    __unm=function(a)return -a end,
+    __idiv=function(a,b)return a//b end,
+    __band=function(a,b)return a&b end,
+    __bor=function(a,b)return a|b end,
+    __bxor=function(a,b)return a~b end,
+    __bnot=function(a)return ~a end,
+    __shl=function(a,b)return a<<b end,
+    __shr=function(a,b)return a>>b end,
+    __concat=function(a,b)return a..b end,
+    __len=function(a)return #a end,
+    __eq=function(a,b)return a==b end,
+    __lt=function(a,b)return a<b end,
+    __le=function(a,b)return a<=b end,
+    __index=function(t,k)return t[k] end,
+    __newindex=function(t,k,v)return t[k]=v end,
+    __call=function(f, ...)return f(...) end,
+
+   __tostring=function(a)return tostring(a) end,
+   __pairs=function(t)return pairs(a) end,
    -- setmetatable
    __metatable=true
    -- Garbage collector
-   __gc=function() end
+   __gc=function() end
    -- Weak table
    __mode='k' -- or 'v'
 }
 
 a or b
 a and b
 a~=b
 a>=b
 true or false
 a or nil
 a::m
 a.m
 a;a
 
 
 -- String
 '\a'
 '\b'
 '\f'
 '\n'
 '\r'
 '\t'
 '\v'
 '\\'
 '\"'
 '\''
 '\z'
 '\xff'
 '\xFF'
 '\231'
 '\23'
 '\2'
 '\u{100201}' -- max 6 digits
 '\2a\ks' -- error
 
 'multi\
 line'
 'multi\z
 line'
 'multi\z    line\
 2'
 
 a = 'alo\n123"'
 a = "alo\n123\""
 a = '\97lo\10\04923"'
 a = [[alo
 123"]]
 a = [==[
 alo
 123"]==]
 
 
 -- Decimal
 3
 345
 0xff
 0xBEBADA
 
 -- Float
 3.
 .3
 3.0
 3.1416
 314.16e-2
 314.e+2
 0.31416E1
 34e1
 0.e3
 0x0.1E
 0xA23p-4
 0xA.p+4
 0x.ap4
 0X1.921FB54442D18P+1
 -- error
 32p
 0xp-4
 0x.p-4
 
 
 -- single comment
 xyz()
 --[[
  long comment
 ]]
 xyz()
 
 
 a = { [f(1)] = g; "x", "y"; x = 1, f(x), [30] = 23; 45 }
 
 -- is equivalent to
 
 do
   local t = {}
   t[f(1)] = g
   t[1] = "x" -- 1st exp
   t[2] = "y" -- 2nd exp
   t.x = 1 -- t["x"] = 1
   t[3] = f(x) -- 3rd exp
   t[30] = 23
   t[4] = 45 -- 4th exp
   a = t
 end
 
 32-0x43+0x2-5
 return"a"
 return'a'
 return{}
 f(3)
 f'a'
 f"a"
 f{s=2}
 f[[s]]
 f[=[s]=]
 #a
 
 local CONSTANT = a
 
 a = {}
 local x = 20
 for i=1,10 do
   local y = 0
-  a[i] = function () y=y+1; return x+y end
+  a[i] = function () y=y+1; return x+y end
 end
 
 --! \brief gfind is deprecated
 string.gfind('s')
 string.gmatch('f')
 
diff --git a/autotests/html/test.pbl.html b/autotests/html/test.pbl.html index f57092f..fecdf4f 100644 --- a/autotests/html/test.pbl.html +++ b/autotests/html/test.pbl.html @@ -1,108 +1,108 @@ test.pbl
 # Wesnoth Markup Language
 
 #textdomain wesnoth-libs
 
 #define __GUI_WINDOW_HEIGHT
 (
 	if(window_height = 0, 9999, window_height)
 )#enddef
 
 #define __GUI_WINDOW_FUNCTIONS
 def reevaluate_best_size(w, s)
 (
 [
 	0,
 #
 	debug_print('window ', w),
 	debug_print('screen ', s)
 #
 ][0]
 );
 #enddef
 
 # Don't highlight array indices as tags
 stored_unit[1].moves
 other[0][1][2]
 other[foo][bar]
 
 foo[{MACRO}]
 foo[$index]
 foo[  12 ]
 
 # Nested tags
 [allow_undo][/allow_undo][not][true]text[/true][/not]
 [foo][bar]text[/bar][/foo]
 
 [about]
 	title= _ "Campaign Designer"
 	text="Your Name"
 [/about]
 
 [window]
 	id = "tooltip"
 
 	[resolution]
 		definition = "tooltip"
 		automatic_placement = false
 		functions = "{__GUI_WINDOW_FUNCTIONS}"
 
 		[grid]
 
 			[row]
 
 				[column]
 
 					[label]
 						id = "label"
 						definition = "default_small"
 
 						use_markup = true
 						wrap = true
 					[/label]
 
 				[/column]
 
 			[/row]
 
 		[/grid]
 
 	[/resolution]
 
 [/window]
 
 [event]
 	name = preload
 	first_time_only = no
 	[lua]
 		code = <<
 			function narrator(t)
 				-- Behave like the [message] tag.
 				wesnoth.fire("message",
 				  { speaker = "narrator", message = t.sentence })
-			end
+			end
 		>>
 	[/lua]
 [/event]
 
 [event]
 	name = turn 1
 	[lua]
 		code = << narrator(...) >>
 		[args]
 			sentence = _ "Hello world!"
 		[/args]
 	[/lua]
 	[lua]
 		code = << narrator(...) >>
 		[args]
 			sentence = _ "How are you today?"
 		[/args]
 	[/lua]
 [/event]
 
diff --git a/autotests/reference/highlight.lua.ref b/autotests/reference/highlight.lua.ref index 26e640c..48151ea 100644 --- a/autotests/reference/highlight.lua.ref +++ b/autotests/reference/highlight.lua.ref @@ -1,160 +1,160 @@ #!/usr/bin/env lua

-- Metatables
t = {
- __add=function(a,b)return a+b end,
- __sub=function(a,b)return a-b end,
- __mul=function(a,b)return a*b end,
- __div=function(a,b)return a/b end,
- __mod=function(a,b)return a%b end,
- __pow=function(a,b)return a^b end,
- __unm=function(a)return -a end,
- __idiv=function(a,b)return a//b end,
- __band=function(a,b)return a&b end,
- __bor=function(a,b)return a|b end,
- __bxor=function(a,b)return a~b end,
- __bnot=function(a)return ~a end,
- __shl=function(a,b)return a<<b end,
- __shr=function(a,b)return a>>b end,
- __concat=function(a,b)return a..b end,
- __len=function(a)return #a end,
- __eq=function(a,b)return a==b end,
- __lt=function(a,b)return a<b end,
- __le=function(a,b)return a<=b end,
- __index=function(t,k)return t[k] end,
- __newindex=function(t,k,v)return t[k]=v end,
- __call=function(f, ...)return f(...) end,
-
- __tostring=function(a)return tostring(a) end,
- __pairs=function(t)return pairs(a) end,
+ __add=function(a,b)return a+b end,
+ __sub=function(a,b)return a-b end,
+ __mul=function(a,b)return a*b end,
+ __div=function(a,b)return a/b end,
+ __mod=function(a,b)return a%b end,
+ __pow=function(a,b)return a^b end,
+ __unm=function(a)return -a end,
+ __idiv=function(a,b)return a//b end,
+ __band=function(a,b)return a&b end,
+ __bor=function(a,b)return a|b end,
+ __bxor=function(a,b)return a~b end,
+ __bnot=function(a)return ~a end,
+ __shl=function(a,b)return a<<b end,
+ __shr=function(a,b)return a>>b end,
+ __concat=function(a,b)return a..b end,
+ __len=function(a)return #a end,
+ __eq=function(a,b)return a==b end,
+ __lt=function(a,b)return a<b end,
+ __le=function(a,b)return a<=b end,
+ __index=function(t,k)return t[k] end,
+ __newindex=function(t,k,v)return t[k]=v end,
+ __call=function(f, ...)return f(...) end,
+
+ __tostring=function(a)return tostring(a) end,
+ __pairs=function(t)return pairs(a) end,
-- setmetatable
__metatable=true
-- Garbage collector
- __gc=function() end
+ __gc=function() end
-- Weak table
__mode='k' -- or 'v'
}

a or b
a and b
a~=b
a>=b
true or false
a or nil
a::m
a.m
a;a


-- String
'\a'
'\b'
'\f'
'\n'
'\r'
'\t'
'\v'
'\\'
'\"'
'\''
'\z'
'\xff'
'\xFF'
'\231'
'\23'
'\2'
'\u{100201}' -- max 6 digits
'\2a\ks' -- error

'multi\
line'
'multi\z
line'
'multi\z line\
2'

a = 'alo\n123"'
a = "alo\n123\""
a = '\97lo\10\04923"'
a = [[alo
123"]]
a = [==[
alo
123"]==]


-- Decimal
3
345
0xff
0xBEBADA

-- Float
3.
.3
3.0
3.1416
314.16e-2
314.e+2
0.31416E1
34e1
0.e3
0x0.1E
0xA23p-4
0xA.p+4
0x.ap4
0X1.921FB54442D18P+1
-- error
32p
0xp-4
0x.p-4


-- single comment
xyz()
--[[
long comment
]]
xyz()


a = { [f(1)] = g; "x", "y"; x = 1, f(x), [30] = 23; 45 }

-- is equivalent to

do
local t = {}
t[f(1)] = g
t[1] = "x" -- 1st exp
t[2] = "y" -- 2nd exp
t.x = 1 -- t["x"] = 1
t[3] = f(x) -- 3rd exp
t[30] = 23
t[4] = 45 -- 4th exp
a = t
end

32-0x43+0x2-5
return"a"
return'a'
return{}
f(3)
f'a'
f"a"
f{s=2}
f[[s]]
f[=[s]=]
#a

local CONSTANT = a

a = {}
local x = 20
for i=1,10 do
local y = 0
- a[i] = function () y=y+1; return x+y end
+ a[i] = function () y=y+1; return x+y end
end

--! \brief gfind is deprecated
string.gfind('s')
string.gmatch('f')
diff --git a/autotests/reference/test.pbl.ref b/autotests/reference/test.pbl.ref index 30b7aaa..b4199f8 100644 --- a/autotests/reference/test.pbl.ref +++ b/autotests/reference/test.pbl.ref @@ -1,101 +1,101 @@ # Wesnoth Markup Language

#textdomain wesnoth-libs

#define __GUI_WINDOW_HEIGHT
(
if(window_height = 0, 9999, window_height)
)#enddef

#define __GUI_WINDOW_FUNCTIONS
def reevaluate_best_size(w, s)
(
[
0,
#
debug_print('window ', w),
debug_print('screen ', s)
#
][0]
);
#enddef

# Don't highlight array indices as tags
stored_unit[1].moves
other[0][1][2]
other[foo][bar]

foo[{MACRO}]
foo[$index]
foo[ 12 ]

# Nested tags
[allow_undo][/allow_undo][not][true]text[/true][/not]
[foo][bar]text[/bar][/foo]

[about]
title= _ "Campaign Designer"
text="Your Name"
[/about]

[window]
id = "tooltip"

[resolution]
definition = "tooltip"
automatic_placement = false
functions = "{__GUI_WINDOW_FUNCTIONS}"

[grid]

[row]

[column]

[label]
id = "label"
definition = "default_small"

use_markup = true
wrap = true
[/label]

[/column]

[/row]

[/grid]

[/resolution]

[/window]

[event]
name = preload
first_time_only = no
[lua]
code = <<
function narrator(t)
-- Behave like the [message] tag.
wesnoth.fire("message",
{ speaker = "narrator", message = t.sentence })
- end
+ end
>>
[/lua]
[/event]

[event]
name = turn 1
[lua]
code = << narrator(...) >>
[args]
sentence = _ "Hello world!"
[/args]
[/lua]
[lua]
code = << narrator(...) >>
[args]
sentence = _ "How are you today?"
[/args]
[/lua]
[/event]
diff --git a/data/syntax/lua.xml b/data/syntax/lua.xml index 44737b7..14a0dcd 100644 --- a/data/syntax/lua.xml +++ b/data/syntax/lua.xml @@ -1,538 +1,551 @@ ]> - + and function in local not or nil false true break do else elseif end for goto if repeat return then until while _PROMPT _PROMPT2 LUA_PATH LUA_CPATH LUA_INIT _ENV _VERSION _G package.config package.cpath package.loaded package.path package.preload package.searchers utf8.charpattern math.maxinteger math.mininteger math.pi assert collectgarbage dofile error getmetatable ipairs load loadfile next pairs pcall print rawequal rawget rawlen rawset select setmetatable tonumber tostring type + warn xpcall coroutine.create coroutine.isyieldable coroutine.resume + coroutine.kill coroutine.running coroutine.status coroutine.wrap coroutine.yield require package.loadlib package.searchpath string.byte string.char string.dump string.find string.format string.gmatch string.gsub string.len string.lower string.match string.pack string.packsize string.rep string.reverse string.sub string.unpack string.upper utf8.char utf8.codes utf8.codepoint utf8.len utf8.offset table.concat table.insert table.move table.pack table.remove table.sort table.unpack math.abs math.acos math.asin math.atan math.ceil math.cos math.deg math.exp math.floor math.fmod math.huge math.log math.max math.min math.modf math.rad math.random math.randomseed math.sin math.sqrt math.tan math.tointeger math.type math.utl io.close io.flush io.input io.lines io.open io.output io.popen io.read io.stderr io.stdin io.stdout io.tmpfile io.type io.write os.clock os.date os.difftime os.execute os.exit os.getenv os.remove os.rename os.setlocale os.time os.tmpname debug.debug debug.gethook debug.getinfo debug.getlocal debug.getmetatable debug.getregistry debug.getupvalue debug.getuservalue debug.sethook debug.setlocal debug.setmetatable debug.setupvalue debug.setuservalue debug.traceback debug.upvalueid debug.upvaluejoin cgilua cgilua.addclosefunction cgilua.addopenfunction cgilua.addopenfunction cgilua.addscripthandler cgilua.addscripthandler cgilua.buildprocesshandler cgilua.contentheader cgilua.cookies.delete cgilua.cookies.get cgilua.cookies.set cgilua.cookies.sethtml cgilua.cookies cgilua.doif cgilua.doscript cgilua.errorlog cgilua.handlelp cgilua.header cgilua.htmlheader cgilua.lp.compile cgilua.lp.include cgilua.lp.setcompatmode cgilua.lp.setoutfunc cgilua.lp.translate cgilua.mkabsoluteurl cgilua.mkurlpath cgilua.pack cgilua.put cgilua.redirect cgilua.script_file cgilua.script_path cgilua.script_pdir cgilua.script_vdir cgilua.script_vpath cgilua.serialize cgilua.servervariable cgilua.session.close cgilua.session.data cgilua.session.delete cgilua.session.load cgilua.session.new cgilua.session.open cgilua.session.save cgilua.session.setsessiondir cgilua.session cgilua.seterrorhandler cgilua.seterroroutput cgilua.setmaxfilesize cgilua.setmaxinput cgilua.setoutfunc cgilua.splitpath cgilua.urlcode.encodetable cgilua.urlcode.escape cgilua.urlcode.insertfield cgilua.urlcode.parsequery cgilua.urlcode.unescape cgilua.urlpath lfs lfs.attributes lfs.chdir lfs.currentdir lfs.dir lfs.lock lfs.mkdir lfs.rmdir lfs.touch lfs.unlock zip zip.open zip.openfile byte char dump find format gmatch gsub len lower match pack packsize rep reverse sub unpack upper concat insert move pack remove sort unpack close commit connect escape execute fetch getcolnames getcoltypes getlastautoid numrows rollback setautocommit files close flush lines read seek setvbuf write __add __sub __mul __div __mod __pow __unm __idiv __band __bor __bxor __bnot __shl __shr __concat __len __eq __lt __le __index __newindex __call __tostring __pairs __metatable __gc __mode _ALERT _ERRORMESSAGE _LOADED __ipairs foreach foreachi loadstring math.atan2 math.cosh math.frexp math.ldexp math.log10 math.mod math.pow math.sinh math.tanh string.gfind table.foreach table.foreachi table.getn table.setn - + + + + + + +