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
some parser bugs and small additions #5
Comments
|
I'll talk about your parser errors here...
The grammer rules for setting a variable and calling a function are pretty different, and lua.js chokes on the differences in this scenario somefn().somevar = 1 That workaround is the only way to do it right now, since Jison does not appear to be able to support a parser that can handle this. Suggestions are welcome.
Fixed. Thanks!
I made a mistake in the grammer rules here. It's expected
The string rules had some problems. Fixed.
Ah yes, I never added support for the string metatable that calls functions in the string library. There was a reason, but I can't remember why. I'll check it out later. As for your other changes. I added a similar change to time() to have it return Javascript time. That was a good idea. You also added some interesting bootstrap code, but I think this can be made easier by adding those properties to lua_libs and lua_core after lua.js has been loaded but before any love scripts have been run. For example... You can take a look at lualib.js to see how it does this. If you have any questions send me a message. |
|
thanks for quick fixes =) regarding love.filesystem.load : might be a misunderstanding here, the first one isn't about setting vars,
i found one more problem with unpack :
comment grammar : i think it's --[[ bla ]] as in [[ ]] is considered one block not interrupted by newlines when commented out by --. |
|
fix for string.sub : to pass some tests : |
You can do that.
You're right, but to the parser those examples are parsed in a same way. A certain class of parsers can't handle that, and I don't see a way to do it with Jison or another Javascript option.
Someone found this bug, which I fixed just today. Try updating your copy of lua.js.
They work.
Ah yes, you're right. After looking through more examples of this comment it appears that second "--" is not necessary. I'll remove it from the grammar rules.
I'll take a look at this. You can send pull/merge requests if you want. |
|
string.sub has been fixed. |
|
awesome, thanks, works like a charm =) here those are javascript global vars, and i had to rename the max var, since i use a global function named max rather than math.max, so one overwrote the other, which can be confusing to debug. |
|
JS does have namespaces, in a way. That's why it's common to put a library in a one-off function call var library = (function () {...})() so the local variables used are kept internal. I didn't intend for lua.js to be used this way, so all the useful variables are global, and unfortunately some of the less useful ones. I've renamed them to start with |
|
found another parser bug : >> print("") << workaround >> print(string.char(92)) << |
|
and another one, tricky to work around : |
This isn't valid Lua. Escape the backslash by writing EDIT: I just noticed you wrote
Sorry, this is an oversight. lua.js assumes incorrectly in function declarations like "function A.B()" that A is always a global. I'll fix it as soon as I find time. The workaround is declaring using A.B = function() instead. |
|
The function declaration bug has been fixed. Thanks again! |
|
awesome, thanks =) |
|
When I run this code in a JS console I get the output... Can you give me an isolated example? I can't figure out what the problem would be. |
|
aha! i only get the error if there is code afterwards. try this : |
|
another thing i found today : |
|
it worked =D pull request sent : #6 |
|
found a tricky problem with multiple-return-values being put in a table directly |
I hunted this down, the regex for strings was ignoring the closing quote if a backslash appears and the end of the string. Thanks!
Damn, I added support for this, but there was a regression at some point. Fixed.
I was originally planning on adding some kind of unique id to each lua table that could be used as a key, but I think your solution is better. You missed one or two things ( |
|
awesome, thanks =) |
|
found another problem with backslash in string: |
Sorry, I accidentally disabled escaping instead of making it work properly. It should be fixed now (again). I also added support for string library functions to be used directly on strings ("lowercase":upper()) which you mentioned earlier. I should probably add pattern support, I need to think about it a bit, it's actually fairly complicated. See my comments on your pull request for more info. |
|
awesome, thanks =) function MyPrint (...) print("vararg1",...) end MyPrint(1,2,3,4) prints a table rather than 1 2 3 4 : ({str:{}, uints:[1, 2, 3, 4], floats:{}, bool:{}, objs:[], arraymode:true}) |
Yikes. The vararg variable was being stored as a table, but everywhere else it is interpreted as a list of variables (which is what it's supposed to be). Needless to say this causes a lot of problems. Fixed. |
|
Hi, Congratulations for the project.. It's very useful. I would like to contribute to the project.. How can I add a lua library to the script? The ideia is to implement some missing Lua modules in JS.. |
|
try this, but please open a new issue if you have further questions rather than hijacking this thread. |
|
Well, technically each issue is supposed to be about one thing, but I don't take bug tracking too seriously, ghoulsblade. erickmelo. I'm not totally sure what you mean, so I've come up with four answers, one if which is probably the one you're looking for.
|
|
webgl game powered by luajs and love2d if you like =) http://ghoulsblade.schattenkind.net/love-webplayer/ludumdare201204/ also found a bug with nested metatables : |
Wow!
The current implementation doesn't allow nested metatables, which doesn't match the behavior in Lua 5.1. Fixed. |
|
regarding more detailed error messages (see also closed #10 ) : one idea that came to my mind for web-site/browserjs): |
|
Maybe it would be better to avoid the "eval". I'll check it out. To help with stack traces, someone suggested using source maps. It's a new technology intended to help with projectiles like lua.js, CoffeeScript, and Dart. http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/ It seemed very new, and I couldn't find good documentation, so I decided to save it for later. |
Hi all, awesome project, i use it to run games made in luascript for Love2D in a experimental webplayer :
https://github.com/ghoulsblade/love-webplayer
i found a few parser bugs, here's the current list, will track new ones in the readme on my project page.
parser bug : clouds demo : parse error in keypressed : >> love.filesystem.load("main.lua")() << workaround : >> (love.filesystem.load("main.lua"))() <<
parser bug : >> myvar = .5 << workaround >> myvar = 0.5 <<
parser bug : iyfct block comment in main.lua >> --[[ bla... ]]-- << workaround : remove comment (js regexp pre load?) or use single line comments
parser bug : iyfct " in table-save.lua >> ""..string.char(26).."" << workaround : >> '"'.."..string.char(26).."..'"' <<
parser bug : sinescroller >> local mytext = "bla" print(mytext:len()) << workaround >> print(string.len(mytext)) <<
i also added small bits to the lua-parser code that might be helpful to others :
see https://github.com/ghoulsblade/love-webplayer/blob/master/js/lua-parser.js all lines marked with ghoulsblade :
near beginning of parser :
"G = G || lua_newtable2(lua_core);\n" + // added 2012-03-16 by ghoulsblade for love-webplayer
since i use multiple lua files in the same state
"LuaBootStrap(G);\n"+ // added 2012-03-16 by ghoulsblade for love-webplayer
to register some custom functions in the api (love2d engine functionality)
if (arguments.length == 0) return [new Date().getTime()]; // added 2012-03-16 by ghoulsblade for love-webplayer
in os.time
keep up the good work =)
The text was updated successfully, but these errors were encountered: