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

Linter #50

Open
10 tasks
Aloso opened this issue Aug 2, 2022 · 0 comments
Open
10 tasks

Linter #50

Aloso opened this issue Aug 2, 2022 · 0 comments
Labels
C-diagnostics Warnings and errors reported by Pomsky C-tooling Tools such as IDE integrations, formatters, linters, etc. enhancement New feature or request

Comments

@Aloso
Copy link
Member

Aloso commented Aug 2, 2022

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 let bindings
  • Unnecessary modifier: 'a'? lazy or enable 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, C is 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'
  • 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
@Aloso Aloso added enhancement New feature or request C-diagnostics Warnings and errors reported by Pomsky C-tooling Tools such as IDE integrations, formatters, linters, etc. labels Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-diagnostics Warnings and errors reported by Pomsky C-tooling Tools such as IDE integrations, formatters, linters, etc. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant