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 pocomane once stated:
> On Wed, Jan 16, 2019 at 11:24 AM Dirk Laurie <dirk.laurie@gmail.com> wrote:
> > Have you studied how lua.c solves precisely this problem?
> 
> Can you be more specific? It does not seem to me that lua uses pattern
> matching (nor on multiple chunks). If you are talking about the lua
> lexer... well, I do not want to implement a proper lexer. Here I was
> just searching for a way to detect if a failing pattern have some
> chance to match when data is appended to the input
> 
> On Wed, Jan 16, 2019 at 8:02 PM Sean Conner <sean@conman.org> wrote:
> >   I've used Lua itself as the configuration language (for personal and work
> > related projects).  It's pretty easy to do:
> 
> Me to... but now I need something more "Ini" like...

  Well, if it's ini-like, I have a parser for that:

https://github.com/spc476/LPeg-Parsers/blob/master/ini.lua

  But it requires the data to be in memory.

> On Wed, Jan 16, 2019 at 9:16 PM Sean Conner <sean@conman.org> wrote:
> >   This is currently more interesting than anything going on at work, so let
> > me ask:  why can't you have the entire config file in memory?  Or at least a
> > line at a time?  This seems like a weird, if arbitrary, limitation.
> 
> Yes, I agree with you that it is quite arbitrary for the described
> scenario. However, I am investigating on the possibility to use the
> same format for data insertion/transfer/storage. So keep all in memory
> could not be feasible. Splitting the chunks on specific token (e,g,
> new line) could work, but I have some patterns that spawn across
> multiple lines, so at least that ones must be handled in a special
> way.

  I also have a JSON parser that can handle streaming:

https://github.com/spc476/LPeg-Parsers/blob/master/jsons.lua

	json = require "org.conman.parsers.jsons

	blob = json:match(input)

If input is a string, it decodes it.  If input is a function, it will
continue to call it until input returns nil (to indicate no more input).  I
can understand not wanting to use JSON, but it might be good to look at how
I handle it.

  -spc