| 1 | /*
|
| 2 | * BTCompilationUnitChecker.java
|
| 3 | *
|
| 4 | * Created on April 11, 2007, 7:24 PM
|
| 5 | *
|
| 6 | */
|
| 7 |
|
| 8 | package ua.gradsoft.javachecker.checkers;
|
| 9 |
|
| 10 | import ua.gradsoft.javachecker.checkers.CheckerType;
|
| 11 | import ua.gradsoft.javachecker.ConfigException;
|
| 12 | import ua.gradsoft.javachecker.JavaFacts;
|
| 13 | import ua.gradsoft.javachecker.Main;
|
| 14 | import ua.gradsoft.termware.ITermRewritingStrategy;
|
| 15 | import ua.gradsoft.termware.Term;
|
| 16 | import ua.gradsoft.termware.TermSystem;
|
| 17 | import ua.gradsoft.termware.TermWare;
|
| 18 | import ua.gradsoft.termware.TermWareException;
|
| 19 |
|
| 20 | /**
|
| 21 | *Checker with apply ruleset, according to BottomTop strategy.
|
| 22 | * @author rssh
|
| 23 | */
|
| 24 | public class BTCompilationUnitChecker extends AbstractCompilationUnitChecker
|
| 25 | {
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 | /**
|
| 30 | * Creates a new instance of BTTypeChecker
|
| 31 | */
|
| 32 | public BTCompilationUnitChecker(String name,String category,String description,Term rules, boolean enabled) throws TermWareException, ConfigException {
|
| 33 | super(name,category,description,enabled);
|
| 34 | ITermRewritingStrategy strategy = TermWare.getInstance().createStrategyByName("BottomTop");
|
| 35 | termSystem_ = new TermSystem(strategy,Main.getFacts(),TermWare.getInstance());
|
| 36 | addRuleset(termSystem_,rules);
|
| 37 | }
|
| 38 |
|
| 39 | public CheckerType getCheckerType() {
|
| 40 | return CheckerType.BT_COMPILATION_UNIT_RULESET; }
|
| 41 |
|
| 42 | public void configure(JavaFacts facts) {
|
| 43 | /* do nothing yet */
|
| 44 | }
|
| 45 |
|
| 46 | public void run(Term compilationUnitAst) throws TermWareException {
|
| 47 | Term toReduce = compilationUnitAst.termClone();
|
| 48 | termSystem_.reduce(toReduce);
|
| 49 | }
|
| 50 |
|
| 51 | private TermSystem termSystem_;
|
| 52 |
|
| 53 |
|
| 54 | }
|