lua-users home
lua-l archive

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

> In particular we want to find the string concatenations in loops:
> local foo = ...
> for ... do
>   ...
>   foo = something .. foo .. something .. else
>   ...
> end

Wouldn't be easier to find string concatenations used with accumulators?
I guess the following pattern (for plain Lua pattern matching),
applied at each line of the program, would be a good filter:

  p = "^%s*([a-zA-Z_][a-zA-Z0-9_]*)%s*=.*%1%s*%.%."

You may also need this other one:

  p = "^%s*([a-zA-Z_][a-zA-Z0-9_]*)%s*=.*%.%.%s*%1"

(You may need to change it something if you want to detect accumulation
over a table field, like a.x = a.x .. something...)

-- Roberto