Skip to content

Lua scanner - #21

Closed
Quintus wants to merge 14 commits into
rubychan:masterfrom
Quintus:lua-scanner
Closed

Lua scanner#21
Quintus wants to merge 14 commits into
rubychan:masterfrom
Quintus:lua-scanner

Conversation

@Quintus

Copy link
Copy Markdown

Hi there,

I’ve written a CodeRay scanner for the Lua 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 # 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 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

Quintus added 14 commits April 21, 2012 22:52
:reserved would be a more fitting token kind than :predefined, but
unfortunately :reserved looks like :keyword in Coderay’s default
stylesheet and this is NOT the same in Lua.
tbl2 = {
[30] = 10,
a = 1,
[{["a"] = "f"}] = 4,
c = {a = 5},
d = {a = 3, b = "fff", {["foo"] = 1}},
e = 9,
"foo",
{},
true,
3
}
Nice, ain’t it?
…tor.
tbl = {}
function tbl:foo(self)
print("foo")
end
x = function() print("anon") end
…vided by the `base' library.
print, error, garbagecollect, ...
@ghost

Copy link
Copy Markdown

You should probably squash those into one commit; otherwise great job!

@Quintus

Copy link
Copy Markdown
Author

You should probably squash those into one commit

OK, I’m going to do so...

Vale,
Quintus

@QuintusQuintus closed this Apr 22, 2012
@korny

Copy link
Copy Markdown
Member

I just reopen this one because it contains important information about your code.

@kornykorny reopened this Jun 19, 2012
@ghostghost assigned kornyJun 25, 2012
@haileys

Copy link
Copy Markdown

👍

@Phrogz

Copy link
Copy Markdown

+1, I still want a Lua scanner. I'm going to attempt to create my own based on this work.

@korny

Copy link
Copy Markdown
Member

@Quintus:

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

:integer is only for numeric literals, not for types of variables or values. So, no.

I will close this issue because we unfortunately merged the one-commit version: #22

@kornykorny closed this Jun 22, 2013
@kornykorny mentioned this pull request Jun 22, 2013
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Quintus@korny@haileys@Phrogz