pomsky
pomsky copied to clipboard
Linter
Is your feature request related to a problem? Please describe.
These days, many languages have top-notch tooling to help the developer write idiomatic, easy-to-understand code. Pomsky should be no exception.
Describe the solution you'd like
A linter, part of pomsky-bin and the VS code extension, which gives the developer useful suggestions.
Lints that I'd like to have:
- [ ] Unreachable alternative:
('ab' | 'abc')- Since the first alternative always matches when the second would also match, the second alternative is never reached and therefore useless
- [ ] Empty expression:
let x = ;or()- Also detects when the input is completely empty, or contains only
letbindings
- Also detects when the input is completely empty, or contains only
- [ ] Unnecessary modifier:
'a'? lazyorenable greedy; 'a' greedy - [ ] Unnecessary parentheses:
('ab')? - [ ] Unnecessary repetition:
('x'?)?or'x'{1} - [ ] Unnecessary repetition chain:
'a'{2}{5}- Could be written with a single repetition
- [ ] Impossible forward reference:
::1 :('x')- Since the reference is not in a repeated group together with the referenced expression, it can never match successfully
- [ ] Too lazy repetition:
C*or'x'* C- The lazy repetition is not followed by a "terminator"; a terminator is an expression that is not a subset of the repeated expression. For example,
Cis not a terminator for'x'?, because it always matches when'x'would match - This should not trigger the lint
-
'x'* C 'y' -
('x'* C) 'y'
-
- The lazy repetition is not followed by a "terminator"; a terminator is an expression that is not a subset of the repeated expression. For example,
- [ ] Exponential backtracking
- This might be difficult to detect correctly in all situations, but a solution with many false negatives and few false positives is better than nothing
- [ ] Too many numbered capturing groups:
:('a') :('a') :('a') :('a') :('a') :('a') :('a') :('a') :('a') :('a') :('a') :('a')- Threshold should be configurable