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

Invalid regular expressions in grammar #1

Closed
lildude opened this issue Jun 19, 2023 · 5 comments
Closed

Invalid regular expressions in grammar #1

lildude opened this issue Jun 19, 2023 · 5 comments

Comments

@lildude
Copy link

lildude commented Jun 19, 2023

👋 from github-linguist/linguist.

I'm in the process of creating the next release and I've seen our grammar compiler has detected the grammar has two invalid regular expressions which may impact the highlighting of some Nushell files:

  • repository vendor/grammars/nu-grammar (from https://github.com/hustcer/nu-grammar.git) (2 errors)
    • Invalid regex in grammar: source.nushell (in grammars/tmLanguage.json) contains a malformed regex (regex "(?<!\w)(?:(\^)|(?![0-9]|(?<=\)|\...": lookbehind assertion is not fixed length (at offset 42))
    • Invalid regex in grammar: source.nushell (in grammars/tmLanguage.json) contains a malformed regex (regex "(?<=\)|\}|\]|\$\w+)(?:\.(?:[\w-]...": lookbehind assertion is not fixed length (at offset 18))

I suspect these were reported in the output when you added the grammar to Linguistin your original PR but likely missed it.

I won't hold back the release for this to be fixed, but I will be adding this to the list of known grammar issues: github-linguist/linguist#3924. Any fixes you make to this grammar will be pulled in when the next release is made.

@hustcer
Copy link
Owner

hustcer commented Jun 19, 2023

OK,thanks, but how to detect invalid regular expressions for nu-grammar? So I can make sure that it's fixed

@lildude
Copy link
Author

lildude commented Jun 19, 2023

We use the compiler here which uses a PCRE library to validate all the regular expressions.

You can do something similar on from the CLI using pcretest or online using something like https://regex101.com/

@glcraft
Copy link

glcraft commented Jun 20, 2023

The regex works in ECMAScript (Javascript) but doesn't work for PCRE and others. That's why it works in vscode but can't work somewhere else.
I'll try to work around this issue to make something which morks for PCRE.

@hustcer
Copy link
Owner

hustcer commented Jun 25, 2023

@glcraft Thanks, the grammar file for linguist has been updated just now

@hustcer
Copy link
Owner

hustcer commented Jul 25, 2023

Should be closed by nushell/vscode-nushell-lang#137

@hustcer hustcer closed this as completed Jul 25, 2023
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

No branches or pull requests

3 participants