|
Thank you much Roberto and Tom for the replies.OK ... I see now that lack of experience with writing a parser makes it hard for me to anticipate eventual possible problems with using another combinations of characters to achieve a shorter and less obtrusive visual text representation while using proportional fonts for editing the code and "misusing" the available syntax for multiple kinds of string literals for the purpose of styling the code text in an editor with custom code highlighter.
By the way: on my journey to understanding the heritage and the "why" for design decisions I am now wondering why does Lua not went the path of allowing only single quotation mark for string literal definitions and not went the Python way of defining multi-line strings like:
' single line string with the option \ to split it over multiple lines ' ''' multiline string first level ''' ''''' multiline string second level ''''' ''''''' multiline string third level ''''''' ...With this approach (the single quotation is quite narrow and not obtrusive) the parsing should be simpler and ... it would have a nicer appearance (not so "edgy" and "stopping" as using [[ ]]) .
On 11/24/23 15:10, Roberto Ierusalimschy wrote:
instead of: `--[[[[[ third level styled text comment ]]]]]`As Tom already pointed out, that creates some ambiguities if we try to enclose text starting or ending with square bracktes.or `--['''[ third level styled text comment ]''']`Compare: a = x[''] versus a = x[''[. We need some look-ahead to distinguish them.or `--[...[ third level styled text comment ]...]`Again, compare: a = x[...] versus a = x[...[. That said, '=' is as good as any other character that cannot follow '[' in regular Lua code. (Better yet if it cannot come before ']'). Well, its symmetry is also a plus: [>>>] text [>>>] ?? [>>>[ text ]<<<] [///] text [///] ?? [///[ text ]\\\] [***[ text ]***] Sounds good -- Roberto