Class Tokenizer
- java.lang.Object
-
- org.openstreetmap.josm.tools.template_engine.Tokenizer
-
public class Tokenizer extends java.lang.Object
This class converts a template string (stream of characters) into a stream of tokens.The result of the tokenization (also called lexical analysis) serves as input for the parser
TemplateParser.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTokenizer.TokenA token for the parserstatic classTokenizer.TokenTypeThe token type
-
Field Summary
Fields Modifier and Type Field Description private intcprivate Tokenizer.TokencurrentTokenprivate intindexprivate java.util.Set<java.lang.Character>specialCharactersprivate java.lang.Stringtemplateprivate java.lang.StringBuildertext
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidgetChar()Tokenizer.TokenlookAhead()Look at the next tokenTokenizer.TokennextToken()Get the next tokenTokenizer.Tokenskip(char lastChar)Skip until we hit a character
-
-
-
Field Detail
-
specialCharacters
private final java.util.Set<java.lang.Character> specialCharacters
-
template
private final java.lang.String template
-
c
private int c
-
index
private int index
-
currentToken
private Tokenizer.Token currentToken
-
text
private final java.lang.StringBuilder text
-
-
Method Detail
-
getChar
private void getChar()
-
nextToken
public Tokenizer.Token nextToken() throws ParseError
Get the next token- Returns:
- The next token
- Throws:
ParseError- if there is an error getting the next token
-
lookAhead
public Tokenizer.Token lookAhead() throws ParseError
Look at the next token- Returns:
- The next token
- Throws:
ParseError- if there is an error getting the next token
-
skip
public Tokenizer.Token skip(char lastChar)
Skip until we hit a character- Parameters:
lastChar- The last character to skip- Returns:
- A token with the skipped characters
-
-