-
Notifications
You must be signed in to change notification settings - Fork 2k
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 comments and indentation level #1350
Comments
+1 |
See #934 for Jeremy's opinion on this. |
It's not so much an opinion as an impossibility. Either we have to parse comments and pass them through to JS, or we lex them out ... Because block comments are currently passed through, they have to be syntactically valid, which means that they have to respect significant whitespace. If you want to comment out a chunk of code, use regular (non-block) comments, and everything should be fine. |
Understandable, and this explains to me why single-line comments are stripped out of Coffee (I always wondered about that, since the Coffee compiler's aim isn't to minify) -- I'm guessing that's simply to allow single-line comments to appear anywhere, without having to respect significant whitespace? To clarify though, it's certainly theoretically possible to ignore expected whitespace when you encounter a multiline comment, no? I'm guessing it'd just take a lot of plumbing through the lexer? |
Yes, you have that all right. It's only theoretically possible to ignore whitespace when parsing a multiline comment -- if we entirely change our current strategy for parsing/passing-through comments, and remove them from the parsing equation. Proposals have been made to lex them out of the token stream (as single-line comments currently are), and tag them on their nearest neighboring node, so that they don't have to encounter the parser at all. Then, in the AST side, they'd be moved to the nearest newline, or something -- it's complicated, and no one has taken a serious stab at making it work. |
Thanks for explaining, Jeremy! |
The first example, for i in foo
print 'hello'
###
hello?
###
print 'world' compiles now, as of #4572. Sorry it took awhile. |
Easier to show code than to try and describe the problem: ;)
https://gist.github.com/965677
It would be great if that first example worked, i.e. matching indentation level wasn't a requirement for multi-line comments. Makes e.g. commenting out chunks of code easier.
What do you think? Thanks in advance!
The text was updated successfully, but these errors were encountered: