Skip to content
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

Enable regular expression flags for terminal rules #127

Closed
spoenemann opened this issue Jun 24, 2021 · 9 comments · Fixed by #1070
Closed

Enable regular expression flags for terminal rules #127

spoenemann opened this issue Jun 24, 2021 · 9 comments · Fixed by #1070
Labels
grammar Grammar language related issue
Milestone

Comments

@spoenemann
Copy link
Contributor

See #126 (comment). JavaScript supports flags to control the behavior of regular expressions. Shall we enable in the grammar language?

@spoenemann spoenemann added the grammar Grammar language related issue label Jun 24, 2021
@spoenemann spoenemann added this to the v0.3.0 milestone Sep 24, 2021
@dhuebner
Copy link
Contributor

dhuebner commented Jan 7, 2022

I don't know how useful are other flags, but those seen to be useful:

s Allows . to match newline characters.
i Case-insensitive search.

Will mean to change the RegexLiteral to:
\/(?![*+?])(?:[^\r\n\[/\\]|\\.|\[(?:[^\r\n\]\\]|\\.)*\])+\/[a-z]?

[a-z]? is if regex will become more options in the future.

dhuebner added a commit that referenced this issue Jan 7, 2022
@spoenemann
Copy link
Contributor Author

This idea does not work well with the changes made in #288. Let's postpone it for now.

@spoenemann spoenemann removed this from the v0.3.0 milestone Jan 10, 2022
@msujew
Copy link
Member

msujew commented Jan 10, 2022

Regarding case sensitivity, there's also a group flag which allows to make search case insensitive. I would argue, that users which are interested in this feature should use the group flag instead of the global regex flag.

@dhuebner
Copy link
Contributor

What about a new keyword for multiline matching?

@msujew
Copy link
Member

msujew commented Jan 10, 2022

@dhuebner Multiline matching is always enabled, no flag necessary :) See the multiline-comment terminal rules.

@dhuebner
Copy link
Contributor

@msujew
I meant the s flag for: Allows . to match newline characters.

@dhuebner
Copy link
Contributor

Keyword is not a good idea, because this flag regex specific

@Josh-Cena
Copy link

Hi, just want to mention that the u flag is quite useful. For example, all JS identifiers use the syntax /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u, but at the moment there's no easy way to specify Unicode character classes.

@msujew
Copy link
Member

msujew commented May 22, 2023

For now, the unicode flag isn't supported in Chevrotain. It is part of a larger lexer issue, see Chevrotain/chevrotain#1670.

Note that custom pattern functions can still be used to achieve the same effect, so it's still possible to achieve this functionality in Langium.

@msujew msujew added this to the v2.0.0 milestone Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
grammar Grammar language related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants