lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

It was thus said that the Great Dibyendu Majumdar once stated:
> On Fri, 21 Feb 2020 at 21:55, Dibyendu Majumdar <> wrote:
> > I am pleased to announce a new project to create a Lua/Ravi parser and
> > code generator that is not a replacement for the default one in
> > Lua/Ravi but can be used for more specialised code generation, as well
> > as as a means of understanding how the parser and code generator
> > works. My hope is that it will enable the study of Lua implementation
> > in educational institutions, as I intend to use classical methods of
> > compilation. Moreover, ease of maintenance is a bigger priority than
> > sheer memory or performance efficiency.
> >
> Hi,
> So I am looking for ideas / suggestions for what the api for this
> library look like.
> I need a C api to start with. I have been looking at other libraries
> to see what they do, but none stands out as ideal. 

  Without knowing what you looked at, there's LLVM for the code generation
part, and clang for more of the lexing and parsing.

  I have worked with TCC (Tiny C Compiler) which can be embedded into a
larger context as you can call it as a library.  It does all the steps,
lexer, parser, code generation (but very little optimization). The official
repo is at <>.  

  I have wrapped TCC up as a Lua module.  I'm not sure how well it works
with the latest TCC (I stopped updating my TCC several years ago---the
development model of TCC is a bit of a mess really).  But if you just want
to check it out:

	The low level module:

	The slightly higher module that allows one to load Lua modules
	directly from C code:

  I'm not sure if this will help you in any way, but who knows?  It might.

> Perhaps Go is the
> only language that has a built-in module that gives you lexer, parser
> etc.
> Suggestions welcome. If you know of a great example then I would
> appreciate if you can give me a reference to the project.

  Hmm ... have you heard of nanopass compilers?