[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: New long comments in 5.1
- From: Philippe Lhoste <PhiLho@...>
- Date: Sun, 20 Jun 2004 11:25:38 +0200
Asko Kauppi wrote:
How about:
The TERMINATOR may never contains ']]'.
I believe it goes implicitely with my rule.
Let's try and make a formal specification of these new rules, while
being nice with legacy code and try to cope with most pitfalls...
I write this for literal strings, but it should apply to block/multiline
comments as well.
A literal string starts with [[ anywhere in a line.
Lexer checks up to the end of the line. If a ]] is meet, it ends the
string. {I believe we don't need nested strings for one-liners.}
If the [[ is immediately followed by a newline character, the newline is
omitted from the string and the string ends when meeting a newline
(which is omitted too) immediately followed by a ]]. Nesting does apply
here.
If the [[ is immedialtely followed by [a-zA-Z_]+ followed by a newline,
the newline (and the string) is omitted from the string and the string
ends when meeting a newline (which is omitted too) immediately followed
by the string above (ditto) and ]]. Nesting works here too. {The
terminator rule can be relaxed for a number of characters, of course.
Probably not for space, and of course not for [ and ]...}
If a non-allowed character is meet before the end of line, old rule
apply, ie. the string ends whenever a ]] is meet, with the usual nesting
rule.
Of course, nesting use the above rules, ie. a given start is ended only
by a matching end.
Perhaps it is a bit too much convoluted, with "complex" rules to
memorize, but at least it should satisfy most people, coping with most
cases.
Unless I overlooked some exception breaking all this rule set...
--
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
http://Phi.Lho.free.fr
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--