|
On 2017-10-14 05:08 AM, Dirk Laurie wrote:
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.
The Lua test suite is a good place to find nontrivial examples of input and expected output, at least once the string goes through the rest of the parser, which turns the string literal into a string.
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.
-- Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.