[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Finding end of string
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sat, 14 Oct 2017 10:08:44 +0200
2017-10-14 7:38 GMT+02:00 Egor Skriptunoff <email@example.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 means
You have now provided (a) and (c), but my enthusiasm flickered
out long ago.
> local m, pos
> m, pos = string.match(word_eol, "(\\*)"..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) 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.