de.hunsicker.jalopy.language.antlr
Class JavaLexer

java.lang.Object
  |
  +--antlr.CharScanner
        |
        +--de.hunsicker.jalopy.language.antlr.InternalJavaLexer
              |
              +--de.hunsicker.jalopy.language.antlr.JavaLexer
All Implemented Interfaces:
de.hunsicker.jalopy.language.antlr.JavaTokenTypes, Lexer, antlr.TokenStream

public class JavaLexer
extends de.hunsicker.jalopy.language.antlr.InternalJavaLexer
implements Lexer


Field Summary
 boolean formatMLComments
          Should multi-line comments be formatted?
static int JDK_1_3
          Indicates JDK version 1.3.
static int JDK_1_4
          Indicates JDK version 1.4.
 boolean parseJavadocComments
          Should Javadoc comments be parsed or added AS IS?
 boolean removeJavadocComments
          Should Javadoc comments be ignored?
 boolean removeMLComments
          Should multi-line comments be ignored?
 boolean removeSLComments
          Should single-line comments be ignored?
 int sourceVersion
          Specifies the Java release version to be compatible with.
 
Fields inherited from class de.hunsicker.jalopy.language.antlr.InternalJavaLexer
_tokenSet_0, _tokenSet_1, _tokenSet_2, _tokenSet_3, _tokenSet_4
 
Fields inherited from class antlr.CharScanner
_returnToken, caseSensitive, caseSensitiveLiterals, commitToPath, EOF_CHAR, hashString, inputState, literals, saveConsumedInput, tabsize, text, tokenObjectClass, traceDepth
 
Fields inherited from interface de.hunsicker.jalopy.language.antlr.JavaTokenTypes
ABSTRACT, ANNOTATION, ANNOTATION_ARRAY_INIT, ANNOTATION_DEF, ANNOTATION_FIELD_DEF, ANNOTATION_MEMBER_VALUE_PAIR, ANNOTATIONS, ARRAY_DECLARATOR, ARRAY_INIT, ASSIGN, AT, BAND, BAND_ASSIGN, BLOCK, BNOT, BOF, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, CASE_GROUP, CASESLIST, CHAR_LITERAL, CLASS_DEF, COLON, COMMA, COMMENT, CTOR_CALL, CTOR_DEF, DEC, DIV, DIV_ASSIGN, DOT, ELIST, EMPTY_STAT, ENUM_CONSTANT_DEF, ENUM_DEF, EOF, EQUAL, ESC, EXPONENT, EXPR, EXTENDS_CLAUSE, FINAL, FLOAT_SUFFIX, FOR_CONDITION, FOR_EACH_CLAUSE, FOR_INIT, FOR_ITERATOR, GE, GT, HEX_DIGIT, IDENT, IMPLEMENTS_CLAUSE, IMPORT, INC, INDEX_OP, INSTANCE_INIT, INTERFACE_DEF, JAVADOC_COMMENT, LABELED_STAT, LAND, LBRACK, LCURLY, LE, LITERAL_assert, LITERAL_boolean, LITERAL_break, LITERAL_byte, LITERAL_case, LITERAL_catch, LITERAL_char, LITERAL_class, LITERAL_continue, LITERAL_default, LITERAL_do, LITERAL_double, LITERAL_else, LITERAL_enum, LITERAL_extends, LITERAL_false, LITERAL_finally, LITERAL_float, LITERAL_for, LITERAL_if, LITERAL_implements, LITERAL_import, LITERAL_instanceof, LITERAL_int, LITERAL_interface, LITERAL_long, LITERAL_native, LITERAL_new, LITERAL_null, LITERAL_package, LITERAL_private, LITERAL_protected, LITERAL_public, LITERAL_return, LITERAL_short, LITERAL_static, LITERAL_super, LITERAL_switch, LITERAL_synchronized, LITERAL_this, LITERAL_threadsafe, LITERAL_throw, LITERAL_throws, LITERAL_transient, LITERAL_true, LITERAL_try, LITERAL_void, LITERAL_volatile, LITERAL_while, LNOT, LOR, LPAREN, LT, METHOD_CALL, METHOD_DEF, MINUS, MINUS_ASSIGN, ML_COMMENT, MOD, MOD_ASSIGN, MODIFIERS, NOT_EQUAL, NULL_TREE_LOOKAHEAD, NUM_DOUBLE, NUM_FLOAT, NUM_INT, NUM_LONG, OBJBLOCK, PACKAGE_DEF, PARAMETER_DEF, PARAMETERS, PLUS, PLUS_ASSIGN, POST_DEC, POST_INC, QUESTION, RBRACK, RCURLY, ROOT, RPAREN, SEMI, SEPARATOR_COMMENT, SL, SL_ASSIGN, SL_COMMENT, SLIST, SPECIAL_COMMENT, SR, SR_ASSIGN, STAR, STAR_ASSIGN, STATIC_IMPORT, STATIC_INIT, STRICTFP, STRING_LITERAL, SUPER_CTOR_CALL, SYNBLOCK, TRIPLE_DOT, TYPE, TYPE_ARGUMENT, TYPE_ARGUMENTS, TYPE_LOWER_BOUNDS, TYPE_PARAMETER, TYPE_PARAMETERS, TYPE_UPPER_BOUNDS, TYPECAST, UNARY_MINUS, UNARY_PLUS, VARIABLE_DEF, VARIABLE_PARAMETER_DEF, VOCAB, WILDCARD_TYPE, WS
 
Constructor Summary
JavaLexer(CompositeFactory factory)
          Creates a new JavaLexer object.
JavaLexer(antlr.InputBuffer ib, CompositeFactory factory)
           
JavaLexer(antlr.LexerSharedInputState state, CompositeFactory factory)
           
JavaLexer(java.io.Reader in, CompositeFactory factory)
           
 
Method Summary
 int getCompatibility()
          Gets the current source compatiblity version.
 FileFormat getFileFormat()
          Returns the detected file format.
 JavadocParser getJavadocParser()
          Returns the internal parser for Javadoc comments.
 Parser getParser()
          Returns the corresponding parser for this lexer.
 boolean isFormatMLComments()
          Indicates whether multi-line comments should be formatted.
 boolean isParseJavadocComments()
          Indicates whether Javadoc comments will be parsed during processing.
 boolean isRemoveJavadocComments()
          Indicates whether Javadoc comments should be removed during processing.
 boolean isRemoveMLComments()
          Indicates whether multi-line comments should be removed during processing.
 boolean isRemoveSLComments()
          Indicates whether single-line comments should be removed during processing.
protected  antlr.Token makeJavaDoc(antlr.Token node, java.lang.String newText)
           
protected  antlr.Token makeToken(int t)
          Creates a token of the given tpye.
 void panic()
           
 void panic(java.lang.String message)
           
 void reportError(antlr.RecognitionException ex)
          Reports the given error.
 void reportError(java.lang.String message)
          Reports the given error.
 void reportWarning(java.lang.String message)
          Reports the given warning.
 void reset()
          Resets the lexer.
 void setCompatibility(int version)
          Sets the source compatiblity to the given release version.
 void setFormatMLComments(boolean format)
          Sets whether multi-line comments should be formatted.
 void setInputBuffer(antlr.InputBuffer buf)
          Sets the input buffer to use.
 void setInputBuffer(java.io.Reader in)
          Sets the input buffer to use.
 void setParseJavadocComments(boolean parse)
          Sets whether Javadoc comments should be parsed during processing.
 void setRemoveJavadocComments(boolean remove)
          Sets whether Javadoc comments should be removed during processing.
 void setRemoveMLComments(boolean remove)
          Sets whether multi-line comments should be removed during processing.
 void setRemoveSLComments(boolean remove)
          Sets whether single-line comments should be removed during processing.
 void setTokenObjectClass(java.lang.String clazz)
          Sets the class to use for tokens.
 int testLiteralsTable(int ttype)
          Test the token type against the literals table.
 int testLiteralsTable(java.lang.String tokenText, int ttype)
          Test the text passed in against the literals table.
 
Methods inherited from class de.hunsicker.jalopy.language.antlr.InternalJavaLexer
enableAssert, enableEnum, isAssertEnabled, isEnumEnabled, mASSIGN, mAT, mBAND_ASSIGN, mBAND, mBNOT, mBOR_ASSIGN, mBOR, mBSR_ASSIGN, mBSR, mBXOR_ASSIGN, mBXOR, mCHAR_LITERAL, mCOLON, mCOMMA, mCOMMENT, mDEC, mDIV_ASSIGN, mDIV, mEQUAL, mESC, mEXPONENT, mFLOAT_SUFFIX, mGE, mGT, mHEX_DIGIT, mIDENT, mINC, mLAND, mLBRACK, mLCURLY, mLE, mLNOT, mLOR, mLPAREN, mLT, mMINUS_ASSIGN, mMINUS, mML_COMMENT, mMOD_ASSIGN, mMOD, mNOT_EQUAL, mNUM_INT, mPLUS_ASSIGN, mPLUS, mQUESTION, mRBRACK, mRCURLY, mRPAREN, mSEMI, mSEPARATOR_COMMENT, mSL_ASSIGN, mSL_COMMENT, mSL, mSR_ASSIGN, mSR, mSTAR_ASSIGN, mSTAR, mSTRING_LITERAL, mVOCAB, mWS, nextToken
 
Methods inherited from class antlr.CharScanner
append, append, commit, consume, consumeUntil, consumeUntil, getCaseSensitive, getCaseSensitiveLiterals, getColumn, getCommitToPath, getFilename, getInputBuffer, getInputState, getLine, getTabSize, getText, getTokenObject, LA, mark, match, match, match, matchNot, matchRange, newline, resetText, rewind, setCaseSensitive, setColumn, setCommitToPath, setFilename, setInputState, setLine, setTabSize, setText, tab, toLower, traceIn, traceIndent, traceOut, uponEOF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.hunsicker.jalopy.language.Lexer
getColumn, getFilename, getLine, setColumn, setFilename, setLine
 
Methods inherited from interface antlr.TokenStream
nextToken
 

Field Detail

JDK_1_3

public static final int JDK_1_3
Indicates JDK version 1.3.

See Also:
Constant Field Values

JDK_1_4

public static final int JDK_1_4
Indicates JDK version 1.4.

See Also:
Constant Field Values

parseJavadocComments

public boolean parseJavadocComments
Should Javadoc comments be parsed or added AS IS?


sourceVersion

public int sourceVersion
Specifies the Java release version to be compatible with.


removeJavadocComments

public boolean removeJavadocComments
Should Javadoc comments be ignored?


formatMLComments

public boolean formatMLComments
Should multi-line comments be formatted?


removeSLComments

public boolean removeSLComments
Should single-line comments be ignored?


removeMLComments

public boolean removeMLComments
Should multi-line comments be ignored?

Constructor Detail

JavaLexer

public JavaLexer(java.io.Reader in,
                 CompositeFactory factory)

JavaLexer

public JavaLexer(antlr.InputBuffer ib,
                 CompositeFactory factory)

JavaLexer

public JavaLexer(antlr.LexerSharedInputState state,
                 CompositeFactory factory)

JavaLexer

public JavaLexer(CompositeFactory factory)
Creates a new JavaLexer object. Use setInputBuffer(Reader) to set up the input buffer.

Method Detail

getJavadocParser

public JavadocParser getJavadocParser()
Returns the internal parser for Javadoc comments.

Returns:
the internal parser for Javadoc comments.

getParser

public Parser getParser()
Returns the corresponding parser for this lexer.

Specified by:
getParser in interface Lexer
Returns:
corresponding parser.

setRemoveMLComments

public void setRemoveMLComments(boolean remove)
Sets whether multi-line comments should be removed during processing.

Parameters:
remove - if true multi-line comments will be removed during processing.

setFormatMLComments

public void setFormatMLComments(boolean format)
Sets whether multi-line comments should be formatted.

Parameters:
format - if true multi-line comments will be formatted.

isFormatMLComments

public boolean isFormatMLComments()
Indicates whether multi-line comments should be formatted.

Returns:
true if multi-line comments should be formatted.

isRemoveMLComments

public boolean isRemoveMLComments()
Indicates whether multi-line comments should be removed during processing.

Returns:
true if multi-line comments should be removed during processing.

setRemoveSLComments

public void setRemoveSLComments(boolean remove)
Sets whether single-line comments should be removed during processing.

Parameters:
remove - if true single-line comments will be removed during processing.

isRemoveSLComments

public boolean isRemoveSLComments()
Indicates whether single-line comments should be removed during processing.

Returns:
true if single-line comments should be removed during processing.

setRemoveJavadocComments

public void setRemoveJavadocComments(boolean remove)
Sets whether Javadoc comments should be removed during processing.

Parameters:
remove - if true Javadoc comments will be removed during processing.

isRemoveJavadocComments

public boolean isRemoveJavadocComments()
Indicates whether Javadoc comments should be removed during processing.

Returns:
true if Javadoc comments should be removed during processing.

setParseJavadocComments

public void setParseJavadocComments(boolean parse)
Sets whether Javadoc comments should be parsed during processing.

Parameters:
parse - if true Javadoc comments will be parsed during processing.

isParseJavadocComments

public boolean isParseJavadocComments()
Indicates whether Javadoc comments will be parsed during processing.

Returns:
true if Javadoc comments will be parsed during processing.

setCompatibility

public void setCompatibility(int version)
Sets the source compatiblity to the given release version.

Parameters:
version - Java JDK version constant.

getCompatibility

public int getCompatibility()
Gets the current source compatiblity version.

Returns:
compatiblity version.

testLiteralsTable

public int testLiteralsTable(int ttype)
Test the token type against the literals table.

Overrides:
testLiteralsTable in class antlr.CharScanner
Parameters:
ttype - recognized token type.
Returns:
token type.

testLiteralsTable

public int testLiteralsTable(java.lang.String tokenText,
                             int ttype)
Test the text passed in against the literals table.

Overrides:
testLiteralsTable in class antlr.CharScanner
Parameters:
tokenText - recognized token text.
ttype - recognized token text type.
Returns:
token type.

panic

public void panic()
Overrides:
panic in class antlr.CharScanner

panic

public void panic(java.lang.String message)
Overrides:
panic in class antlr.CharScanner

reportError

public void reportError(antlr.RecognitionException ex)
Reports the given error.

Overrides:
reportError in class antlr.CharScanner
Parameters:
ex - exception which caused the error.

reportError

public void reportError(java.lang.String message)
Reports the given error.

Overrides:
reportError in class antlr.CharScanner
Parameters:
message - error message.

reportWarning

public void reportWarning(java.lang.String message)
Reports the given warning.

Overrides:
reportWarning in class antlr.CharScanner
Parameters:
message - warning message.

makeToken

protected antlr.Token makeToken(int t)
Creates a token of the given tpye.

Overrides:
makeToken in class antlr.CharScanner
Parameters:
t - type of the token.

setTokenObjectClass

public void setTokenObjectClass(java.lang.String clazz)
Sets the class to use for tokens.

Overrides:
setTokenObjectClass in class antlr.CharScanner
Parameters:
clazz - a qualified class name.
Throws:
java.lang.IllegalArgumentException - if the class is not derived from ExtendedToken.

getFileFormat

public FileFormat getFileFormat()
Returns the detected file format.

Specified by:
getFileFormat in interface Lexer
Returns:
file format.

setInputBuffer

public void setInputBuffer(antlr.InputBuffer buf)
Sets the input buffer to use.

Parameters:
buf - buffer.

setInputBuffer

public void setInputBuffer(java.io.Reader in)
Sets the input buffer to use.

Specified by:
setInputBuffer in interface Lexer
Parameters:
in - reader to read from.

reset

public void reset()
Resets the lexer.

You have to re-initialize the input buffer before you can use the lexer again.

Specified by:
reset in interface Lexer
See Also:
setInputBuffer(antlr.InputBuffer)

makeJavaDoc

protected antlr.Token makeJavaDoc(antlr.Token node,
                                  java.lang.String newText)
                           throws antlr.TokenStreamIOException
Specified by:
makeJavaDoc in class de.hunsicker.jalopy.language.antlr.InternalJavaLexer
antlr.TokenStreamIOException


Copyright © 1997-2005 Jalopy. All Rights Reserved.