lua-users home
lua-l archive

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


> While a tree that fails compilation looks like:
> 
> [1 = P  2 = P  3 = Line  ]
> grammar 3
>   rule n: 0  key: 3 -- Line = lpeg.P"x" * lpeg.C(lpeg.V"P"),
>     seq
>       char 'x'
>       capture cap: 5  key: 0  n: 0
>         call key: 1
>   rule n: 1  key: 2 -- P = lpeg.P"a"
>     char 'a'
>   rule n: 2  key: 0 -- Q = lpeg.V"P"
>     call key: 2
> Segmentation fault
> 
> I think the rule ordering is different because of string (key) hash
> randomization.
> 
> If I understand things correctly (and I may not), it seems that the
> "Q" rule references itself instead of "P" (call key: 2 instead of call
> key: 1 in the failing tree above). This  leads to infinite
> recursion/stack exhaustion during compilation.

This is correct. The 'key' there is the index in the ktable (shown
in the beginning of the tree) of the key of the rule being called.
In that table, "2 = P", which means that the rule is calling "P"
(which is correct).

-- Roberto