lua-users home
lua-l archive

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


The code you gave works great for my example, but what if I want to
access the value of the capture in the function at match time? What I
am trying to do it change the parsing path taken based on validation
done in the match time function.

Thanks, Leaf


On Wed, Jun 15, 2011 at 11:16 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> I have a relatively simple contrived grammar (below) which works great
>> with small files.
>> When I try to feed it a large file though I get an error:
>>
>>     stack overflow (too many runtime captures)
>
>
> You may try something like this: (Warning: untested code!!)
>
> -     Name = Cmt(Name, function(str, pos, name)
> -       count = count + 1
> -       return true, name
> -     end)
>
> +     Name = C(Cmt(Name, function(str, pos)
> +       count = count + 1
> +       return true
> +     end))
>
> That is, get the name as a regular capture, instead of a runtime one.
>
> -- Roberto
>
>