FPtje / DarkRP

DarkRP, a non-serious roleplay gamemode for Garry's Mod.
https://darkrp.miraheze.org
MIT License
462 stars 710 forks source link

Syntax errors #1226

Closed exKAZUu closed 10 years ago

exKAZUu commented 10 years ago

I'm now developing Lua 5.2 parser and testing my parser using your project. I've noticed this project may contain many syntax errors. I can't fix all them so instead I list what problems there are. I'm not an expert in Lua so please check the official document (http://www.lua.org/manual/5.2/).

exKAZUu commented 10 years ago

I believe we can fix problems except for the last one using just replacement.

FPtje commented 10 years ago

Try to load this project in Garry's mod. You will find that it will give no syntax errors.

That's because there's a difference between Lua and GLua. Garry Added support for the exact things you mentioned. You should not try your Lua parser on a GLua project if pure Lua is what you want to parse.

You could also add support for these syntax additions. Most of them are silly, they were added because Garry couldn't get used to Lua 's syntax. Other things, like the continue keyword, are indeed very useful.

exKAZUu commented 10 years ago

I see. Sorry for my ignorance.

FPtje commented 10 years ago

You can read more about the differences here: http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexba22.html

Even though the site is out of date, the info on that particular page is still correct. You might want to be able to parse GLua scripts. That should be possible without hurting interpretation of standard Lua scripts. What are you making the parser in anyway, Haskell?

exKAZUu commented 10 years ago

Thanks! I'm using ANTLR v4 and then I also wrote GarryLua version. https://github.com/exKAZUu/Code2Xml/blob/master/Code2Xml.Languages/ANTLRv4/Processors/GarryLua/GarryLua.g4

I tried to parse this project using my GarryLua parser and I confirmed there was no syntax error :)

FPtje commented 10 years ago

That is really cool! As it happens I'm following a course on Languages and Compilers at Utrecht University. We have to parse things using Haskell (Alex and Happy libraries). I was wondering how parsing was done in imperative languages. Nice project!

exKAZUu commented 10 years ago

Thank you :) I hear these libraries first and they also seem to be interesting!