public class LexerDumpHelper
extends java.lang.Object
The first column is formatted as "[" line number ":" column number "]".
The second column is the symbolic representation of the integer token type of that token. The third column is the actual text from the file that corresponds to that token.
Modifier and Type | Field and Description |
---|---|
private java.text.NumberFormat |
cfmt
Formats a column number padded on left with zeros.
|
private antlr.TokenStream |
lexer
An instance of the lexer object.
|
private java.text.NumberFormat |
lfmt
Formats a line number padded on left with zeros.
|
private int |
maxSymSize
Size in characters of the largest possible token type name.
|
private java.lang.String[] |
names
Maps token types (as indexes) to token names.
|
private java.io.PrintWriter |
out
Output destination.
|
Constructor and Description |
---|
LexerDumpHelper(antlr.TokenStream lexer,
java.lang.String[] names,
java.io.PrintStream out)
Constructs an instance of the test driver using a specific instance
of the lexer.
|
LexerDumpHelper(antlr.TokenStream lexer,
java.lang.String[] names,
java.io.PrintWriter out)
Constructs an instance of the test driver using a specific instance
of the lexer.
|
Modifier and Type | Method and Description |
---|---|
private void |
calcMaximumSymbolNameSize()
Scans the list of token type names (text symbols that represent each
integer token type) and calculates the width in characters of the
largest one.
|
void |
dump()
Prints a report with one line per token in the token stream.
|
private void |
printToken(antlr.CommonToken next)
Prints a one line record for the token object passed as a parameter.
|
private java.text.NumberFormat lfmt
private java.text.NumberFormat cfmt
private int maxSymSize
private antlr.TokenStream lexer
private java.lang.String[] names
private java.io.PrintWriter out
public LexerDumpHelper(antlr.TokenStream lexer, java.lang.String[] names, java.io.PrintWriter out)
lexer
- Instance of the lexer to use for tokenizing the input file.names
- The array of token names indexed by token type.out
- Destination for output.public LexerDumpHelper(antlr.TokenStream lexer, java.lang.String[] names, java.io.PrintStream out)
lexer
- Instance of the lexer to use for tokenizing the input file.names
- The array of token names indexed by token type.out
- Destination for output.private void calcMaximumSymbolNameSize()
public void dump() throws antlr.TokenStreamException, java.io.IOException
antlr.TokenStreamException
- If an respective error occurs.java.io.IOException
- If an respective error occurs.private void printToken(antlr.CommonToken next) throws java.io.IOException
next
- The token to print.java.io.IOException
- If an respective error occurs.