8000 Add support for punctuation in generated textmate grammars [#3337] by iTob191 · Pull Request #3377 · eclipse-xtext/xtext · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support for punctuation in generated textmate grammars [#3337] #3377

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iTob191
Copy link
@iTob191 iTob191 commented Mar 2, 2025

I've implemented the change as outlined in #3337 (comment).

@iTob191 iTob191 force-pushed the feature/textmate_punctuation branch from 7bb90e3 to 2a6cd93 Compare March 2, 2025 19:06
@cdietrich cdietrich requested review from szarnekow and tivervac March 3, 2025 08:50
matchBuilder.append("(?i)");
}
matchBuilder.append("(");
List<String> allKeywords = GrammarUtil.getAllKeywords(grammar)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems as if we could use the same implementation for bother regex rules. The only meaningful difference seems to be the s.matches("\\w+") vs its negation and the name of the match rule.
Regular keywords should still work if we funnel them through escapeAndAddWordBoundaries

Would that work?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works and I've updated the PR accordingly. Only downside is that the generated regex for the keyword.control rule is less optimized: (\\ba\\b|\\bb\\b|\\bc\\b) instead of \\b(a|b|c)\\b

@iTob191 iTob191 force-pushed the feature/textmate_punctuation branch from 2a6cd93 to a546293 Compare March 7, 2025 12:26
@iTob191 iTob191 force-pushed the feature/textmate_punctuation branch from a546293 to f579467 Compare March 11, 2025 13:40
@iTob191
Copy link
Author
iTob191 commented Mar 11, 2025

After extending my grammar with Xbase support which brings in a lot more punctuation characters, I've noticed that this PR breaks highlighting of comments. The problem is that Xbase introduces / as a keyword which is then picked up by the punctuation rule and prevents other rules further down (like the comment rules) from being chosen. To resolve this, I have pushed an updated version in which the punctuation rule is moved to the bottom.

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

Successfully merging this pull request may close these issues.

2 participants
0