Class ExpressionPiece
java.lang.Object
net.diversionmc.parser.util.Pointable
net.diversionmc.parser.expression.ExpressionPiece
- Direct Known Subclasses:
CharPiece,CommentPiece,GroupPiece,NamePiece,NumberPiece,StringPiece
Expression Pieces are the units of the text format. They represent single characters or sequences of characters digested into structural form by first parsing pass.
A piece usually features a PiecePredicate determining which piece type
should start processing at a current point in file given a character.
There must be only one valid piece type at a given point.
Piece never starts with a whitespace character (space, tab, newline, etc),
when there is no currently set piece, the whitespace characters are skipped.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract PieceResultread(char c, FilePointer ptr) Parse a character by this piece.replace(FilePointer ptr) Called wheneverPieceResult.REPLACE_LEAVEorPieceResult.REPLACE_TAKEare used.
-
Constructor Details
-
ExpressionPiece
Construct a piece at a position.- Parameters:
ptr- Creation position.
-
-
Method Details
-
read
Parse a character by this piece.- Parameters:
c- Character to parse.ptr- Character position in file.- Returns:
PieceResult
-
replace
Called wheneverPieceResult.REPLACE_LEAVEorPieceResult.REPLACE_TAKEare used.- Parameters:
ptr- Position when replace was used.- Returns:
- Another piece to continue parsing with, or null to discard current piece.
-