Interface ParsePattern<T extends Sentence>

Type Parameters:
T - Sentence type, matching Parser.
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ParsePattern<T extends Sentence>

Pattern is a function which consumes Expression Pieces and converts them into a Sentence list.

Patterns either belong to the parser or just exist outside to be used by other patterns. Patterns in the first case will be gone through when trying to parse the whole text. They have IDs by which they can be received from the parser. A parser should have at least one of such a pattern.

Pattern takes some amount of pieces, gives this amount and sentence as result (or null on failure), and leaves the rest of pieces to the code that used the pattern. Hence, that code should check whether all pieces were used when required.

Patterns in parser-related documents should be defined using following pattern notation:

 [_] - piece 0 or 1 times
 <_> - piece once
 [_]... - piece 0 or more times
 <_>... - piece 1 or more times
 _(_) - group of other pattern (used inside brackets)>
 a|b - either a or b (used inside brackets)
 ... - anything / et cetera (used inside brackets)
 -> _ - possible result (used at the end of a pattern)
 

The written text (denoted as an underscore) can be anything, but should usually display the piece name (as code variable name or part of the piece structure name), their character content (if it is explicit), or other pattern notation. The patterns can be separated by spaces (reflects how the spaces work in the parsing process).