Bachir:
On Sun, 1 Oct 2023 at 22:21, Bachir Bendrissou <babendrissou@gmail.com> wrote:
> According to the spec (as Francisco has quoted above): It's only a short comment if the double hyphen is not followed immediately by an opening long bracket. Therefore the comment in my example cannot be a short/line comment.
> On the other hand, the comment can't be a valid long comment either. Because there is no corresponding closing long bracket!
> So, there is no valid way to parse the comment. Again, this conclusion is based on the Lua specification.
Yes, it can be, because no, it is not followed by an opening long
bracket, only by what may be the start. The problem here is there are
too many things called brackets ( the '[' char is sometimes called
bracket )
'[' is not a long bracket.
So the "--[a\n" parses as "--"=comment, "[", "a" = commented chars,
"\n" end of line and comment, the long bracket is a multi-character
token.
Informally, parses sees '--' and says, ok, a comment start, lets see
if it is a long one, I'll mark my position.
... a '[', ok, it can be, let's see next char.
... an 'a', ups, not a long comment, I'll go back to the marked
position and note it is a short one.
Tokens in lua are not defined by a unique prefix, otherwise you could
not use returning, or format, as identifiers ( as they start by return
and for ).
(tokens, parser, etc.. are my choice of words, not something I've copied )
Francisco Olarte.