use of org.whole.lang.grammars.model.NonTerminal in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testProduct3.
@Test
public void testProduct3() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("testProduct3");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
int count = 0;
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(pe1, g, bm)) {
String vname = ((NonTerminal) bm.wGet("name1")).getValue() + "x" + ((NonTerminal) bm.wGet("name2")).getValue();
String tname = tuple.wGet(0).wStringValue() + "x" + tuple.wGet(1).wStringValue();
Assert.assertEquals(vname, tname);
count++;
}
Assert.assertEquals(g.getPhraseStructure().wSize() * g.getPhraseStructure().wSize(), count);
}
use of org.whole.lang.grammars.model.NonTerminal in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testSingleVariableTestInPathExpPredicateOfPathInternalStep.
@Test
public void testSingleVariableTestInPathExpPredicateOfPathInternalStep() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("findAllNonTerminalsUsed");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
// FIXME bm.wDefValue("pname", "Element");
bm.wDef("pname", GrammarsEntityFactory.instance.createNonTerminal("IName"));
int count = 0;
for (NonTerminal nt : BehaviorUtils.<NonTerminal>compileAndLazyEvaluate(pe1, g, bm)) count++;
Assert.assertEquals(4, count);
}
use of org.whole.lang.grammars.model.NonTerminal in project whole by wholeplatform.
the class SelectQueriesTest method testSelectPathExpression2.
@Test
public void testSelectPathExpression2() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar model = new TestXmlGrammar().create();
PathExpression query = (PathExpression) tm.create("selectPath2");
StringBuilder names = new StringBuilder();
for (NonTerminal nt : BehaviorUtils.<NonTerminal>compileAndLazyEvaluate(query, model)) names.append(nt.getValue());
assertEquals("DocumentElementINameIContent", names.toString());
}
use of org.whole.lang.grammars.model.NonTerminal in project whole by wholeplatform.
the class SelectQueriesTest method testSelectPathExpression1.
@Test
public void testSelectPathExpression1() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("selectPath1");
StringBuilder names = new StringBuilder();
for (NonTerminal nt : BehaviorUtils.<NonTerminal>compileAndLazyEvaluate(pe1, g)) names.append(nt.getValue());
assertEquals("DocumentElementINameIContent", names.toString());
}
use of org.whole.lang.grammars.model.NonTerminal in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTuple1.
@Test
public void testSelectTuple1() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("selectTuple1");
int count = 0;
for (IEntity t : BehaviorUtils.compileAndLazyEvaluate(pe1, g)) {
NonTerminal name = (NonTerminal) t.wGet(0);
Rule rule = (Rule) t.wGet(1);
Production prod = (Production) t.wGet(2);
assertEquals(name, prod.getName());
assertSame(rule, prod.getRule());
assertEquals(g.getName(), t.wGet(3));
count++;
}
assertEquals(g.getPhraseStructure().wSize(), count);
}
Aggregations