Package io
Class Parser<T>
java.lang.Object
io.Parser<T>
- Direct Known Subclasses:
XMLParser
- Since:
- 11.12.2021
- Author:
- Juyas
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
check
(List<Token> tokens, int pos, TokenReader... readers) Match a list of tokens at the given position.protected String
Helper method to get a value in of the token list without going out of bounds.protected boolean
is
(List<Token> tokens, int pos, TokenReader reader) Match a token.abstract T
Parse an object by taking a chronological list of tokens.
-
Constructor Details
-
Parser
public Parser()
-
-
Method Details
-
get
Helper method to get a value in of the token list without going out of bounds.- Parameters:
tokens
- the list of tokenspos
- the position- Returns:
- the value at the given position in the list or
null
if the position is out of bounds
-
check
Match a list of tokens at the given position. Starting at pos, executes {@link this#is(List, int, TokenReader)} to test if all tokens are in the right order.- Parameters:
tokens
- the list of tokenspos
- the position to start matchingreaders
- the expected list of tokens by using theirTokenReader.type()
- Returns:
- if the token list matches the expected ones.
-
is
Match a token.- Parameters:
tokens
- the list of tokenspos
- the position to matchreader
- the expected token to match using itsTokenReader.type()
- Returns:
- true, if and only if the token list has a token at the given position that matches the given type
-
parse
Parse an object by taking a chronological list of tokens.- Parameters:
tokens
- the chronological list of tokens- Returns:
- the parsed object
-