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

Bash lexer issue with escaping # ( \# ) #511

Closed
oOosys opened this issue Mar 9, 2024 · 5 comments
Closed

Bash lexer issue with escaping # ( \# ) #511

oOosys opened this issue Mar 9, 2024 · 5 comments

Comments

@oOosys
Copy link

oOosys commented Mar 9, 2024

issue_bashLexer

Note: SciTE does it the right way ...

@orbitalquark
Copy link
Owner

orbitalquark commented Mar 10, 2024 via email

@oOosys
Copy link
Author

oOosys commented Mar 10, 2024

... Thanks for the reply. No urge in fixing ... if it were very important to me I would have sure already provided a fix myself. Just wanted to mention this issue for the sake of it.

@orbitalquark
Copy link
Owner

Fixed in orbitalquark/scintillua@f971ac5

@oOosys
Copy link
Author

oOosys commented Mar 11, 2024

OK ... it works like a charm :) and it was so easy to fix, that it can't be called a bug or issue but a simple oversight in first place, so it appears a bit strange that it wasn't over the years yet reported.

May you please explain a bit the mechanism used in this fix? It appears to demonstrate how to include exceptions from a rule triggered by a pattern by specifying a prefix one with -B('CharacterOrStringOrAnyRegex?') to the pattern to_eol('CharacterOrStringOrAnyRegex?'):

lex:add_rule('comment', lex:tag(lexer.COMMENT, -B('\\') * lexer.to_eol('#')))

I mean learning how things work by fixing issues is a much better way to make progress in understanding the underlying mechanisms than reading the manuals ...

@orbitalquark
Copy link
Owner

It's kind of like regex look-behind. LPeg matches '#' (in lexer.to_eol('#')), but only if it's not preceded by a '\' character.

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

2 participants