usethesource / rascal-syntax-highlighting

TM Bundle for syntax highlighting Rascal code
BSD 2-Clause "Simplified" License
2 stars 3 forks source link

Fixed regex literals and tags, Added concrete syntax highlighting #3

Closed ahmadsalim closed 7 years ago

ahmadsalim commented 7 years ago

You can see the effects of concrete syntax highlighting here: Concrete syntax highlighting

PaulKlint commented 7 years ago

Looks very good. I tried varies snippets and works well, thanks.

Below is an example that surprises me: (string literals like "template_open" are not highlighted in red, while they are in other contexts). Any clue?

private MuExp translateStringLiteral(s: (StringLiteral) `<PreStringChars pre> <Expression expression> <StringTail tail>`) {
    preIndent = computeIndent(pre);
    return muBlock( [ muCallPrim3("template_open", translatePreChars(pre), pre@\loc),
                      *translateExpInStringLiteral(preIndent, expression),
                      *translateTail(preIndent, tail),
                      muCallPrim3("template_close", [], tail@\loc)
                    ]   );
}
ahmadsalim commented 7 years ago

@PaulKlint Thanks. Hmm, I might have been to general in scope for the lexical [] so it also apparently included list literals. I will try and see how to fix this.

PaulKlint commented 7 years ago

Here is another one: int n versus list[int] n. In the former int is green in the latter it is not. Is there a reason for this?

ahmadsalim commented 7 years ago

Yeah, so the major issue is that [] seems to have a different meaning when it's inside lexical or syntax than when it's outside. I have to figure out a nice way to capture this property.

This is because e.g. [/bla/] is a list containing a regex in a normal context, whereas it is something which expects any of the characters / b l or a in a lexical context). The current way is that it treats all [] uniformly as lexical contexts (if it doesn't it will ruin the highlighting elsewhere in the grammar files).

ahmadsalim commented 7 years ago

It's my first time writing a TextMate grammar, so it's taking me some time to figure out how to do these things correctly.

PaulKlint commented 7 years ago

This has been on our list for a long time since we are no experts on this either. I can imagine that some more regexp fiddling is needed here and that it is not so simple to figure out what these cooperation regents do precisely.

Since I find your highlighter so good (on par or even better than our Eclipse one a I would say) I am doing more experiments and will report surprises here (take this as a compliment, its intended to make this really good!).

Here is another one where a comment is missed:

// comment 1

n = 1;  // comment 3
l = [1, // comment 3: non highlighted
     2, 
     3];
ahmadsalim commented 7 years ago

Great, thank you for the examples and the comments! I will take a look at fixing this tomorrow, I think I have an idea how to proceed.