package com.fokkenrood.antlr;_x000D_
_x000D_
import java.util.Calendar;_x000D_
_x000D_
import com.fokkenrood.antlr.ProfielSpraakParser.ObjectContext;_x000D_
import com.fokkenrood.antlr.ProfielSpraakParser.RegelContext;_x000D_
_x000D_
_x000D_
public class AangifteDroolsListener extends ProfielSpraakBaseListener {_x000D_
	private Calendar		TODAY			= Calendar.getInstance();_x000D_
	private String			regel			= "Regel";_x000D_
	private String			regelset		= "Regelset";_x000D_
	private StringBuilder	drlWhen			= new StringBuilder();_x000D_
	private StringBuilder	drlThen			= new StringBuilder();_x000D_
_x000D_
	//	CONSTRUCTOR:_x000D_
	public AangifteDroolsListener() {_x000D_
		TODAY.set(2017, 1, 16);				// Datum voor digitaal Tijdreizen: YYYY, (MM=0-11), (DD=1-31)_x000D_
	}	// end constructor_x000D_
_x000D_
	//	GET-er:_x000D_
	public String getDRL() {_x000D_
		return (drlWhen.toString() + drlThen.toString());_x000D_
	}_x000D_
_x000D_
	_x000D_
	@Override_x000D_
	public void enterRegel(RegelContext ctx) {_x000D_
		drlWhen.setLength(0);_x000D_
		drlWhen.append("package ");_x000D_
		drlWhen.append(regelset);_x000D_
		drlWhen.append("\n\n");_x000D_
		drlWhen.append("import com.fokkenrood.drools.Aangifte;\n\n");_x000D_
		drlWhen.append("rule \"");_x000D_
		drlWhen.append(regel);_x000D_
		drlWhen.append("\"\n");_x000D_
		drlWhen.append("  when\n");_x000D_
		drlThen.setLength(0);_x000D_
		drlThen.append("\n      )\n");_x000D_
		drlThen.append("  then\n");_x000D_
	}	// end enterRegel_x000D_
_x000D_
_x000D_
	@Override_x000D_
	public void exitRegel(RegelContext ctx) {_x000D_
		drlThen.append("    $aangifte.setScore(\"");_x000D_
		drlThen.append(ctx.w.getText());_x000D_
		drlThen.append("\");\n");_x000D_
		drlThen.append("end\n");_x000D_
	}	// end exitRegel_x000D_
_x000D_
	_x000D_
	@Override_x000D_
	public void exitObject(ObjectContext ctx) {_x000D_
		drlWhen.append(drlWhen.indexOf("$aangifte") < 1 ? "    $aangifte : Aangifte(\n" : ",\n");_x000D_
		if (ctx.w1 != null) {_x000D_
			drlWhen.append("      ");_x000D_
			drlWhen.append(ctx.f.signifier);_x000D_
			drlWhen.append(" ");_x000D_
			drlWhen.append(ctx.v.operator);_x000D_
			drlWhen.append(" ");_x000D_
			drlWhen.append(ctx.w1.value);_x000D_
		}	// end if_x000D_
		if (ctx.w2 != null) {_x000D_
			drlWhen.append("      ");_x000D_
			drlWhen.append(ctx.f.signifier);_x000D_
			drlWhen.append((ctx.not != null ? " not" : ""));_x000D_
			drlWhen.append(" matches \".*(");_x000D_
			drlWhen.append(ctx.w2.getText());_x000D_
			drlWhen.append(").*\"");_x000D_
		}	// end if_x000D_
	}	// end exitObject_x000D_
	_x000D_
_x000D_
}	// end class_x000D_

// Datum voor digitaal Tijdreizen: YYYY, (MM=0-11), (DD=1-31)_x000D_
package com.fokkenrood.antlr;_x000D_
_x000D_
import java.util.Calendar;_x000D_
_x000D_
import com.fokkenrood.antlr.ProfielSpraakParser.ObjectContext;_x000D_
import com.fokkenrood.antlr.ProfielSpraakParser.RegelContext;_x000D_
_x000D_
_x000D_
public class AangifteDroolsListener extends ProfielSpraakBaseListener {_x000D_
	private Calendar		TODAY			= Calendar.getInstance();_x000D_
	private String			regel			= "Regel";_x000D_
	private String			regelset		= "Regelset";_x000D_
	private StringBuilder	drlWhen			= new StringBuilder();_x000D_
	private StringBuilder	drlThen			= new StringBuilder();_x000D_
_x000D_
	//	CONSTRUCTOR:_x000D_
	public AangifteDroolsListener() {_x000D_
		TODAY.set(2017, 1, 16);				// Datum voor<SUF>
	}	// end constructor_x000D_
_x000D_
	//	GET-er:_x000D_
	public String getDRL() {_x000D_
		return (drlWhen.toString() + drlThen.toString());_x000D_
	}_x000D_
_x000D_
	_x000D_
	@Override_x000D_
	public void enterRegel(RegelContext ctx) {_x000D_
		drlWhen.setLength(0);_x000D_
		drlWhen.append("package ");_x000D_
		drlWhen.append(regelset);_x000D_
		drlWhen.append("\n\n");_x000D_
		drlWhen.append("import com.fokkenrood.drools.Aangifte;\n\n");_x000D_
		drlWhen.append("rule \"");_x000D_
		drlWhen.append(regel);_x000D_
		drlWhen.append("\"\n");_x000D_
		drlWhen.append("  when\n");_x000D_
		drlThen.setLength(0);_x000D_
		drlThen.append("\n      )\n");_x000D_
		drlThen.append("  then\n");_x000D_
	}	// end enterRegel_x000D_
_x000D_
_x000D_
	@Override_x000D_
	public void exitRegel(RegelContext ctx) {_x000D_
		drlThen.append("    $aangifte.setScore(\"");_x000D_
		drlThen.append(ctx.w.getText());_x000D_
		drlThen.append("\");\n");_x000D_
		drlThen.append("end\n");_x000D_
	}	// end exitRegel_x000D_
_x000D_
	_x000D_
	@Override_x000D_
	public void exitObject(ObjectContext ctx) {_x000D_
		drlWhen.append(drlWhen.indexOf("$aangifte") < 1 ? "    $aangifte : Aangifte(\n" : ",\n");_x000D_
		if (ctx.w1 != null) {_x000D_
			drlWhen.append("      ");_x000D_
			drlWhen.append(ctx.f.signifier);_x000D_
			drlWhen.append(" ");_x000D_
			drlWhen.append(ctx.v.operator);_x000D_
			drlWhen.append(" ");_x000D_
			drlWhen.append(ctx.w1.value);_x000D_
		}	// end if_x000D_
		if (ctx.w2 != null) {_x000D_
			drlWhen.append("      ");_x000D_
			drlWhen.append(ctx.f.signifier);_x000D_
			drlWhen.append((ctx.not != null ? " not" : ""));_x000D_
			drlWhen.append(" matches \".*(");_x000D_
			drlWhen.append(ctx.w2.getText());_x000D_
			drlWhen.append(").*\"");_x000D_
		}	// end if_x000D_
	}	// end exitObject_x000D_
	_x000D_
_x000D_
}	// end class_x000D_
