Menu

#2205 Lua language stylization of block comments is wrong

Bug
closed-fixed
nobody
5
2021-06-02
2020-09-24
No

Report from: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8087

This peace of code has wrong comment style for block comment:

print("First")
--[[ Block comment start
print("Second")
--[[ Another block comment ]]
print("Third. If run through an actual program, this will be executed.")

I check this in various online Lua interpreter and all have correct highlighting (see attachments).

Refs:
https://www.lua.org/pil/1.3.html
https://en.wikibooks.org/wiki/Lua_Programming/comment

1 Attachments

Discussion

  • Neil Hodgson

    Neil Hodgson - 2020-09-24
    • labels: --> lexer, lua
    • status: open --> open-accepted
     
  • Kein-Hong Man

    Kein-Hong Man - 2020-09-27

    My bad, heh. I have non-coding stuff that is taking all my free time, so I am quite behind on the curve these days. Here is the explanation for the issue: The incorrect highlighting is due to my attempt at supporting multiple Lua versions. Specifically, nested -[[ ]] long comments. Since that is long ago in the past, I guess nested [[ ]] should be removed. Will users care enough that it should be made an option? Perhaps not.

    If I am working on a patch, I'll ping here.

     
  • Zufu Liu

    Zufu Liu - 2020-09-27

    Patch to remove nested comment.

     

    Last edit: Zufu Liu 2020-09-27
    • Kein-Hong Man

      Kein-Hong Man - 2020-09-28

      Thanks for taking a look. [[ ]] nesting (and folding) for both SCE_LUA_LITERALSTRING and SCE_LUA_COMMENT can be removed or disabled. The syntax was only present in Lua 5.0, I believe. From Lua 5.1 onwards, [==[ ]==] can be used so nesting was more like a failed experiment.

      I did not ever recall reading of anyone complaining that their nested [[ ]] failed when folks moved from Lua 5.0 to Lua 5.1, so the probability of anyone still relying on nested [[ ]] today is pretty miniscule.

      I think disabling the nesting code is a good idea, and I am totally in support of it.

       
  • Zufu Liu

    Zufu Liu - 2020-09-28

    https://www.lua.org/manual/5.0/manual.html#2.1

    Literals in this bracketed form may run for several lines, may contain nested [[ · · · ]] pairs, and do not interpret any escape sequences.

    Long comments may run for several lines and may contain nested [[ · · · ]] pairs.

    5.1 and later
    http://www.lua.org/manual/5.1/manual.html#2.1

    A long string starts with an opening long bracket of any level and ends at the first closing long bracket of the same level. Literals in this bracketed form can run for several lines, do not interpret any escape sequences, and ignore long brackets of any other level. They can contain anything except a closing bracket of the proper level.

    Otherwise, it is a long comment, which runs until the corresponding closing long bracket.

    I also agreed on removing supporting for Lua 5.0 nested brackets.

     
  • Zufu Liu

    Zufu Liu - 2020-10-01

    Patch to remove nested long string and block comment.

     
    • Kein-Hong Man

      Kein-Hong Man - 2020-10-02

      I have updated my files to hg HEAD and tested it, works fine, thanks!

       
      • Neil Hodgson

        Neil Hodgson - 2020-10-02

        OK. It is unlikely this will be committed until after Scintilla 5.0.

         
  • Neil Hodgson

    Neil Hodgson - 2021-04-29
    • labels: lexer, lua --> lexer, lua, lexilla
    • status: open-accepted --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2021-06-02
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB