|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.springsource.util.parser.manifest.internal.RecoveringManifestLexer
public class RecoveringManifestLexer
Process some input data according to the expected layout above. However, this is not a dumb lexer and intelligently processes the data to allow for some errors (which will be reported but are recovered from) and automatically processes some constructs so that the real parser building on top of this lexer does not have to (ie. it identifies ; = , := in the values)
The end of result of a 'lex' is that the data is broken into these tokens: NAME, COLON, VALUE, NEWLINE. Importantly:
Hopefully building the above knowledge into the lexer isn't make it too difficult to understand...
Concurrent Semantics
This class is thread safe.
Nested Class Summary | |
---|---|
private static class |
RecoveringManifestLexer.ParsingState
|
Field Summary | |
---|---|
private static byte |
alphanumMask
|
private static char[] |
BLANK_TOKEN_VALUE
|
private static char |
COLON
|
private SourceContext |
context
|
private char[] |
data
|
private int |
dataLength
|
private int |
dataPos
|
private static byte |
digitChar
|
private static byte[] |
fastCharLookup
|
private ManifestToken |
lastEmittedNameToken
|
private static byte |
letterChar
|
private java.util.List<java.lang.Integer> |
linebreaks
|
static int |
MAX_TOKEN_LENGTH
|
private static byte |
nameMask
|
private static byte |
newlineChar
|
private java.util.List<Token> |
newlineTokens
|
private RecoveringManifestLexer.ParsingState |
parsingState
|
private int |
possibleTokenEnd
|
private static char |
SPACE
|
private int |
startPosition
|
private char[] |
token
|
private int |
tokenPos
|
private SimpleTokenStream |
tokenStream
|
private static byte |
underscoreHyphenChar
|
Constructor Summary | |
---|---|
private |
RecoveringManifestLexer()
|
Method Summary | |
---|---|
private int |
correctMaxPosition(int pos)
|
private void |
emitAccumulatedNewlineTokens()
|
private void |
emitColonToken(int spos,
int epos)
|
private void |
emitNameToken()
|
private void |
emitPhantomColonToken(int pos)
|
private void |
emitPhantomValueToken(int pos)
|
private void |
emitValueToken(int spos,
int epos)
|
private void |
initialize()
|
private static boolean |
isAlphanumeric(char ch)
|
private static boolean |
isNameChar(char ch)
|
private static boolean |
isNewline(char ch)
|
private void |
process(java.lang.String str)
|
private boolean |
processNewlines(boolean emitToTokenStreamImmediately)
Process newlines from the currentposition until something other than a newline is encountered. |
private void |
recordProblem(ManifestProblemKind problemKind,
int start,
int end,
java.lang.String... inserts)
|
private void |
startNewToken()
|
static char[] |
subarray(char[] array,
int start,
int end)
|
static java.lang.String |
substring(char[] array,
int start,
int end)
|
static TokenStream |
tokenize(java.io.Reader reader)
Tokenize input from a Reader as a manifest. |
static TokenStream |
tokenize(java.lang.String manifestString)
Tokenize a string representing a manifest. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final char[] BLANK_TOKEN_VALUE
private static final char SPACE
private static final char COLON
public static final int MAX_TOKEN_LENGTH
private SimpleTokenStream tokenStream
private SourceContext context
private char[] data
private int dataLength
private int dataPos
private java.util.List<java.lang.Integer> linebreaks
private RecoveringManifestLexer.ParsingState parsingState
private char[] token
private int tokenPos
private int startPosition
private int possibleTokenEnd
private ManifestToken lastEmittedNameToken
private java.util.List<Token> newlineTokens
private static byte[] fastCharLookup
private static final byte letterChar
private static final byte digitChar
private static final byte underscoreHyphenChar
private static final byte newlineChar
private static final byte alphanumMask
private static final byte nameMask
Constructor Detail |
---|
private RecoveringManifestLexer()
Method Detail |
---|
public static TokenStream tokenize(java.lang.String manifestString)
manifestString
- the string
public static TokenStream tokenize(java.io.Reader reader) throws java.io.IOException
reader
- for input
java.io.IOException
- for read errorsprivate void initialize()
private void process(java.lang.String str)
private int correctMaxPosition(int pos)
private void emitNameToken()
private void emitColonToken(int spos, int epos)
private void emitPhantomColonToken(int pos)
private void emitValueToken(int spos, int epos)
private void emitPhantomValueToken(int pos)
private void emitAccumulatedNewlineTokens()
private void startNewToken()
private void recordProblem(ManifestProblemKind problemKind, int start, int end, java.lang.String... inserts)
public static final char[] subarray(char[] array, int start, int end)
public static final java.lang.String substring(char[] array, int start, int end)
private static boolean isAlphanumeric(char ch)
private static boolean isNameChar(char ch)
private static boolean isNewline(char ch)
private boolean processNewlines(boolean emitToTokenStreamImmediately)
emitToTokenStreamImmediately
- whether to emit the Newline tokens
immediately or simply record for later emission
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |