Methods Summary |
---|
public char | LA(int i)
if (caseSensitive) {
return inputState.input.LA(i);
}
else {
return toLower(inputState.input.LA(i));
}
|
public void | append(char c)
if (saveConsumedInput) {
text.append(c);
}
|
public void | append(java.lang.String s)
if (saveConsumedInput) {
text.append(s);
}
|
public void | commit()
inputState.input.commit();
|
public void | consume()
if (inputState.guessing == 0) {
char c = LA(1);
if (caseSensitive) {
append(c);
}
else {
// use input.LA(), not LA(), to get original case
// CharScanner.LA() would toLower it.
append(inputState.input.LA(1));
}
if (c == '\t") {
tab();
}
else {
inputState.column++;
}
}
inputState.input.consume();
|
public void | consumeUntil(int c)Consume chars until one matches the given char
while (LA(1) != EOF_CHAR && LA(1) != c) {
consume();
}
|
public void | consumeUntil(persistence.antlr.collections.impl.BitSet set)Consume chars until one matches the given set
while (LA(1) != EOF_CHAR && !set.member(LA(1))) {
consume();
}
|
public boolean | getCaseSensitive()
return caseSensitive;
|
public final boolean | getCaseSensitiveLiterals()
return caseSensitiveLiterals;
|
public int | getColumn()
return inputState.column;
|
public boolean | getCommitToPath()
return commitToPath;
|
public java.lang.String | getFilename()
return inputState.filename;
|
public persistence.antlr.InputBuffer | getInputBuffer()
return inputState.input;
|
public persistence.antlr.LexerSharedInputState | getInputState()
return inputState;
|
public int | getLine()
return inputState.line;
|
public int | getTabSize()
return tabsize;
|
public java.lang.String | getText()return a copy of the current text buffer
return text.toString();
|
public persistence.antlr.Token | getTokenObject()
return _returnToken;
|
protected persistence.antlr.Token | makeToken(int t)
try {
Token tok = (Token)tokenObjectClass.newInstance();
tok.setType(t);
tok.setColumn(inputState.tokenStartColumn);
tok.setLine(inputState.tokenStartLine);
// tracking real start line now: tok.setLine(inputState.line);
return tok;
}
catch (InstantiationException ie) {
panic("can't instantiate token: " + tokenObjectClass);
}
catch (IllegalAccessException iae) {
panic("Token class is not accessible" + tokenObjectClass);
}
return Token.badToken;
|
public int | mark()
return inputState.input.mark();
|
public void | match(char c)
if (LA(1) != c) {
throw new MismatchedCharException(LA(1), c, false, this);
}
consume();
|
public void | match(persistence.antlr.collections.impl.BitSet b)
if (!b.member(LA(1))) {
throw new MismatchedCharException(LA(1), b, false, this);
}
else {
consume();
}
|
public void | match(java.lang.String s)
int len = s.length();
for (int i = 0; i < len; i++) {
if (LA(1) != s.charAt(i)) {
throw new MismatchedCharException(LA(1), s.charAt(i), false, this);
}
consume();
}
|
public void | matchNot(char c)
if (LA(1) == c) {
throw new MismatchedCharException(LA(1), c, true, this);
}
consume();
|
public void | matchRange(char c1, char c2)
if (LA(1) < c1 || LA(1) > c2) throw new MismatchedCharException(LA(1), c1, c2, false, this);
consume();
|
public void | newline()
inputState.line++;
inputState.column = 1;
|
public void | panic()
System.err.println("CharScanner: panic");
System.exit(1);
|
public void | panic(java.lang.String s)This method is executed by ANTLR internally when it detected an illegal
state that cannot be recovered from.
The default implementation of this method calls
{@link java.lang.System.exit(int)} and writes directly to
{@link java.lang.System.err)} , which is usually not appropriate when
a translator is embedded into a larger application. It is highly
recommended that this method be overridden to handle the error in a
way appropriate for your application (e.g. throw an unchecked
exception).
System.err.println("CharScanner; panic: " + s);
System.exit(1);
|
public void | reportError(persistence.antlr.RecognitionException ex)Parser error-reporting function can be overridden in subclass
System.err.println(ex);
|
public void | reportError(java.lang.String s)Parser error-reporting function can be overridden in subclass
if (getFilename() == null) {
System.err.println("error: " + s);
}
else {
System.err.println(getFilename() + ": error: " + s);
}
|
public void | reportWarning(java.lang.String s)Parser warning-reporting function can be overridden in subclass
if (getFilename() == null) {
System.err.println("warning: " + s);
}
else {
System.err.println(getFilename() + ": warning: " + s);
}
|
public void | resetText()
text.setLength(0);
inputState.tokenStartColumn = inputState.column;
inputState.tokenStartLine = inputState.line;
|
public void | rewind(int pos)
inputState.input.rewind(pos);
// RK: should not be here, it is messing up column calculation
// setColumn(inputState.tokenStartColumn);
|
public void | setCaseSensitive(boolean t)
caseSensitive = t;
|
public void | setColumn(int c)
inputState.column = c;
|
public void | setCommitToPath(boolean commit)
commitToPath = commit;
|
public void | setFilename(java.lang.String f)
inputState.filename = f;
|
public void | setInputState(persistence.antlr.LexerSharedInputState state)
inputState = state;
|
public void | setLine(int line)
inputState.line = line;
|
public void | setTabSize(int size)
tabsize = size;
|
public void | setText(java.lang.String s)
resetText();
text.append(s);
|
public void | setTokenObjectClass(java.lang.String cl)
try {
tokenObjectClass = Class.forName(cl);
}
catch (ClassNotFoundException ce) {
panic("ClassNotFoundException: " + cl);
}
|
public void | tab()advance the current column number by an appropriate amount
according to tab size. This method is called from consume().
int c = getColumn();
int nc = ( ((c-1)/tabsize) + 1) * tabsize + 1; // calculate tab stop
setColumn( nc );
|
public int | testLiteralsTable(int ttype)
hashString.setBuffer(text.getBuffer(), text.length());
Integer literalsIndex = (Integer)literals.get(hashString);
if (literalsIndex != null) {
ttype = literalsIndex.intValue();
}
return ttype;
|
public int | testLiteralsTable(java.lang.String text, int ttype)Test the text passed in against the literals table
Override this method to perform a different literals test
This is used primarily when you want to test a portion of
a token.
ANTLRHashString s = new ANTLRHashString(text, this);
Integer literalsIndex = (Integer)literals.get(s);
if (literalsIndex != null) {
ttype = literalsIndex.intValue();
}
return ttype;
|
public char | toLower(char c)
return Character.toLowerCase(c);
|
public void | traceIn(java.lang.String rname)
traceDepth += 1;
traceIndent();
System.out.println("> lexer " + rname + "; c==" + LA(1));
|
public void | traceIndent()
for (int i = 0; i < traceDepth; i++)
System.out.print(" ");
|
public void | traceOut(java.lang.String rname)
traceIndent();
System.out.println("< lexer " + rname + "; c==" + LA(1));
traceDepth -= 1;
|
public void | uponEOF()This method is called by YourLexer.nextToken() when the lexer has
hit EOF condition. EOF is NOT a character.
This method is not called if EOF is reached during
syntactic predicate evaluation or during evaluation
of normal lexical rules, which presumably would be
an IOException. This traps the "normal" EOF condition.
uponEOF() is called after the complete evaluation of
the previous token and only if your parser asks
for another token beyond that last non-EOF token.
You might want to throw token or char stream exceptions
like: "Heh, premature eof" or a retry stream exception
("I found the end of this file, go back to referencing file").
|