atom-language-rust icon indicating copy to clipboard operation
atom-language-rust copied to clipboard

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

Open Wulfsta opened this issue 8 years ago • 3 comments

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

Wulfsta avatar Jul 26 '17 19:07 Wulfsta

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 avatar Aug 07 '17 19:08 zargony

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.

mikeyhew avatar Jun 20 '18 20:06 mikeyhew

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

Wulfsta avatar Jun 21 '18 23:06 Wulfsta