LuaPreprocess - straightforward preprocessor with simple syntax
Re: LuaPreprocess
I found this to be more intuitive than the others
Re: LuaPreprocess
I'm glad you think so.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Re: LuaPreprocess
Update 1.11.1
Changes since 1.11:
Library:
More updates have been made since the first release. I'm not sure why I didn't post anything about them here...
Changes since 1.11:
Library:
- Huge numbers are now outputted as '1/0' instead of 'math.huge'.
- Fixed newToken("pp_keyword",...) not accepting all preprocessor keywords.
- Better error message for unescaped newlines in string literals.
- Preprocess.cmd returns %ERRORLEVEL%.
More updates have been made since the first release. I'm not sure why I didn't post anything about them here...
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Re: LuaPreprocess
My gut reaction is that adding a preprocessing phase to Lua unnecessarily increases the complexity.
Personally, I find it easier to just hijack existing functions like so:
I could be wrong, but it's an interesting library and kudos for attempting this in pure Lua.
Your code looks very much like C and I believe it could be simplified using pattern matching.
Don't want to criticize this project too much, and it's a decent try. Good luck!
Personally, I find it easier to just hijack existing functions like so:
Code: Select all
if DEV_MODE then
-- inject debug features to "print"
devlog = {}
local _print = print
function print(sz)
-- append to the the debug log here
table.insert(devlog, sz)
_print(sz)
end
end
Your code looks very much like C and I believe it could be simplified using pattern matching.
Don't want to criticize this project too much, and it's a decent try. Good luck!
Re: LuaPreprocess
@ivan
I don't agree that unnecessary complexity is being added. I've used the library in multiple projects now and I've found that it makes a bunch of different tasks easier to do, and other tasks that weren't even possible before now becoming possible, without saying anything specific. (That example doesn't really demonstrate what I use preprocessing for.)
I'm not sure what you mean by the pattern matching part. The library is using pattern matching to match Lua tokens when parsing. Sure, the library could be simplified and optimized in general but I don't think it's bad as it is.
Thanks for the good luck
I don't agree that unnecessary complexity is being added. I've used the library in multiple projects now and I've found that it makes a bunch of different tasks easier to do, and other tasks that weren't even possible before now becoming possible, without saying anything specific. (That example doesn't really demonstrate what I use preprocessing for.)
I'm not sure what you mean by the pattern matching part. The library is using pattern matching to match Lua tokens when parsing. Sure, the library could be simplified and optimized in general but I don't think it's bad as it is.
Thanks for the good luck
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Re: LuaPreprocess
Precropressing is basically one language on top of another so it's definately more complicated than just using Lua. Preprocessing bugs are notoriously hard to debug in C/C++ so I would disagree with you there.
Re: LuaPreprocess
I know what you mean, but unlike C/C++ there's only one language here. There are other preprocessors for Lua that has like a separate language for the "metaprogram" but that is something I specifically wanted to avoid. It's all Lua here. Another difference to C/C++ is that actual human-readable Lua code is being generated. If there's an error then it's easy to look at the outputted code.
I just think preprocessing is a powerful tool that, like any other tool, can be misused. The things in my metaprogram aren't very complex compared to the rest of the program (especially in games which are often complex systems by nature). Here's a comparison I'd like to make with something else... In object-oriented systems, class inheritance can create a lot of complexity if it's too deep and tangled, but if the inheritance is restricted to only one level deep in most places then inheritance isn't a problem anymore. The metaprogram could create a mess, but if you try to keep things simple then there are real benefits that can be made (like overall tidier code, or speed benefits at runtime in the final program).
Note that I don't think having a preprocessing phase necessarily makes things less complicated, but if preprocessing isn't used to accomplish a certain task then the complexity has to exist elsewhere to create the same desired outcome, and there's nothing that says things will be less complex at that point either. Use the right tool for the job.
I just think preprocessing is a powerful tool that, like any other tool, can be misused. The things in my metaprogram aren't very complex compared to the rest of the program (especially in games which are often complex systems by nature). Here's a comparison I'd like to make with something else... In object-oriented systems, class inheritance can create a lot of complexity if it's too deep and tangled, but if the inheritance is restricted to only one level deep in most places then inheritance isn't a problem anymore. The metaprogram could create a mess, but if you try to keep things simple then there are real benefits that can be made (like overall tidier code, or speed benefits at runtime in the final program).
Note that I don't think having a preprocessing phase necessarily makes things less complicated, but if preprocessing isn't used to accomplish a certain task then the complexity has to exist elsewhere to create the same desired outcome, and there's nothing that says things will be less complex at that point either. Use the right tool for the job.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Re: LuaPreprocess
This sums it up pretty concisely. If you don't see a need for it, maybe you don't have one. When you need it, it's there for you.ReFreezed wrote:Use the right tool for the job.
There can be many uses for a preprocessor. One application that comes to mind is creating a demo version of a program without including the code for the full version. It might be possible to split that code into other files and invoke it conditionally, and omit these files in the demo, but that separation could be artificial and inconvenient.
Re: LuaPreprocess
Update 1.11.2
Changes since 1.11.1:
Library:
Changes since 1.11.1:
Library:
- Fixed parsing of numbers ending with a point.
- Added --backtickstrings and --nonil options (for specifying params.backtickStrings and params.canOutputNil).
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Re: LuaPreprocess
I don't understand the difference between these two:
Can you explain? I'm having trouble understanding why !! is necessary or convenient.
Code: Select all
!!local TWO_PI = 2 * math.pi
local TWO_PI = !(2 * math.pi)
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest