This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

How to circumvent Lua limitation for 200 local variables when machine-generating a dissector from XML description of protocol

0

I've used Matlab (this is the easiest language for me) to generate a Lua dissector from an XML file describing a protocol.

The issue right now, is that it is generating too many local (global) variables and I'm getting the

`too many local variables (limit is 200) in main function near '='`

error.

Many of the variables (~150) are due to some enumeration.

Any suggestion how to solve it?

asked 10 Aug '17, 01:27

BMWE's gravatar image

BMWE
467811
accept rate: 100%

edited 10 Aug '17, 01:39

sindy's gravatar image

sindy
6.0k4851

@BMWE, I've converted your post to a new Question as this way it better fits this site's purpose.

(10 Aug '17, 01:39) sindy

To the subject, what means "some enumeration"? If your protocol has 150 distinct fields, there is no surprise that 150 variables get created. If that is not the case, please provide some more details.

(10 Aug '17, 01:40) sindy

One Answer:

0

I realize this is an old question on a now-obsolete Q&A site, but in case anyone finds themselves in this situation, one solution is to group variables together into a Lua table.

For example, instead of:

local variableA = 1
local variableB = 2
...
local variableZ = 26

use something like:

local variables = {
    A = 1,
    B = 2,
    ...,
    Z = 26
}

answered 31 Jul '18, 09:15

cmaynard's gravatar image

cmaynard ♦♦
9.4k1038142
accept rate: 20%