lua-users home
lua-l archive

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


Hi,

In LPEG , you can pass a variable to your parser using Carg.

BUT if you build your grammar dynamically for EACH string / file you could pre-create state for each of your Cmt functions.

- One design is stateless ( which has some dubious clarity )

- One design creates a separate grammar for each string , which is likely slower ?

Question 1 :: is option 2 a anti-pattern ? do we stick to option 1 ?

Another issue I feel you have with using Carg is that all your rules have Carg  all over the place.

local patt1 = P(Carg(1)* .................)

local patt2 = P(Carg(1)* .................)

I understand that its possible to pass multiple arguments with multiple states :

local patt1 = P(Carg(1)* .................)

local patt2 = P(Carg(2)* .................)

local patt2 = P(Carg(3)* .................)

But it doesn't make things any clearer, and now you need to remember which number corresponds to which variable.

My question is that of confidence and design - how large does your parser have to get before this method of arranging stops making sense ?

best wishes,

Joy