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

Refactor CharacterClass: use ICharacterClass where possible #26

Merged

Commits on Jul 5, 2019

  1. Refactor CharacterClass: use ICharacterClass where possible

    The main rationale behind this refactoring is that the class
    `CharacterClassSymbol` (a subclass of `Symbol`) was being "abused".
    It was used for instance in the lookahead restriction of symbols
    and reduce actions and in `State.doReduces`/`State.addReduceAction`.
    Those use sites do not need to know anything related to a grammar
    symbol, but really only need to know which characters are in the CC.
    Therefore, it is better to directly use the `ICharacterClass` interface
    at these places. In order to accomplish this, the following changes
    have been made:
    
    - `union`, `intersection`, and `difference` used to be called on the
      `CharacterClassFactory`, and `isEmpty` could only be called on
      `CharacterClassSymbol`. Now, they can be called directly on
      `ICharacterClass`.
    - `toAterm` used to be a method in the `CharacterClassSymbol`.
      It is now also a method in `ICharacterClass`, where a more specific
      implementation for the "single" and "range" classes (resolving the
      `FIXME` comment).
      - This adds a dependency from `tableinterfaces` to
        `org.metaborg.terms`.
    
    Note that the `CharacterClass` symbol class has been renamed to
    `CharacterClassSymbol`, to reduce the confusion between the grammar
    symbol and the `ICharacterClass` data structure.
    
    As a final remark: my autoformatter has sometimes reformatted spacing
    and import groups, even in classes where I only changed one line.
    Unfortunately, this does generate some noise in the diff.
    mpsijm committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    291e625 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    285d8b6 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0e47571 View commit details
    Browse the repository at this point in the history