org.jacaranda.verifier
Class PrintReporter

java.lang.Object
  extended by org.jacaranda.verifier.Reporter
      extended by org.jacaranda.verifier.PrintReporter

public class PrintReporter
extends Reporter

A Reporter that prints error messages to a PrintWriter 'err', and the result message to a PrintWriter 'out'.


Field Summary
 
Fields inherited from class org.jacaranda.verifier.Reporter
JUST_TREE, NO_TREE, spaces, TREE_WITH_ATTRIBUTES
 
Constructor Summary
PrintReporter(java.io.PrintWriter out, java.io.PrintWriter err, int debugLevel)
           
 
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.
 
Methods inherited from class org.jacaranda.verifier.Reporter
getMaxSnippetLength, getRuleInvocationStack, getTabStopColumns, howMuchTree, reportError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintReporter

public PrintReporter(java.io.PrintWriter out,
                     java.io.PrintWriter err,
                     int debugLevel)
Method Detail

debugLevel

public int debugLevel()
Description copied from class: Reporter
Return the debug level (0 to 9).

Overrides:
debugLevel in class Reporter

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)
Description copied from class: Reporter
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.

Overrides:
error in class Reporter

done

public void done(boolean passed,
                 java.lang.Throwable optFatal,
                 org.antlr.runtime.tree.Tree optTree)
Description copied from class: Reporter
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()'.

Overrides:
done in class Reporter