rubychan/coderay — pull request #21 by Quintus (2012-04-22 19:03:08+00:00)
Title: Lua scanner

Hi there,

I’ve written a CodeRay scanner for the [Lua](http://lua.org) programming language as I’m currently doing a lot of Lua stuff and because CodeRay is my favourite code highlighter I thought someone had to do something about this definite lack of features ;-)

I’ve tested the scanner with a good portion of obscure Lua code, but of course it’s possible that it may doesn’t recognize something it has to or the other way round.

Regarding Lua’s [length operator #](http://www.lua.org/manual/5.2/manual.html#3.4.6) I wasn’t sure whether to parse expressions using it directly as integer, because although that operator is intended to return the "length" of something, it’s possible to overwrite it like this:

metatable = {}
function metatable.__len()
return "Foo"
end

table = {}
print(#table) --> 0
setmetatable(table, metatable)
print(#table) --> Foo

That way it doesn’t return an integral value after all. So, shall I add this feature or not?

Finally I don’t really like the CSS style I’ve added for the Lua table definitions, but I’ve not yet digged that much in things such as hsla expressions in CSS. But changing that one shouldn’t be too hard ;-)

I’ve implemented the scanner by reference to the [official manual for Lua 5.2](http://www.lua.org/manual/5.2/manual.html) which claims to cover the Lua language completely and as far as I can see the scanner covers everything mentioned there.

Thanks for consideration!
Valete,
Quintus