|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object antlr.Parser antlr.LLkParser net.mtu.eggplant.dbc.JavaRecognizer
Java parser for JonsAssert. This file is generated by Antlr.
Run 'java JonsAssert' Contributing authors: 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 pwilliams@netdynamics.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 This grammar is in the PUBLIC DOMAIN BUGS
This parser has been modified from the original Recognizer to a pre-parser that implements assertions in java as well as support JDK 1.4.
Field Summary | |
static String[] |
_tokenNames
|
static BitSet |
_tokenSet_0
|
static BitSet |
_tokenSet_1
|
static BitSet |
_tokenSet_10
|
static BitSet |
_tokenSet_11
|
static BitSet |
_tokenSet_12
|
static BitSet |
_tokenSet_13
|
static BitSet |
_tokenSet_14
|
static BitSet |
_tokenSet_15
|
static BitSet |
_tokenSet_16
|
static BitSet |
_tokenSet_17
|
static BitSet |
_tokenSet_18
|
static BitSet |
_tokenSet_19
|
static BitSet |
_tokenSet_2
|
static BitSet |
_tokenSet_20
|
static BitSet |
_tokenSet_21
|
static BitSet |
_tokenSet_3
|
static BitSet |
_tokenSet_4
|
static BitSet |
_tokenSet_5
|
static BitSet |
_tokenSet_6
|
static BitSet |
_tokenSet_7
|
static BitSet |
_tokenSet_8
|
static BitSet |
_tokenSet_9
|
Fields inherited from class antlr.Parser |
astFactory, inputState, returnAST, tokenNames, tokenTypeToASTClassMap, traceDepth |
Constructor Summary | |
|
JavaRecognizer(ParserSharedInputState state)
|
|
JavaRecognizer(TokenBuffer tokenBuf)
|
protected |
JavaRecognizer(TokenBuffer tokenBuf,
int k)
|
|
JavaRecognizer(TokenStream lexer)
|
protected |
JavaRecognizer(TokenStream lexer,
int k)
|
Method Summary | |
void |
aCase()
|
protected void |
addAsserts(List asserts,
Token jdClose)
add an assert. |
protected void |
addInvariant(Token invariant)
add invariants to this class |
void |
additiveExpression()
binary addition/subtraction (level 3) |
void |
addPostCondition(Token post)
clear out the list of postconditions. |
void |
addPreCondition(Token pre)
Add a precondition to the list of preconditions. |
void |
andExpression()
bitwise or non-short-circuiting and (&) (level 7) |
void |
argList()
|
void |
arrayInitializer()
|
void |
assertOrInvariantCondition()
Handle assert or invariant conditions, if an invariant token is seen, clear the asserts, if an assert is seen, clear the invariants. |
void |
assignmentExpression()
|
Token |
builtInType()
|
Token |
builtInTypeSpec()
|
void |
casesGroup()
|
void |
caseSList()
|
void |
classBlock(String name,
boolean isInterface,
boolean isAnonymous,
Token superclass)
This is the body of a class or interface. |
void |
classDefinition()
|
Token |
classTypeSpec()
|
protected void |
clearInvariants()
Clear the list of invariants for this class. |
void |
clearPostConditions()
clear out the list of postconditions. |
void |
clearPreConditions()
clear out the list of preconditions. |
CodePointPair |
compoundStatement()
|
void |
conditionalExpression()
|
void |
constant()
|
net.mtu.eggplant.util.Pair |
ctorHead()
This is the header of a method. |
void |
declaration()
A declaration is the creation of a reference or primitive-type variable Create a separate Type/Var tree for each var in the var list. |
void |
declaratorBrackets()
|
void |
end()
|
void |
equalityExpression()
equality/inequality (==/! |
void |
exclusiveOrExpression()
exclusive or (^) (level 8) |
void |
expression()
the mother of all expressions expressions Note that most of these expressions follow the pattern thisLevelExpression : nextHigherPrecedenceExpression (OPERATOR nextHigherPrecedenceExpression)* which is a standard recursive definition for a parsing an expression. |
void |
expressionList()
This is a list of expressions. |
void |
field()
Now the various things that can be defined inside a class or interface... |
void |
forCond()
|
void |
forInit()
|
void |
forIter()
|
protected List |
getInvariants()
get the invariants for this class. |
List |
getPostConditions()
Get the list of postconditions that have been seen since the last clear. |
List |
getPreConditions()
Get the list of preconditions that have been seen since the last clear. |
Symtab |
getSymtab()
Get the symbol table object being used. |
void |
handler()
|
Token |
identifier()
A (possibly-qualified) java identifier. |
void |
identifierStar()
Used for import statements. |
void |
implementsClause()
|
void |
importDefinition()
|
void |
inclusiveOrExpression()
bitwise or non-short-circuiting or (|) (level 9) |
void |
initializer()
|
void |
interfaceDefinition()
|
void |
interfaceExtends()
|
void |
invariantCondition()
This is a javadoc comment that we're looking for invariants in. |
void |
javadocComment()
This is a javadoc comment that we're not looking for any conditions in. |
void |
logicalAndExpression()
logical and (&&) (level 10) |
void |
logicalOrExpression()
logical or (||) (level 11) |
void |
middle()
|
Token |
modifier()
|
Set |
modifiers()
|
void |
multiplicativeExpression()
multiplication/division/modulo (level 2) |
void |
newArrayDeclarator()
|
void |
newExpression()
object instantiation. |
String |
packageDefinition()
Package statement: "package" followed by an identifier. |
net.mtu.eggplant.util.StringPair |
parameterDeclaration()
|
List |
parameterDeclarationList()
|
StringBuffer |
parameterDeclaratorBrackets()
|
void |
parameterModifier()
|
protected void |
parseImplementedInterface(Token t)
Given the id Token from the implements clause find the package the interface is defined in. |
void |
postfixExpression()
qualified names, array expressions, method invocation, post inc/dec |
void |
pre()
|
void |
prePostField()
|
void |
prePosts()
|
void |
primaryExpression()
the basic element of an expression |
void |
print(String s)
|
void |
relationalExpression()
boolean relational expressions (level 5) |
void |
returnTypeBrackersOnEndOfMethodHead()
|
void |
setSymtab(Symtab symtab)
set the symbol table object to use. |
void |
shiftExpression()
bit shift expressions (level 4) |
void |
start()
|
void |
statement()
|
Token |
superClassClause()
|
Set |
throwsClause()
|
void |
tryBlock()
|
Token |
type()
|
void |
typeDefinition()
|
Token |
typeSpec()
|
void |
unaryExpression()
|
void |
unaryExpressionNotPlusMinus()
|
void |
unit()
|
void |
uselessComments()
|
void |
variableDeclarator()
Declaration of a variable. |
void |
variableDefinitions()
|
void |
varInitializer()
|
Methods inherited from class antlr.LLkParser |
consume, LA, LT, traceIn, traceOut |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String[] _tokenNames
public static final BitSet _tokenSet_0
public static final BitSet _tokenSet_1
public static final BitSet _tokenSet_2
public static final BitSet _tokenSet_3
public static final BitSet _tokenSet_4
public static final BitSet _tokenSet_5
public static final BitSet _tokenSet_6
public static final BitSet _tokenSet_7
public static final BitSet _tokenSet_8
public static final BitSet _tokenSet_9
public static final BitSet _tokenSet_10
public static final BitSet _tokenSet_11
public static final BitSet _tokenSet_12
public static final BitSet _tokenSet_13
public static final BitSet _tokenSet_14
public static final BitSet _tokenSet_15
public static final BitSet _tokenSet_16
public static final BitSet _tokenSet_17
public static final BitSet _tokenSet_18
public static final BitSet _tokenSet_19
public static final BitSet _tokenSet_20
public static final BitSet _tokenSet_21
Constructor Detail |
protected JavaRecognizer(TokenBuffer tokenBuf, int k)
public JavaRecognizer(TokenBuffer tokenBuf)
protected JavaRecognizer(TokenStream lexer, int k)
public JavaRecognizer(TokenStream lexer)
public JavaRecognizer(ParserSharedInputState state)
Method Detail |
public void print(String s)
public void setSymtab(Symtab symtab)
public Symtab getSymtab()
protected void parseImplementedInterface(Token t)
protected void addAsserts(List asserts, Token jdClose)
asserts
- asserts, ordered as they appear in the code.protected void addInvariant(Token invariant)
protected List getInvariants()
protected void clearInvariants()
public List getPreConditions()
public void addPreCondition(Token pre)
public void clearPreConditions()
public List getPostConditions()
public void addPostCondition(Token post)
public void clearPostConditions()
public final void unit() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void pre() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void start() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void middle() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void end() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void uselessComments() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final String packageDefinition() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void importDefinition() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void invariantCondition() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void typeDefinition() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void javadocComment() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final Token identifier() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void identifierStar() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final Set modifiers() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void classDefinition() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void interfaceDefinition() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void declaration() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final Token typeSpec() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void variableDefinitions() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final Token modifier() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final Token classTypeSpec() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final Token builtInTypeSpec() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final Token builtInType() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final Token type() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final Token superClassClause() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void implementsClause() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void classBlock(String name, boolean isInterface, boolean isAnonymous, Token superclass) throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void interfaceExtends() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void prePostField() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void prePosts() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void field() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final net.mtu.eggplant.util.Pair ctorHead() throws RecognitionException, TokenStreamException
This is the header of a method. It includes the name and parameters for the method. This also watches for a list of exception classes in a "throws" clause.
this is only used for constructors so I'm just going to return the params, the method name is known
RecognitionException
TokenStreamException
public final CodePointPair compoundStatement() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final List parameterDeclarationList() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void returnTypeBrackersOnEndOfMethodHead() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final Set throwsClause() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void variableDeclarator() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void declaratorBrackets() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void varInitializer() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void initializer() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void arrayInitializer() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void expression() throws RecognitionException, TokenStreamException
expressions Note that most of these expressions follow the pattern thisLevelExpression : nextHigherPrecedenceExpression (OPERATOR nextHigherPrecedenceExpression)* which is a standard recursive definition for a parsing an expression. The operators in java have the following precedences: lowest (13) = *= /= %= += -= <<= >>= >>>= &= ^= |= (12) ?: (11) || (10) && ( 9) | ( 8) ^ ( 7) & ( 6) == != ( 5) < <= > >= ( 4) << >> ( 3) +(binary) -(binary) ( 2) * / % ( 1) ++ -- +(unary) -(unary) ~ ! (type) [] () (method call) . (dot -- identifier qualification) new () (explicit parenthesis) the last two are not usually on a precedence chart; I put them in to point out that new has a higher precedence than '.', so you can validy use new Frame().show() Note that the above precedence levels map to the rules below... Once you have a precedence chart, writing the appropriate rules as below is usually very straightfoward
RecognitionException
TokenStreamException
public final net.mtu.eggplant.util.StringPair parameterDeclaration() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void parameterModifier() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final StringBuffer parameterDeclaratorBrackets() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void assertOrInvariantCondition() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void statement() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void forInit() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void forCond() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void forIter() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void casesGroup() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void tryBlock() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void aCase() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void caseSList() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void expressionList() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void handler() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void assignmentExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void conditionalExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void logicalOrExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void logicalAndExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void inclusiveOrExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void exclusiveOrExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void andExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void equalityExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void relationalExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void shiftExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void additiveExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void multiplicativeExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void unaryExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void unaryExpressionNotPlusMinus() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void postfixExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void primaryExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void newExpression() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void argList() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void constant() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
public final void newArrayDeclarator() throws RecognitionException, TokenStreamException
RecognitionException
TokenStreamException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |