use of de.neemann.digital.hdl.hgs.Parser in project Digital by hneemann.
the class ElementAttributesTest method testDataField.
/**
* Ensures that the DataField is accessible from within the template engine
*/
public void testDataField() throws IOException, ParserException, HGSEvalException {
DataField d = new DataField(5).setData(0, 1).setData(1, 7).setData(2, 4).setData(3, 8).setData(4, 2);
Context c = new Context().declareVar("d", d);
new Parser("(<? for(i:=0;i<sizeOf(d);i++) { if (i>0) print(\"-\"); print(d[i]);} ?>)").parse().execute(c);
assertEquals("(1-7-4-8-2)", c.toString());
}
use of de.neemann.digital.hdl.hgs.Parser in project Digital by hneemann.
the class ElementAttributesTest method testElementAttibutes.
/**
* Ensures that the ElementAttributes is accessible from within the template engine
*/
public void testElementAttibutes() throws IOException, ParserException, HGSEvalException {
ElementAttributes attr = new ElementAttributes().set(Keys.BITS, 5);
final Context c = new Context().declareVar("elem", attr);
new Parser("bits=<?=elem.Bits?>;").parse().execute(c);
assertEquals("bits=5;", c.toString());
}