moonscript icon indicating copy to clipboard operation
moonscript copied to clipboard

Multi-line comment support

Open Yorwba opened this issue 11 years ago • 7 comments

Issue #127 should disappear with this. If DelayedLine ever becomes implemented some changes will be necessary, but until then everything should work nicely.

Yorwba avatar Feb 01 '14 21:02 Yorwba

Also added multiline support to the parser.

Yorwba avatar Feb 04 '14 15:02 Yorwba

I get this error when trying to run moonc after your patch. Here's a similar issue with that popped up with lpeg 0.12: https://github.com/mascarenhas/cosmo/issues/5

bin/moonc moon/ moonscript/
lua: ./moonscript/parse.lua:395: bad argument #2 to '__div' (invalid replacement value)
stack traceback:
    [C]: in function '__div'
    ./moonscript/parse.lua:395: in function 'build_grammar'
    ./moonscript/parse.lua:658: in function 'string'
    bin/moonc:121: in function 'compile_file'
    bin/moonc:169: in function 'compile_and_write'
    bin/moonc:402: in main chunk
    [C]: in ?
Makefile:12: recipe for target 'compile' failed
make: *** [compile] Error 1

leafo avatar Feb 04 '14 21:02 leafo

The error message refers to this line:

Comment = P"--" * (V"NoSpaceLuaString" / 0 * Space^-1 + (1 - S"\r\n")^0 * #Stop),

And mentions a "bad argument 2 to _div" which I guess refers to the 0 which I placed there so that all captures made by the LuaString rule would be dropped (otherwise the compiler thinks it found a "string" line decorator if the comment was at the end a line). This behavior is documented on the official lpeg page and works fine for me using a fresh lpeg v0.12 from LuaRocks. I do not know why it does not work for you, but since Cmt() also drops the captures made by the enclosed pattern, I modified the grammar to use that function instead.

Yorwba avatar Feb 05 '14 17:02 Yorwba

What's the status on merging this @leafo?

eloff avatar Apr 03 '14 18:04 eloff

The line number fix was manually merged in. The multiline comment was not. I've been lingering on adding it because it makes parsing about 20% slower if I remember correctly. I wanted to take some time to see if is a more efficient implementation.

leafo avatar Apr 03 '14 18:04 leafo

Any update on this?

taxilly avatar Nov 06 '17 21:11 taxilly

It would be pretty nice to have multi-line comments: what sort of % performance hit would be acceptable?

Sewerbird avatar Aug 01 '18 08:08 Sewerbird