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

support pure-lua environments? #6

Open
Jan69 opened this issue Nov 15, 2022 · 3 comments
Open

support pure-lua environments? #6

Jan69 opened this issue Nov 15, 2022 · 3 comments

Comments

@Jan69
Copy link

Jan69 commented Nov 15, 2022

lpeglabel requires compilation, and support for native modules, while there are several alternative lua implementations, such as gopher-lua, which don't support compiled native modules

although I don't know of any pure-lua lpeglabel implementations, there are a couple of lua-based lpeg implementations, though, such as LuLPeg(emulates LPeg v0.12) and LPegLJ(LPeg v1.0, but for LuaJIT 2.x, so doesn't really count)

my use-case would be with Algernon web server, which embeds gopher-lua, so I don't need to also have a separate copy of "normal lua" to use candran with

@Jan69
Copy link
Author

Jan69 commented Nov 15, 2022

and of course, on windows, and mac, compiling stuff might be a bit troublesome anyway, since LuaRocks really wants to use gcc, I had to specifically download gcc for windows, to get it to compile correctly, because the clang I had didn't support dynamic linking for god-knows-why

@Reuh
Copy link
Owner

Reuh commented Nov 15, 2022

For this use case I would probably advise to setup Candran properly on your development computer, and compile your Candran files to regular Lua files when you want to run them in an environment without Candran, just like you would compile your program before running it for any compiled language. At least that's what I've been doing for my projects when I want to ship them without any native module for portability reasons. With a Makefile or some script that re-compile every candran file in my project directory for convenience.

But of course, if the pure-Lua implementations of lpeg work, I don't see a reason not use them as a fall-back to make setup easier. It's a bit of a shame that they don't support lpeglabel though, that will make syntax error messages a lot more cryptic, but oh well.

It will probably require a fair amount of work to adapt the current code to that though, and I won't have much free time right now I'm afraid (if you have the courage and the time for a PR, all the lpeg stuff is in parser.lua :) otherwise I'll probably get to it in a couple weeks).

@Jan69
Copy link
Author

Jan69 commented Nov 15, 2022

ok, alhough using effectively lpeg 0.12 would be a big downgrade, I'm happy you're at least considering eventually dealing with it, I'm not really that good with lua yet, myself...also, as the file comments,

This module implements a parser for Lua 5.3 with LPeg,and generates an Abstract Syntax Tree that is similar to the one generated by Metalua.

so why not use Metalua itself as fallback? (or the koneki project's archive)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants