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 Soni They/Them L. once stated:
> I'm rolling with this weird idea. is it possible to make a simple parser 
> out of tables? 

  Yes.  There's an entire book dedicated to this topic---_Compilers:
Principles, Techniques, and Tools_, [1] also known as The Dragon Book
(because of the cover).  It doesn't use Lua tables per se, but the lexing
portion is driven completely by a 2D array that represents a state machine.

  The other book I'm familiar with is _Compiler Design in C_ [2].  It too,
uses a table to drive the lexing.

> I tried some stuff but ran into a few issues. I don't 
> wanna use LPeg or anything more complicated than string.find(foo, bar, 
> 1, true).

  You might be better off learning LPEG.

  -spc (But that's just my opinion)

[1]	https://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools

[2]	https://holub.com/compiler/