[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why isn't Lua more widely used?
- From: Jay Carlson <nop@...>
- Date: Mon, 30 Jan 2012 07:18:17 +0000
On Mon, Jan 30, 2012 at 6:50 AM, Jay Carlson <nop@nop.com> wrote:
> csv = t.grammar{
> record={t.group{
> t.exp[[field]]
> t.star{",", t.exp[[field]]}
> }, t.choice{t.nl, t.eof}
> },
> field=t.choice{t.exp[[escaped]], t.exp[[nonescaped]]},
> nonescaped={t.range'^,"%nl'.star().capture()},
> escaped={'"',
> t.choice{ t.range'^"', t.cap('""').as('"') }.star().capture()
> '"'}
> }
Table constructors are distinctly lacking sugar. This is the second
time I've wanted letrec. Let's imagine:
csv = t.grammar{
-- imagine: local field, nonescaped, escaped
record={t.group{
field,
t.star{",", field}
}, t.choice{t.nl, t.eof}
},
field=t.choice{escaped, nonescaped},
nonescaped={t.range'^,"%nl'.star().capture()},
escaped={'"',
t.choice{ t.range'^"', t.cap('""').as('"') }.star().capture()
'"'}
-- and all the interior references get fixed up
}
...not that I'm volunteering to code any of this mess...