analysis.coverage
Class Analyzer

java.lang.Object
  extended by analysis.coverage.Analyzer

public class Analyzer
extends java.lang.Object

Coverage analysis, including rule coverage or context-dependent rule coverage.

Author:
XZW

Constructor Summary
Analyzer(MyGrammar grammar)
          Creates an instance of analyzer
 
Method Summary
 boolean analyzeSentence(java.lang.String sentence)
          Parses a sentence and marks all the used productions and branches.
 int analyzeSentences(java.lang.String[] sentences)
          Analyzes the coverage of a sentence set.
 void init()
          Initializes all the productions and branches unused.
 boolean isAllBranchMark()
          Returns true if all the branches have been used
 boolean isAllProductionMark()
          Returns true if all the productions have been used
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Analyzer

public Analyzer(MyGrammar grammar)
Creates an instance of analyzer

Parameters:
grammar - the grammar for analysis
Method Detail

init

public void init()
Initializes all the productions and branches unused.


analyzeSentence

public boolean analyzeSentence(java.lang.String sentence)
Parses a sentence and marks all the used productions and branches.

Parameters:
sentence - the sentence to parse
Returns:
true if the sentence belongs to the grammar.

isAllBranchMark

public boolean isAllBranchMark()
Returns true if all the branches have been used

Returns:
true if all the branches have been used

isAllProductionMark

public boolean isAllProductionMark()
Returns true if all the productions have been used

Returns:
true if all the productions have been used

analyzeSentences

public int analyzeSentences(java.lang.String[] sentences)
Analyzes the coverage of a sentence set.

Parameters:
sentences - the sentence set to analyze
Returns:
-1 if all sentences belong to the grammar or the first index of the unaccepted sentence