Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Macro call syntax may interfere with grammar and can break syntax highlighting for remainder of document #115

Open
Wulfsta opened this issue Jul 26, 2017 · 3 comments
Labels

Comments

@Wulfsta
Copy link

Wulfsta commented Jul 26, 2017

This can be see here. It looks like "{}\n{}\n{}" is causing the issue.

@zargony
Copy link
Owner

zargony commented Aug 7, 2017

Seems to be caused be two lines earlier, inside the macro call, where it falsely detects a function statement fn but no function begin { and therefore takes the rest of the file as a big function definition. And that's where it gets hard. The syntax of a macro call is defined by the macro definition - grammar rules can't tokenize that dynamically. One option would be to remove any tokenization inside macro calls, but that might look even worse.

I don't know any good solution to this problem atm. Anybody else?

@zargony zargony added the bug label Aug 7, 2017
@zargony zargony changed the title String breaks syntax highlighting for remainder of document Macro call syntax may interfer with grammar and can break syntax highlighting for remainder of document Aug 7, 2017
@Wulfsta Wulfsta changed the title Macro call syntax may interfer with grammar and can break syntax highlighting for remainder of document Macro call syntax may interfere with grammar and can break syntax highlighting for remainder of document Aug 7, 2017
@mikeyhew
Copy link

Just thought I'd chime in and let you know I ran into this in vscode, which uses this grammar. Gluon has a record! macro where you write type Type => some_type, and it causes the same problem. Here is an example https://github.com/gluon-lang/gluon/blob/master/repl/src/repl.rs#L469

BTW does GitHub also use this grammar for syntax highlighting? Seems to have the same issues.

@Wulfsta
Copy link
Author

Wulfsta commented Jun 21, 2018

Yes, seeing my code highlight incorrectly on GitHub is how I noticed this.

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

No branches or pull requests

3 participants