javaprec
Class JavaRecognizer
java.lang.Object
|
+--antlr.Parser
|
+--antlr.LLkParser
|
+--javaprec.JavaRecognizer
- All Implemented Interfaces:
- JavaTokenTypes
- public class JavaRecognizer
- extends LLkParser
- implements JavaTokenTypes
Java 1.3 Recognizer
Contributing authors:
James Bloom jamesdbloom@msn.com
John Mitchell johnm@non.net
Terence Parr parrt@magelang.com
John Lilley jlilley@empathy.com
Scott Stanchfield thetick@magelang.com
Markus Mohnen mohnen@informatik.rwth-aachen.de
Peter Williams pete.williams@sun.com
Allan Jacobs Allan.Jacobs@eng.sun.com
Steve Messick messick@redhills.com
Version 1.00 December 9, 1997 -- initial release
Version 1.01 December 10, 1997
fixed bug in octal def (0..7 not 0..8)
Version 1.10 August 1998 (parrt)
added tree construction
fixed definition of WS,comments for mac,pc,unix newlines
added unary plus
Version 1.11 (Nov 20, 1998)
Added "shutup" option to turn off last ambig warning.
Fixed inner class def to allow named class defs as statements
synchronized requires compound not simple statement
add [] after builtInType DOT class in primaryExpression
"const" is reserved but not valid..removed from modifiers
Version 1.12 (Feb 2, 1999)
Changed LITERAL_xxx to xxx in tree grammar.
Updated java.g to use tokens {...} now for 2.6.0 (new feature).
Version 1.13 (Apr 23, 1999)
Didn't have (stat)? for else clause in tree parser.
Didn't gen ASTs for interface extends. Updated tree parser too.
Updated to 2.6.0.
Version 1.14 (Jun 20, 1999)
Allowed final/abstract on local classes.
Removed local interfaces from methods
Put instanceof precedence where it belongs...in relationalExpr
It also had expr not type as arg; fixed it.
Missing ! on SEMI in classBlock
fixed: (expr) + "string" was parsed incorrectly (+ as unary plus).
fixed: didn't like Object[].class in parser or tree parser
Version 1.15 (Jun 26, 1999)
Screwed up rule with instanceof in it. :( Fixed.
Tree parser didn't like (expr).something; fixed.
Allowed multiple inheritance in tree grammar. oops.
Version 1.16 (August 22, 1999)
Extending an interface built a wacky tree: had extra EXTENDS.
Tree grammar didn't allow multiple superinterfaces.
Tree grammar didn't allow empty var initializer: {}
Version 1.17 (October 12, 1999)
ESC lexer rule allowed 399 max not 377 max.
java.tree.g didn't handle the expression of synchronized
statements.
Version 1.18 (August 12, 2001)
Terence updated to Java 2 Version 1.3 by observing/combining work of
Allan Jacobs and Steve Messick. Handles 1.3 src.
Summary:
o primary didn't include boolean.class kind of thing
o constructor calls parsed explicitly now:
see explicitConstructorInvocation
o add strictfp modifier
o missing objBlock after new expression in tree grammar
o merged local class definition alternatives, moved after declaration
o fixed problem with ClassName.super.field
o reordered some alternatives to make things more efficient
o long and double constants were not differentiated from int/float
o whitespace rule was inefficient: matched only one char
o add an examples directory with some nasty 1.3 cases
o made Main.java use buffered IO and a Reader for Unicode support
o supports UNICODE?
Using Unicode charVocabulay makes code file big, but only
in the bitsets at the end. I need to make ANTLR generate
unicode bitsets more efficiently.
2002-01-25 jpnp (john@pybus.org)
o fix lexing of floating point constants
o 3.0 was incorrectly parsed as float rather than double
o preliminary stab at sorting out SUPER_CTOR_CALL
o f.g.super() was parsing as METHOD_CALL.
rearranged primaryExpression and postfixExpression so they
don't match ...super(). [I haven't yet fully tested that I
didn't break anything else in the process!]
2002-01-28 jpnp
o problem with SUPER_CTOR_CALL fixed
o Tidied up postfixExpression, and identPrimary. Primary expressions
with more than one dotted part now work as qualifiers for super().
2002-01-29 jpnp
o properly fixed float lexing bug.
o Typo, wanted to test on 'F' but was using 'D'.
2003-06-22 James Bloom
o updated for java 1.4,
o removed tree production,
o added output to StringBuffer to enable code tpo be copied and
altered by adding new code in to certain parts of a class
o adapted for Runtime Java Class Editor - PreCompiler
generates precompiled source and XML for any class
that implements rom.interpreter.InterpreterWrapper
Fields inherited from interface javaprec.JavaTokenTypes |
ABSTRACT, ARRAY_DECLARATOR, ARRAY_INIT, ASSERT, ASSIGN, BAND, BAND_ASSIGN, BLOCK, BNOT, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, CASE_GROUP, CHAR_LITERAL, CLASS_DEF, COLON, COMMA, CTOR_CALL, CTOR_DEF, DEC, DIV, DIV_ASSIGN, DOT, ELIST, EMPTY_STAT, EOF, EQUAL, ESC, EXPONENT, EXPR, EXTENDS_CLAUSE, FINAL, FLOAT_SUFFIX, FOR_CONDITION, FOR_INIT, FOR_ITERATOR, GE, GT, HEX_DIGIT, IDENT, IMPLEMENTS_CLAUSE, IMPORT, INC, INDEX_OP, INSTANCE_INIT, INTERFACE_DEF, LABELED_STAT, LAND, LBRACK, LCURLY, LE, 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_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, RPAREN, SEMI, SL, SL_ASSIGN, SL_COMMENT, SLIST, SR, SR_ASSIGN, STAR, STAR_ASSIGN, STATIC_INIT, STRICTFP, STRING_LITERAL, SUPER_CTOR_CALL, TYPE, TYPECAST, UNARY_MINUS, UNARY_PLUS, VARIABLE_DEF, VOCAB, WS |
Methods inherited from class antlr.Parser |
addMessageListener, addParserListener, addParserMatchListener, addParserTokenListener, addSemanticPredicateListener, addSyntacticPredicateListener, addTraceListener, consumeUntil, consumeUntil, defaultDebuggingSetup, getAST, getASTFactory, getFilename, getInputState, getTokenName, getTokenNames, isDebugMode, mark, match, match, matchNot, panic, removeMessageListener, removeParserListener, removeParserMatchListener, removeParserTokenListener, removeSemanticPredicateListener, removeSyntacticPredicateListener, removeTraceListener, reportError, reportError, reportWarning, rewind, setASTFactory, setASTNodeClass, setASTNodeType, setDebugMode, setFilename, setIgnoreInvalidDebugCalls, setInputState, setTokenBuffer, traceIndent |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
escapedSourceURL
java.lang.String escapedSourceURL
escapedXmlURL
java.lang.String escapedXmlURL
staticClass
public static boolean staticClass
staticMod
public static boolean staticMod
outerClassName
java.lang.String outerClassName
innerClassName
java.lang.String innerClassName
classMethodNo
int classMethodNo
methodLevel
int methodLevel
methodNo
int methodNo
rjce_classNo
int rjce_classNo
indenting
static final java.lang.String[] indenting
outputBuffers
OutputBuffer outputBuffers
imports
java.util.List imports
doneImports
boolean doneImports
parametersList
java.util.List parametersList
_tokenNames
public static final java.lang.String[] _tokenNames
_tokenSet_0
public static final BitSet _tokenSet_0
_tokenSet_1
public static final BitSet _tokenSet_1
_tokenSet_2
public static final BitSet _tokenSet_2
_tokenSet_3
public static final BitSet _tokenSet_3
_tokenSet_4
public static final BitSet _tokenSet_4
_tokenSet_5
public static final BitSet _tokenSet_5
_tokenSet_6
public static final BitSet _tokenSet_6
_tokenSet_7
public static final BitSet _tokenSet_7
_tokenSet_8
public static final BitSet _tokenSet_8
_tokenSet_9
public static final BitSet _tokenSet_9
_tokenSet_10
public static final BitSet _tokenSet_10
_tokenSet_11
public static final BitSet _tokenSet_11
_tokenSet_12
public static final BitSet _tokenSet_12
_tokenSet_13
public static final BitSet _tokenSet_13
_tokenSet_14
public static final BitSet _tokenSet_14
_tokenSet_15
public static final BitSet _tokenSet_15
_tokenSet_16
public static final BitSet _tokenSet_16
_tokenSet_17
public static final BitSet _tokenSet_17
_tokenSet_18
public static final BitSet _tokenSet_18
_tokenSet_19
public static final BitSet _tokenSet_19
_tokenSet_20
public static final BitSet _tokenSet_20
_tokenSet_21
public static final BitSet _tokenSet_21
_tokenSet_22
public static final BitSet _tokenSet_22
_tokenSet_23
public static final BitSet _tokenSet_23
_tokenSet_24
public static final BitSet _tokenSet_24
_tokenSet_25
public static final BitSet _tokenSet_25
_tokenSet_26
public static final BitSet _tokenSet_26
_tokenSet_27
public static final BitSet _tokenSet_27
_tokenSet_28
public static final BitSet _tokenSet_28
JavaRecognizer
protected JavaRecognizer(TokenBuffer tokenBuf,
int k)
JavaRecognizer
public JavaRecognizer(TokenBuffer tokenBuf)
JavaRecognizer
protected JavaRecognizer(TokenStream lexer,
int k)
JavaRecognizer
public JavaRecognizer(TokenStream lexer)
JavaRecognizer
public JavaRecognizer(ParserSharedInputState state)
compilationUnit
public final void compilationUnit(java.lang.String sourceURL,
java.lang.String xmlURL)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
packageDefinition
public final void packageDefinition()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
importDefinition
public final void importDefinition()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
typeDefinition
public final void typeDefinition(boolean fileLevelTypeDefinition)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
identifier
public final java.lang.String identifier(java.lang.StringBuffer returnType)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
identifierStar
public final void identifierStar(java.lang.StringBuffer importName)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
modifiers
public final void modifiers(java.lang.StringBuffer modifiersBuffer)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
classDefinition
public final void classDefinition(boolean fileLevelTypeDefinition)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
interfaceDefinition
public final void interfaceDefinition()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
declaration
public final void declaration()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
typeSpec
public final java.lang.String typeSpec(java.lang.StringBuffer returnType)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
variableDefinitions
public final void variableDefinitions()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
classTypeSpec
public final java.lang.String classTypeSpec(java.lang.StringBuffer returnType)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
builtInTypeSpec
public final java.lang.String builtInTypeSpec(java.lang.StringBuffer returnType)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
builtInType
public final java.lang.String builtInType(java.lang.StringBuffer returnType)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
type
public final void type()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
spacedIdentifierToken
public final java.lang.String spacedIdentifierToken(java.lang.StringBuffer returnType)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
identifierToken
public final java.lang.String identifierToken(java.lang.StringBuffer returnType)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
modifier
public final void modifier(java.lang.StringBuffer modifiersBuffer)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
superClassClause
public final void superClassClause()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
implementsClause
public final void implementsClause(boolean fileLevelTypeDefinition)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
classBlock
public final void classBlock(boolean fileLevelTypeDefinition,
boolean isInterface,
boolean anonymousClass)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
interfaceExtends
public final void interfaceExtends()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
field
public final void field(boolean fileLevelTypeDefinition,
boolean anonymousClass)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
ctorHead
public final void ctorHead()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
constructorBody
public final void constructorBody()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
parameterDeclarationList
public final java.lang.StringBuffer parameterDeclarationList(boolean recordParameters)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
declaratorBrackets
public final void declaratorBrackets()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
throwsClause
public final void throwsClause()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
compoundStatement
public final void compoundStatement(java.lang.String methodName,
boolean fileLevelTypeDefinition,
boolean anonymousClass,
int methodNo,
java.lang.StringBuffer modifier,
java.lang.StringBuffer typeBuffer)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
explicitConstructorInvocation
public final void explicitConstructorInvocation()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
statement
public final void statement(boolean fileLevelTypeDefinition)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
argList
public final void argList()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
postfixExpression
public final void postfixExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
variableDeclarator
public final void variableDeclarator()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
varInitializer
public final void varInitializer()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
initializer
public final void initializer()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
arrayInitializer
public final void arrayInitializer()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
expression
public final void expression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
parameterDeclaration
public final java.lang.String parameterDeclaration(boolean recordParameters)
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
parameterModifier
public final void parameterModifier()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
forInit
public final void forInit()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
forCond
public final void forCond()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
forIter
public final void forIter()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
casesGroup
public final void casesGroup()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
tryBlock
public final void tryBlock()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
aCase
public final void aCase()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
caseSList
public final void caseSList()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
expressionList
public final void expressionList()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
handler
public final void handler()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
assignmentExpression
public final void assignmentExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
conditionalExpression
public final void conditionalExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
logicalOrExpression
public final void logicalOrExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
logicalAndExpression
public final void logicalAndExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
inclusiveOrExpression
public final void inclusiveOrExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
exclusiveOrExpression
public final void exclusiveOrExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
andExpression
public final void andExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
equalityExpression
public final void equalityExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
relationalExpression
public final void relationalExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
shiftExpression
public final void shiftExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
additiveExpression
public final void additiveExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
multiplicativeExpression
public final void multiplicativeExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
unaryExpression
public final void unaryExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
unaryExpressionNotPlusMinus
public final void unaryExpressionNotPlusMinus()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
primaryExpression
public final void primaryExpression()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
newExpression
public final void newExpression()
throws RecognitionException,
TokenStreamException
- object instantiation.
Trees are built as illustrated by the following input/tree pairs:
new T()
new
|
T -- ELIST
|
arg1 -- arg2 -- .. -- argn
new int[]
new
|
int -- ARRAY_DECLARATOR
new int[] {1,2}
new
|
int -- ARRAY_DECLARATOR -- ARRAY_INIT
|
EXPR -- EXPR
| |
1 2
new int[3]
new
|
int -- ARRAY_DECLARATOR
|
EXPR
|
3
new int[1][2]
new
|
int -- ARRAY_DECLARATOR
|
ARRAY_DECLARATOR -- EXPR
| |
EXPR 1
|
2
RecognitionException
TokenStreamException
identPrimary
public final void identPrimary()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
constant
public final void constant()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
newArrayDeclarator
public final void newArrayDeclarator()
throws RecognitionException,
TokenStreamException
RecognitionException
TokenStreamException
mk_tokenSet_0
private static final long[] mk_tokenSet_0()
mk_tokenSet_1
private static final long[] mk_tokenSet_1()
mk_tokenSet_2
private static final long[] mk_tokenSet_2()
mk_tokenSet_3
private static final long[] mk_tokenSet_3()
mk_tokenSet_4
private static final long[] mk_tokenSet_4()
mk_tokenSet_5
private static final long[] mk_tokenSet_5()
mk_tokenSet_6
private static final long[] mk_tokenSet_6()
mk_tokenSet_7
private static final long[] mk_tokenSet_7()
mk_tokenSet_8
private static final long[] mk_tokenSet_8()
mk_tokenSet_9
private static final long[] mk_tokenSet_9()
mk_tokenSet_10
private static final long[] mk_tokenSet_10()
mk_tokenSet_11
private static final long[] mk_tokenSet_11()
mk_tokenSet_12
private static final long[] mk_tokenSet_12()
mk_tokenSet_13
private static final long[] mk_tokenSet_13()
mk_tokenSet_14
private static final long[] mk_tokenSet_14()
mk_tokenSet_15
private static final long[] mk_tokenSet_15()
mk_tokenSet_16
private static final long[] mk_tokenSet_16()
mk_tokenSet_17
private static final long[] mk_tokenSet_17()
mk_tokenSet_18
private static final long[] mk_tokenSet_18()
mk_tokenSet_19
private static final long[] mk_tokenSet_19()
mk_tokenSet_20
private static final long[] mk_tokenSet_20()
mk_tokenSet_21
private static final long[] mk_tokenSet_21()
mk_tokenSet_22
private static final long[] mk_tokenSet_22()
mk_tokenSet_23
private static final long[] mk_tokenSet_23()
mk_tokenSet_24
private static final long[] mk_tokenSet_24()
mk_tokenSet_25
private static final long[] mk_tokenSet_25()
mk_tokenSet_26
private static final long[] mk_tokenSet_26()
mk_tokenSet_27
private static final long[] mk_tokenSet_27()
mk_tokenSet_28
private static final long[] mk_tokenSet_28()