Search in sources :

Example 1 with Parser

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());
}
Also used : Context(de.neemann.digital.hdl.hgs.Context) DataField(de.neemann.digital.core.memory.DataField) Parser(de.neemann.digital.hdl.hgs.Parser)

Example 2 with Parser

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());
}
Also used : Context(de.neemann.digital.hdl.hgs.Context) Parser(de.neemann.digital.hdl.hgs.Parser)

Aggregations

Context (de.neemann.digital.hdl.hgs.Context)2 Parser (de.neemann.digital.hdl.hgs.Parser)2 DataField (de.neemann.digital.core.memory.DataField)1