Class CounterRule

  extended by com.veromodo.tempo.filters.rules.CounterRule
All Implemented Interfaces:
Direct Known Subclasses:

public class CounterRule
extends java.lang.Object
implements SemanticRule

Defines a SemanticRule requireing counting of nodes. for example "an expression only has one quantifier".

Semantics of Rule: Rule(n,x,S,F,P) : class(n)== X && S(n) => P(|F(n)|) Where
- |z| denotes the size of z
- n is a node
- x is a class
- S is a semantic rule to determine when The counting should start (the root of the subtree where it applies)
- F is a semantic rule to filter the nodes in the subtree where the counting occurs.
- P is a predicate on integers that tests the value of the counter.

Note how F is going to be applied on all the nodes reachable from the root n satisfying the guard (class(n)==x && S(n))

Constructor Summary
CounterRule(java.lang.Class c, BasicRule startPred, BasicRule filterPred, IntegerPredicate numPred)
Method Summary
 boolean eval(ASTNode n)
          evaluates the ASTNode n.
 java.lang.Class getNodeClass()
          provides the class of the root node which the semantic Rule is defined for.
 boolean IgnoreSubtree()
          boolean value if the subtree should be ignored.
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public CounterRule(java.lang.Class c,
                   BasicRule startPred,
                   BasicRule filterPred,
                   IntegerPredicate numPred)
Constructor. Creates a counting rule.

c - ASTNode type which the counting should start on
startPred - identifies the criteria to start a count
filterPred - identifies the criteria count a node
numPred - evaulates if the count is satifactory
Method Detail


public java.lang.Class getNodeClass()
Description copied from interface: SemanticRule
provides the class of the root node which the semantic Rule is defined for. This is used to filter when a check is executed, so that it is not performed on every node.

Specified by:
getNodeClass in interface SemanticRule
the class which counting starts on.


public boolean IgnoreSubtree()
Description copied from interface: SemanticRule
boolean value if the subtree should be ignored. This is used to to deside if the subtree should have the current set of rules applied to it.

Specified by:
IgnoreSubtree in interface SemanticRule
true if the subtree should be ignored


public boolean eval(ASTNode n)
evaluates the ASTNode n. Returns true if the ASTNode matches the counting critera, false otherwise. Reports errors if necessary.

Specified by:
eval in interface SemanticRule
n - an ASTNode to be checked.
true if the ASTNode counting matches.