use of org.whole.lang.grammars.model.Production in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testPatternWithVariablePredicate.
@Test
public void testPatternWithVariablePredicate() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
StringBuilder names = new StringBuilder();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
IEntityIterator<Production> iterator = BehaviorUtils.<Production>compileAndLazyEvaluate((PathExpression) tm.create("path8"), g, bm);
for (Production p : iterator) {
Assert.assertEquals(bm.wStringValue("name"), p.getName().getValue());
names.append(p.getName().getValue());
}
Assert.assertEquals("VersionEncodingValueNameNameSpaceCharDataCDataSectDataCommentText", names.toString());
}
use of org.whole.lang.grammars.model.Production in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testPathWithFiltersIterator.
@Test
public void testPathWithFiltersIterator() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
Set<String> l = new HashSet<String>();
for (Production p : BehaviorUtils.<Production>compileAndLazyEvaluate((PathExpression) tm.create("path4"), g)) l.add(p.getName().getValue());
Assert.assertEquals(16, l.size());
}
use of org.whole.lang.grammars.model.Production in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testVariableJoinTest3.
@Test
public void testVariableJoinTest3() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new QueriesGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("recursiveProduction3");
StringBuilder names = new StringBuilder();
for (Production p : BehaviorUtils.<Production>compileAndLazyEvaluate(pe1, g)) names.append(p.getName().getValue());
Assert.assertEquals("ExpressionPathExpressionStepExpressionPredicate", names.toString());
}
use of org.whole.lang.grammars.model.Production in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testSingleVariableTestInPathExpPredicate.
@Test
public void testSingleVariableTestInPathExpPredicate() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
Production p = (Production) g.getPhraseStructure().wGet(1);
PathExpression pe1 = (PathExpression) tm.create("findProduction");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
// FIXME bm.wDefValue("pname", "Element");
bm.wDef("pname", GrammarsEntityFactory.instance.createNonTerminal("Element"));
IEntity p1 = BehaviorUtils.evaluateFirstResult(pe1, g, bm);
Assert.assertSame(p, p1);
bm.wDef("pname", GrammarsEntityFactory.instance.createNonTerminal("invented"));
p1 = BehaviorUtils.evaluateFirstResult(pe1, g, bm);
Assert.assertNull(p1);
}
use of org.whole.lang.grammars.model.Production in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testProduct4.
@Test
public void testProduct4() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
Productions productions = g.getPhraseStructure();
PathExpression pe1 = (PathExpression) tm.create("testProduct4");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
int count = 0;
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(pe1, g, bm)) {
Production p = (Production) productions.wGet(count++);
Assert.assertSame(p.getName(), bm.wGet("name"));
Assert.assertSame(p.getRule(), bm.wGet("rule"));
Assert.assertSame(p.getName(), tuple.wGet(0));
Assert.assertSame(p.getRule(), tuple.wGet(1));
}
Assert.assertEquals(g.getPhraseStructure().wSize(), count);
}
Aggregations