Skip to content

Conversation

Mwexim
Copy link
Owner

@Mwexim Mwexim commented Jul 13, 2021

This pull request aims to improve pattern utilities by extending the parse marks with more functionality:

  • Parse marks now are called 'marks' for short (to not make the methods too long)
  • Strings are now the base components of parse marks and allow alphanumeric values.
  • If no mark is given (like (:first choice|:second choice)), the stripped text representation of the ChoiceElement will be the mark. This means that a choice group :first [choice] won't have 'first [choice]' as parse mark, but 'first' (notice the space at the end is omitted).
  • You can also use the ':' character in front of a group (like :(first|second)) to apply this behaviour to all elements of the group (except for the ones that still have a mark present: these will override this behaviour).
  • A list of all parsed marks is now present in the ParseContext instead of a simple integer value.
    • You can still use getNumericMark() which will parse all strings as integers (with the correct base) and XOR them accordingly (basically the old behaviour)
    • You can use getSingleMark() to quickly get a mark.
    • You can use hasMark(String) to quickly check if a mark is present.

This will be very helpful for patterns that require multiple parse marks in different groups. In all other cases, you probably are better of using integer marks.

@Mwexim
Copy link
Owner Author

Mwexim commented Jul 13, 2021

See this PR by the way to have a better context as of why these changes were made.

@Mwexim Mwexim merged commit 956a2b4 into master Jul 24, 2021
@Mwexim Mwexim deleted the improvement/pattern-tools branch July 24, 2021 18:42
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

Successfully merging this pull request may close these issues.

1 participant