-
-
Notifications
You must be signed in to change notification settings - Fork 11
JavaScript highlighting bug in regexp with quotes #2145
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
Comments
|
I don't think it is duplicate.
It is different syntax highlighting file and language.
As i understand problem is that / can be both division operator and beginig of the regexp. Simples difference is that before / in regexp we need to have: { or ( or [ or , or ; or = or other oprator (+ - / & && || | ^ ~). But befor division operator we need to have ) or digit or letter or dot. (We inore of course whitespaces in the match)
.+ becuase 'var a = //;' is illegal as this is empty regexp (would always match), and actually it is a commened ';' string |
Regexp should be
With negative lookbehind and ignore space, to distinguish from the division operator followed by comment:
After further refinmentens (like allowing / in after [ (character class), and then disallowing after [ if it was escaped \[.
this will match to
but not to
PS. Some regexp engine have limited lookbehind capabilities, but this shouldn't be probleme here, as we are only matching only single char before possible regexp (ignoring whitespaces).
But perl gives me correctly some comments (which should are processed on its own, so will not be matched in real life:
output
looks very well. "..." have some false positives, but it is ONLY becuase there was comments there of the form:
|
Changing not needed groups to be noncapturing (?: ...):
brings slight more efficient matching and gives exactly same matche.
Is it possible to use this somehow in the syntax files? Or something more simple and not based on the regexp need to be used? |
|
Important
This issue was migrated from Trac:
baryluk
(witold.baryluk@….com)Consider this simple example file.js:
This is correct javascript code which search for occurrence of ' or returns null if there is no such.
mcedit incorrectly highlights ' (green) in the /'/, and assumes it is string which continues beyond end of regexp (including comments, and probably to the end of file).
All examples here: http://smp.if.uj.edu.pl/~baryluk/mcedit-js-highlight-bug/
Thanks.
The text was updated successfully, but these errors were encountered: