use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class ControlQueriesTest method testCall1.
// TODO choose5
@Test
public void testCall1() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("call1");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
count++;
}
assertEquals(16, count);
}
use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class ControlQueriesTest method testCall2.
@Test
public void testCall2() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("call2");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.NonTerminal, p));
count++;
}
assertEquals(16, count);
}
use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class ControlQueriesTest method testCall5.
@Test
public void testCall5() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("call5");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
count++;
}
assertEquals(4, count);
}
use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testOnePredicate.
@Test
public void testOnePredicate() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("exactlyOneDefUse");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
IEntityIterator<Production> iterator = BehaviorUtils.<Production>compileAndLazyEvaluate(pe1, g, bm);
Assert.assertTrue(iterator.hasNext());
Production p = iterator.next();
Assert.assertEquals("IName", p.getName().getValue());
Assert.assertFalse(iterator.hasNext());
}
use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testVariableJoinTest2.
@Test
public void testVariableJoinTest2() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new QueriesGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("recursiveProduction2");
StringBuilder names = new StringBuilder();
for (Production p : BehaviorUtils.<Production>compileAndLazyEvaluate(pe1, g)) names.append(p.getName().getValue());
Assert.assertEquals("ExpressionPathExpressionStepExpressionPredicate", names.toString());
}
Aggregations