eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
740 stars 66 forks source link

Or ( || ) removes syntax-highlighting #399

Closed MathiasSJacobsen closed 2 years ago

MathiasSJacobsen commented 2 years ago

When using "||" in a rule, the syntax-highlighting disappears from on every lower (<=) level rules.

Langium version: 0.2.0

Steps To Reproduce

  1. Create a new grammar.
  2. Define a rule that contains "||" name=ID .
  3. Define a rule that contains "let" name=ID.
  4. Then define an other rule that contains multiple of the first rule and second rule:
    OtherRule:  
    "component" name=ID "{"
    ruleOnes+=RuleOne*
    ruleTwos+=RuleTwo*
    "}"
  5. Then run the plugin and try to make the grammar. Now the syntax-highlighting should only appear on the first line.

Link to code example: https://pastebin.com/CKcXgezy

The current behavior

Grammar with or ( || ) Syntax-highlighting of grammar with or ( || )

Her you can see that let is not purple.

The expected behavior

Grammar without or ( || ) Syntax-highlighting of grammar without or ( || )

msujew commented 2 years ago

Hey, @MathiasSJacobsen thanks for the report.

Do you mind testing whether this is the same issue as described in here: https://github.com/langium/langium/discussions/349?

If it is fixed by adding the appropriate \ in the tmLanguage.json file, then this issue has already been fixed with #293 and will release in 0.3 (this month).

MathiasSJacobsen commented 2 years ago

Hi, @msujew.

I don't think this is the same problem, or at least I can't seem to see that it is 😅.

This is the same line as mentioned in #349 and there isn't missing any \\.

"match": "(\\;|\\{|\\}|\\||)"

I guess the problem is that the second | in the \\||.

If you want to make a language able to say:

if (…… || ……) {
    …
}
msujew commented 2 years ago

@MathiasSJacobsen thanks for sharing the generated code, because there actually is an error in there. The \\|| should actually be \\|\\|. Just \\|| is a combination of an escaped | and a regex alternative. Can you try manually adding the second \\?

MathiasSJacobsen commented 2 years ago

I'm so sorry yes that worked. Didn't work late last night. Probably forgot to regenerate. Then I can't wait for the new release!