-
Notifications
You must be signed in to change notification settings - Fork 195
Multi-line comment support#128
Conversation
Yorwba
commented
Feb 4, 2014
Also added multiline support to the parser.
leafo
commented
Feb 4, 2014
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: mascarenhas/cosmo#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
Yorwba
commented
Feb 5, 2014
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.
eloff
commented
Apr 3, 2014
What's the status on merging this @leafo?
leafo
commented
Apr 3, 2014
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.
taxilly
commented
Nov 6, 2017
Any update on this?
Sewerbird
commented
Aug 1, 2018
It would be pretty nice to have multi-line comments: what sort of % performance hit would be acceptable?
Issue #127 should disappear with this. If
DelayedLineever becomes implemented some changes will be necessary, but until then everything should work nicely.