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 comments cannot be nested #525

Open
jiribenes opened this issue Jul 26, 2024 · 3 comments
Open

Multi-line comments cannot be nested #525

jiribenes opened this issue Jul 26, 2024 · 3 comments

Comments

@jiribenes
Copy link
Contributor

jiribenes commented Jul 26, 2024

/*
  /*
  nested
  */
  comment
*/

returns:

[error] nested.effekt:5:3: Unexpected end of input
  comment
  ^^^^^^^

which implies that multi-line comments cannot be nested.

@dvdvgt
Copy link
Collaborator

dvdvgt commented Aug 31, 2024

Is there a practical use-case for nested comments to justify the implied lexer complexity by supporting it? Otherwise, I would just not support it and add a lexer error upon encountering a /* while already lexing a multiline comment.

@jiribenes
Copy link
Contributor Author

jiribenes commented Aug 31, 2024

TL;DR: No, not really.

The only use case I have is when my code looks like this:

def foo() = 42
def bar() = 100
/*
def baz() = 400
*/
def quux() = 1000

(with way larger, multiline functions) and I want to comment out the rest of the file except for foo, I do:

def foo() = 42
/* 
def bar() = 100
/*
def baz() = 400
*/
def quux() = 1000
*/

which then doesn't work.

@jiribenes
Copy link
Contributor Author

But a few months ago, we were discussing that we might remove multiline comments anyways and instead add better support for singleline ones (see effekt-lang/effekt-vscode#19).

In fact, I was thinking about simplifying the language to remove all multiline tokens (we can hack around multiline strings, Zig-style), since that would make the lexer simpler and it would be super simple to do incremental compilation (since only the changed lines need to be re-lexed, re-parsed, ...).

@jiribenes jiribenes changed the title Nested comments are not lexed correctly Multi-line comments cannot be nested Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants