Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-line comment support #128

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Multi-line comment support #128

wants to merge 3 commits into from

Conversation

Yorwba
Copy link
Contributor

@Yorwba Yorwba commented Feb 1, 2014

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

@Yorwba
Copy link
Contributor Author

Yorwba commented Feb 4, 2014

Also added multiline support to the parser.

@leafo
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Contributor

eloff commented Apr 3, 2014

What's the status on merging this @leafo?

@leafo
Copy link
Owner

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.

@leafo leafo changed the title Fixed lua/moon line mapping Multi-line comment support Sep 27, 2015
@taxilly
Copy link

taxilly commented Nov 6, 2017

Any update on this?

@Sewerbird
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants