[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Finding end of string
- From: "Soni L." <fakedme@...>
- Date: Sat, 14 Oct 2017 08:45:51 -0300
On 2017-10-14 05:08 AM, Dirk Laurie wrote:
2017-10-14 7:38 GMT+02:00 Egor Skriptunoff <firstname.lastname@example.org>:
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.
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
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.
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.