[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Profiling LPEG
- From: Sean Conner <sean@...>
- Date: Wed, 26 Apr 2023 15:48:21 -0400
It was thus said that the Great Roberto Ierusalimschy once stated:
> > > Quick comparison:
> > > -----------------------------------------------------------
> > > local P = lpeg.P"hello world" -- pattern in a Lua variable
> > > (P * P * P):ptree()
> > > -- tree has 66 lines
> > >
> > > local P = lpeg.V"P" -- pattern in a grammar rule
> > > lpeg.P{P * P * P, P = lpeg.P"hello world"}:ptree()
> > > -- tree has 32 lines
> > > -----------------------------------------------------------
> >
> > I see. Although, when I tried the above as-is, I got:
> >
> > lua: ll.lua:3: attempt to perform arithmetic on a nil value (global 'P')
> > stack traceback:
> > ll.lua:3: in main chunk
> > [C]: in ?
>
> Sorry. Line 3 should start with a ';', otherwise Lua is reading it
> as an argument in a call from the previous line:
Wow! I use semicolons so seldom (as in, never) that it never occured to
me to use one. Thanks.
-spc