Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua scanner #21

Closed
wants to merge 14 commits into from
Closed

Lua scanner #21

wants to merge 14 commits into from

Conversation

Quintus
Copy link

@Quintus Quintus commented Apr 22, 2012

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

ghost commented Apr 22, 2012

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

@Quintus
Copy link
Author

Quintus commented Apr 22, 2012

You should probably squash those into one commit

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

Vale,
Quintus

@Quintus Quintus closed this Apr 22, 2012
@korny
Copy link
Member

korny commented Jun 19, 2012

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

@korny korny reopened this Jun 19, 2012
@ghost ghost assigned korny Jun 25, 2012
@haileys
Copy link

haileys commented Aug 28, 2012

👍

@Phrogz
Copy link

Phrogz commented May 24, 2013

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

@korny
Copy link
Member

korny commented Jun 22, 2013

@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

Sign up for free to 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.

None yet

4 participants