SonarSource Language Recognizer
  1. SonarSource Language Recognizer
  2. SSLR-359

The Lexer (and Parser) class should be extendable to allow preprocessing logic to be injected

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.20
    • Fix Version/s: 1.22
    • Component/s: None
    • Labels:
      None

      Description

      In the Python plugin, it is not possible to get rid of the preprocessor because there is no way to inject logic in the lexer, as that class is not extendable.

      It only has a private constructor taking a Builder instance (which itself is also final).

      In a better world, constructors should never take builders as parameters, to not enforce the usage of the builder too strictly.

      Moreover, the Lexer.lex(Reader) class is private, but it would be much more convenient to make it at least protected, so that it can be the only method which must be overriden to inject the preprocessing behavior back.

        Issue Links

          Activity

          Show
          Dinesh Bolkensteyn added a comment - Python preprocessor: https://github.com/SonarCommunity/sonar-python/blob/master/python-squid/src/main/java/org/sonar/python/lexer/IndentationPreprocessor.java

            People

            • Assignee:
              Unassigned
              Reporter:
              Dinesh Bolkensteyn
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: