dk.brics.grammar.ambiguity
Class ApproximationStrategy

java.lang.Object
  extended by dk.brics.grammar.ambiguity.ApproximationStrategy
Direct Known Subclasses:
RegularApproximation, TerminalApproximation

public abstract class ApproximationStrategy
extends Object

Abstract base class for approximation strategies.


Field Summary
protected  boolean debug
          Verbose flag.
protected  Grammar g
          Current grammar.
static HorizontalOverlapString HORIZONTAL_NOT_APPLICABLE
          Value used by checkHorizontalOverlap(Production, int) for "not applicable" responses.
protected  PrintWriter out
          Print stream for messages.
static VerticalOverlapString VERTICAL_NOT_APPLICABLE
          Value used by checkVerticalOverlap(Production, Production) for "not applicable" responses.
 
Constructor Summary
protected ApproximationStrategy()
          Abstract constructor.
 
Method Summary
protected  HorizontalOverlapString checkHorizontalOverlap(Production p, int index)
          Conservatively checks horizontal overlap in a production.
protected  VerticalOverlapString checkVerticalOverlap(Production p1, Production p2)
          Conservatively checks vertical overlap of two productions of the same nonterminal.
 HorizontalOverlapString horizontalCheck(Production p, int index)
          Conservatively checks horizontal overlap in a production.
protected  void horizontalDone()
          Invoked once per production when all its horizontal checks are done.
protected  void init()
          Initializes for the current grammar.
 void init(Grammar g, PrintWriter out, boolean debug)
          Initializes for the given grammar.
 void printStatistics(PrintWriter out)
          Prints statistics from the last analysis.
 VerticalOverlapString verticalCheck(Production p1, Production p2)
          Conservatively checks vertical overlap of two productions of the same nonterminal.
protected  void verticalDone()
          Invoked once per nonterminal when all its vertical checks are done (in the outer loop).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

protected boolean debug
Verbose flag.


g

protected Grammar g
Current grammar.


HORIZONTAL_NOT_APPLICABLE

public static final HorizontalOverlapString HORIZONTAL_NOT_APPLICABLE
Value used by checkHorizontalOverlap(Production, int) for "not applicable" responses.


out

protected PrintWriter out
Print stream for messages.


VERTICAL_NOT_APPLICABLE

public static final VerticalOverlapString VERTICAL_NOT_APPLICABLE
Value used by checkVerticalOverlap(Production, Production) for "not applicable" responses.

Constructor Detail

ApproximationStrategy

protected ApproximationStrategy()
Abstract constructor.

Method Detail

checkHorizontalOverlap

protected HorizontalOverlapString checkHorizontalOverlap(Production p,
                                                         int index)
Conservatively checks horizontal overlap in a production. This method is typically implemented in a subclass. The default implementation returns HORIZONTAL_NOT_APPLICABLE.

Parameters:
p - a production
index - division point
Returns:
potential example string in overlap, null if definitely no overlap, HORIZONTAL_NOT_APPLICABLE can be used as a "don't know" value

checkVerticalOverlap

protected VerticalOverlapString checkVerticalOverlap(Production p1,
                                                     Production p2)
Conservatively checks vertical overlap of two productions of the same nonterminal. This method is typically implemented in a subclass. The default implementation returns VERTICAL_NOT_APPLICABLE.

Parameters:
p1 - one production
p2 - another production
Returns:
potential example string in overlap, null if definitely no overlap, VERTICAL_NOT_APPLICABLE can be used as a "don't know" value

horizontalCheck

public final HorizontalOverlapString horizontalCheck(Production p,
                                                     int index)
Conservatively checks horizontal overlap in a production. This method is invoked by AmbiguityAnalyzer.

Parameters:
p - a production
index - division point
Returns:
potential example string in overlap, null if definitely no overlap, HORIZONTAL_NOT_APPLICABLE can be used as a "don't know" value

horizontalDone

protected void horizontalDone()
Invoked once per production when all its horizontal checks are done. Default implementation does nothing.


init

protected void init()
Initializes for the current grammar. This method is typically implemented in a subclass. The default implementation does nothing. The grammar is available as g.


init

public final void init(Grammar g,
                       PrintWriter out,
                       boolean debug)
Initializes for the given grammar. This method is invoked by AmbiguityAnalyzer.

Parameters:
g - current grammar
out - print writer for messages
debug - debug flag

printStatistics

public void printStatistics(PrintWriter out)
Prints statistics from the last analysis.

Parameters:
out - print writer for output

verticalCheck

public final VerticalOverlapString verticalCheck(Production p1,
                                                 Production p2)
Conservatively checks vertical overlap of two productions of the same nonterminal. This method is invoked by AmbiguityAnalyzer.

Parameters:
p1 - one production
p2 - another production
Returns:
potential example string in overlap, null if definitely no overlap, VERTICAL_NOT_APPLICABLE can be used as a "don't know" value

verticalDone

protected void verticalDone()
Invoked once per nonterminal when all its vertical checks are done (in the outer loop). Default implementation does nothing.



Copyright © 2005-2008 Anders Møller.