JML

org.multijava.mjc
Class ParserUtility

java.lang.Object
  extended byorg.multijava.mjc.ParserUtility
All Implemented Interfaces:
TroubleReporter
Direct Known Subclasses:
JmlParserUtility

public class ParserUtility
extends Object
implements TroubleReporter

This class is delegated to my the parser classes and provides a place to encapsulate the utility methods of those classes.


Field Summary
 boolean allowGeneric
          Indicates whether generics syntax should be recognized.
 boolean allowMultiJava
          Indicates whether multijava syntax should be recognized.
 boolean allowRelaxedMultiJava
          Indicates whether relaxed multijava syntax should be recognized.
 boolean allowUniverseKeywords
          WMD Indicates whether universe type modifier syntax should be recognized.
protected  Main compiler
           
 boolean parseJavadocs
          Indicates whether javadoc comments should be parsed.
protected  ParsingController parsingController
          manages parsing of nested language features (like javadoc comments)
 
Constructor Summary
ParserUtility(Main compiler, ParsingController parsingController, boolean allowGeneric, boolean allowMultiJava, boolean allowRelaxedMultiJava, boolean allowUniverseKeywords, boolean parseJavadocs)
           
 
Method Summary
 PositionedError beautifyParserError(antlr.ANTLRException e)
          Returns an exception from our exception hierarchy by wrapping the ANTLR excepton.
 TokenReference buildTokenReference()
          Constructs a token reference (i.e., a source code position marker) for annotating the abstract syntax tree.
 TokenReference buildTokenReference(antlr.Token tok)
          Constructs a token reference (i.e., a source code position marker) for annotating the abstract syntax tree.
 TokenReference buildTokenReference(ParsingController.TokenWrapper wrap)
          Constructs a token reference (i.e., a source code position marker) for annotating the abstract syntax tree.
 void flushJavadocTokensWithWarning(antlr.Token tok)
          Flushes the javadoc token buffer of all javadoc tokens preceding the given token.
 void flushJavadocTokensWithWarning(ParsingController.TokenWrapper index)
          Flushes the javadoc token buffer of all javadoc tokens preceding the given token.
 Main getCompiler()
          Returns the compiler that instantiated the parser.
 JavadocComment getJavadocComment(antlr.Token tok)
          Supplies an AST for the javadoc style comment preceding the given token.
 JavadocComment getJavadocComment(ParsingController.TokenWrapper declStart)
          Supplies an AST for the javadoc style comment preceding the given token.
 String getModifierName(long mod)
          Returns the name of the modifier according to the ModifierUtility of the compiler used to instantiate this.
 String getModifierNames(long mods)
          Returns the names of the modifiers according to the ModifierUtility of the compiler used to instantiate this.
 JavaStyleComment[] getStatementComment()
          Returns the non-Javadoc comments preceding the current lookahead token.
 int getUnmatchedTypeLT()
          get the value of unmatchedTypeLT, from the ParsingController
 boolean modifiersInPreferredOrder(long prevMods, long mod)
          Returns the true if the modifiers are in the preferred order according to the ModifierUtility of the compiler used to instantiate this.
 void reportTrouble(Exception trouble)
          Reports that an error has been detected in the lexical analyser.
 void setUnmatchedTypeLT(int count)
          set the value of unmatchedTypeLT, from the ParsingController
 void wrapIfEmptyNonNullWrapper(ParsingController.TokenWrapper wrapper, antlr.Token tok)
          If the given wrapper reference is non-null and the wrapper is empty then wrap the given token in the wrapper.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compiler

protected Main compiler

parsingController

protected ParsingController parsingController
manages parsing of nested language features (like javadoc comments)


allowMultiJava

public final boolean allowMultiJava
Indicates whether multijava syntax should be recognized.


allowGeneric

public final boolean allowGeneric
Indicates whether generics syntax should be recognized.


allowRelaxedMultiJava

public final boolean allowRelaxedMultiJava
Indicates whether relaxed multijava syntax should be recognized.


allowUniverseKeywords

public final boolean allowUniverseKeywords
WMD Indicates whether universe type modifier syntax should be recognized.


parseJavadocs

public final boolean parseJavadocs
Indicates whether javadoc comments should be parsed.

Constructor Detail

ParserUtility

public ParserUtility(Main compiler,
                     ParsingController parsingController,
                     boolean allowGeneric,
                     boolean allowMultiJava,
                     boolean allowRelaxedMultiJava,
                     boolean allowUniverseKeywords,
                     boolean parseJavadocs)
Method Detail

getCompiler

public final Main getCompiler()
Returns the compiler that instantiated the parser.


buildTokenReference

public final TokenReference buildTokenReference()
Constructs a token reference (i.e., a source code position marker) for annotating the abstract syntax tree.


buildTokenReference

public final TokenReference buildTokenReference(antlr.Token tok)
Constructs a token reference (i.e., a source code position marker) for annotating the abstract syntax tree. This is more efficient than the no-argument version.

Parameters:
tok - A token from which the row and column will be extracted

buildTokenReference

public final TokenReference buildTokenReference(ParsingController.TokenWrapper wrap)
Constructs a token reference (i.e., a source code position marker) for annotating the abstract syntax tree. This is more efficient than the no-argument version.

Parameters:
wrap - A wrapped token from which the row and column will be extracted

 requires wrap.unwrap() != null;
 

getStatementComment

public final JavaStyleComment[] getStatementComment()
Returns the non-Javadoc comments preceding the current lookahead token.


getJavadocComment

public final JavadocComment getJavadocComment(ParsingController.TokenWrapper declStart)
                                       throws antlr.TokenStreamException,
                                              antlr.RecognitionException
Supplies an AST for the javadoc style comment preceding the given token.

Throws:
antlr.TokenStreamException
antlr.RecognitionException

getJavadocComment

public JavadocComment getJavadocComment(antlr.Token tok)
                                 throws antlr.TokenStreamException,
                                        antlr.RecognitionException
Supplies an AST for the javadoc style comment preceding the given token.

Throws:
antlr.TokenStreamException
antlr.RecognitionException

flushJavadocTokensWithWarning

public final void flushJavadocTokensWithWarning(ParsingController.TokenWrapper index)
                                         throws antlr.TokenStreamException
Flushes the javadoc token buffer of all javadoc tokens preceding the given token. Issues a warning if any tokens were flushed.

Throws:
antlr.TokenStreamException

flushJavadocTokensWithWarning

public final void flushJavadocTokensWithWarning(antlr.Token tok)
                                         throws antlr.TokenStreamException
Flushes the javadoc token buffer of all javadoc tokens preceding the given token. Issues a warning if any tokens were flushed.

Throws:
antlr.TokenStreamException

wrapIfEmptyNonNullWrapper

public final void wrapIfEmptyNonNullWrapper(ParsingController.TokenWrapper wrapper,
                                            antlr.Token tok)
If the given wrapper reference is non-null and the wrapper is empty then wrap the given token in the wrapper.


reportTrouble

public final void reportTrouble(Exception trouble)
Reports that an error has been detected in the lexical analyser. The handling is delegated to the compiler driver.

Specified by:
reportTrouble in interface TroubleReporter
Parameters:
trouble - the error to report

beautifyParserError

public final PositionedError beautifyParserError(antlr.ANTLRException e)
Returns an exception from our exception hierarchy by wrapping the ANTLR excepton. The exception is really positioned, by the positioning information is embedded in the message.


getModifierName

public final String getModifierName(long mod)
Returns the name of the modifier according to the ModifierUtility of the compiler used to instantiate this.

See Also:
org.multijava.util.compiler.ModifierUtility#nameOf(int)

getModifierNames

public final String getModifierNames(long mods)
Returns the names of the modifiers according to the ModifierUtility of the compiler used to instantiate this.

See Also:
org.multijava.util.compiler.ModifierUtility#asString(int)

modifiersInPreferredOrder

public final boolean modifiersInPreferredOrder(long prevMods,
                                               long mod)
Returns the true if the modifiers are in the preferred order according to the ModifierUtility of the compiler used to instantiate this.

See Also:
org.multijava.util.compiler.ModifierUtility#inPreferredOrder(int,int)

getUnmatchedTypeLT

public int getUnmatchedTypeLT()
get the value of unmatchedTypeLT, from the ParsingController


setUnmatchedTypeLT

public void setUnmatchedTypeLT(int count)
set the value of unmatchedTypeLT, from the ParsingController


JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.