org.jacaranda.verifier
Class Reporter

java.lang.Object
  extended by org.jacaranda.verifier.Reporter
Direct Known Subclasses:
PrintReporter

public class Reporter
extends java.lang.Object


Field Summary
static int JUST_TREE
           
static int NO_TREE
           
protected  java.lang.String spaces
           
static int TREE_WITH_ATTRIBUTES
           
 
Constructor Summary
Reporter()
           
 
Method Summary
 int debugLevel()
          Return the debug level (0 to 9).
 void done(boolean passed, java.lang.Throwable optFatal, org.antlr.runtime.tree.Tree optTree)
          Reports that the verification completed.
 void error(java.lang.Exception e, int index, int line, int charInLine, java.lang.String snippet, int charInSnippet, java.lang.String message, java.lang.Class inClass)
          Reports an error at the given line and char-in-line.
 int getMaxSnippetLength()
          Maximum length in code units of a source snippet, default 100.
 java.util.List<java.lang.String> getRuleInvocationStack(java.lang.Throwable e, java.lang.Class inClass)
           
 int getTabStopColumns()
          Return the distance between tab stops in the source code, measured in columns.
 int howMuchTree()
          Return NO_TREE, JUST_TREE, or TREE_WITH_ATTRIBUTES, depending on how much abstract syntax tree information is wanted.
 void reportError(java.lang.Exception e, org.antlr.runtime.CharStream chars, org.antlr.runtime.BaseRecognizer recognizer)
          Call error(...) with information obtained from the exception, character stream, token, and lexer/parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_TREE

public static final int NO_TREE
See Also:
Constant Field Values

JUST_TREE

public static final int JUST_TREE
See Also:
Constant Field Values

TREE_WITH_ATTRIBUTES

public static final int TREE_WITH_ATTRIBUTES
See Also:
Constant Field Values

spaces

protected final java.lang.String spaces
Constructor Detail

Reporter

public Reporter()
Method Detail

howMuchTree

public int howMuchTree()
Return NO_TREE, JUST_TREE, or TREE_WITH_ATTRIBUTES, depending on how much abstract syntax tree information is wanted. (Requesting less information reduces memory usage.)


debugLevel

public int debugLevel()
Return the debug level (0 to 9).


getTabStopColumns

public int getTabStopColumns()
Return the distance between tab stops in the source code, measured in columns. This only affects source code display in error messages.


error

public void error(java.lang.Exception e,
                  int index,
                  int line,
                  int charInLine,
                  java.lang.String snippet,
                  int charInSnippet,
                  java.lang.String message,
                  java.lang.Class inClass)
Reports an error at the given line and char-in-line.

'e' is the exception that was thrown by ANTLR to signal the error:

'source' is the path of the source file, or null if the source is not known to have come from a file. 'index' is the code unit index of the error. 'line' is the line number of the error (1-based). 'charInLine' is the code unit index of the error in that line. Tabs are counted as one code unit. 'snippet' is a source snippet of the line containing the error, of maximum length determined by getMaxSnippetLength(). 'charInSnippet' is the code unit index of the error in 'snippet'. 'message' is a description of the error. 'inClass' is the class (JacarandaLexer or JacarandaParser) that detected the error. It may be null if the lexer or parser could not be initialized. If non-null, this can be used to get the rule invocation stack via getRuleInvocationStack(e, inClass).

To treat this error as fatal, throw new FatalException(message, e).

By default this method receives all errors from the lexer and parser. Note that the errors from a given source should be deterministic for a given version of the Jacaranda spec, but the ordering between lexer and parser errors is unspecified.


getRuleInvocationStack

public java.util.List<java.lang.String> getRuleInvocationStack(java.lang.Throwable e,
                                                               java.lang.Class inClass)

getMaxSnippetLength

public int getMaxSnippetLength()
Maximum length in code units of a source snippet, default 100.


reportError

public void reportError(java.lang.Exception e,
                        org.antlr.runtime.CharStream chars,
                        org.antlr.runtime.BaseRecognizer recognizer)
Call error(...) with information obtained from the exception, character stream, token, and lexer/parser. This should not normally need to be overridden.


done

public void done(boolean passed,
                 java.lang.Throwable optFatal,
                 org.antlr.runtime.tree.Tree optTree)
Reports that the verification completed. If 'passed' is true, then the result was a pass.

If 'optFatal' is non-null (which can only occur if 'passed' is false), there was a fatal error.

If 'optTree' is non-null, it gives the root of the ANTLR abstract syntax tree. This can be rendered as a string by 'optTree.toStringTree()', or as a .dot (graphviz) file by 'new org.antlr.runtime.tree.DOTTreeGenerator().toDOT(optTree).toString()'.