lua-users home
lua-l archive

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


2017-10-14 7:38 GMT+02:00 Egor Skriptunoff <egor.skriptunoff@gmail.com>:

> The task is to simplify Sony's code:

I would have participated more enthusiastically if the OP had provided
(a) a decent description of what the code is supposed to do
(b) a nontrivial example of input and expected ouptut
(c) an indication of what word_eol[2] means

You have now provided (a) and (c), but my enthusiasm flickered
out long ago.

> local m, pos
> repeat
>   m, pos = string.match(word_eol[2], "(\\*)"..cw:sub(1,1).."()", pos or 2)
> until m == nil or #m % 2 == 0
>
> (cw:sub(1,1) being one of " or ')
>
> What this code does?
> It is probably a part of some parser (or should I say scanner?)
> A text (in variable word_eol[2]) starts with quote-delimited string literal
> (the quote is cw:sub(1,1))
> This code finds the position where the string literal terminates.
> String literal syntax implied here is allowing backslash escaping.