Search in sources :

Example 6 with Production

use of org.whole.lang.grammars.model.Production in project whole by wholeplatform.

the class ControlQueriesTest method testCall4.

@Test
public void testCall4() {
    Grammar grammar = new TestXmlGrammar().create();
    IBindingManager bm = BindingManagerFactory.instance.createArguments();
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("call4");
    int count = 0;
    for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
        assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
        assertEquals("IContent", ((Production) p).getName().getValue());
        count++;
    }
    assertEquals(1, count);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Production(org.whole.lang.grammars.model.Production) IBindingManager(org.whole.lang.bindings.IBindingManager) ITemplateManager(org.whole.lang.templates.ITemplateManager) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) Test(org.junit.Test)

Example 7 with Production

use of org.whole.lang.grammars.model.Production in project whole by wholeplatform.

the class ControlQueriesTest method testCall6.

@Test
public void testCall6() {
    Grammar grammar = new TestXmlGrammar().create();
    IBindingManager bm = BindingManagerFactory.instance.createArguments();
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("call6");
    int count = 0;
    for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
        assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
        assertEquals("IContent", ((Production) p).getName().getValue());
        count++;
    }
    assertEquals(1, count);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Production(org.whole.lang.grammars.model.Production) IBindingManager(org.whole.lang.bindings.IBindingManager) ITemplateManager(org.whole.lang.templates.ITemplateManager) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) Test(org.junit.Test)

Example 8 with Production

use of org.whole.lang.grammars.model.Production in project whole by wholeplatform.

the class ControlQueriesTest method testCall3.

@Test
public void testCall3() {
    Grammar grammar = new TestXmlGrammar().create();
    IBindingManager bm = BindingManagerFactory.instance.createArguments();
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("call3");
    int count = 0;
    for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
        assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
        assertEquals("IContent", ((Production) p).getName().getValue());
        count++;
    }
    assertEquals(1, count);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Production(org.whole.lang.grammars.model.Production) IBindingManager(org.whole.lang.bindings.IBindingManager) ITemplateManager(org.whole.lang.templates.ITemplateManager) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) Test(org.junit.Test)

Example 9 with Production

use of org.whole.lang.grammars.model.Production in project whole by wholeplatform.

the class ControlQueriesTest method testQueryDecl2.

@Test
public void testQueryDecl2() {
    Grammar grammar = new TestXmlGrammar().create();
    IBindingManager bm = BindingManagerFactory.instance.createArguments();
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("queryDecl2");
    int count = 0;
    for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
        assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
        assertEquals("IContent", ((Production) p).getName().getValue());
        count++;
    }
    assertEquals(1, count);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Production(org.whole.lang.grammars.model.Production) IBindingManager(org.whole.lang.bindings.IBindingManager) ITemplateManager(org.whole.lang.templates.ITemplateManager) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) Test(org.junit.Test)

Example 10 with Production

use of org.whole.lang.grammars.model.Production in project whole by wholeplatform.

the class ControlQueriesTest method testQueryDecl1.

@Test
public void testQueryDecl1() {
    Grammar grammar = new TestXmlGrammar().create();
    IBindingManager bm = BindingManagerFactory.instance.createArguments();
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("queryDecl1");
    int count = 0;
    for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
        assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
        assertEquals("IContent", ((Production) p).getName().getValue());
        count++;
    }
    assertEquals(1, count);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Production(org.whole.lang.grammars.model.Production) IBindingManager(org.whole.lang.bindings.IBindingManager) ITemplateManager(org.whole.lang.templates.ITemplateManager) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) Test(org.junit.Test)

Aggregations

Production (org.whole.lang.grammars.model.Production)55 Grammar (org.whole.lang.grammars.model.Grammar)43 Test (org.junit.Test)41 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)41 ITemplateManager (org.whole.lang.templates.ITemplateManager)26 PathExpression (org.whole.lang.queries.model.PathExpression)20 QueriesGrammar (org.whole.lang.grammars.codebase.QueriesGrammar)18 IEntity (org.whole.lang.model.IEntity)18 IBindingManager (org.whole.lang.bindings.IBindingManager)14 Productions (org.whole.lang.grammars.model.Productions)13 NonTerminal (org.whole.lang.grammars.model.NonTerminal)8 HashSet (java.util.HashSet)5 ArrayList (java.util.ArrayList)3 Rule (org.whole.lang.grammars.model.Rule)3 PrettyPrinterOperation.toPrettyPrintString (org.whole.lang.operations.PrettyPrinterOperation.toPrettyPrintString)3 ModelsEntityFactory (org.whole.lang.models.factories.ModelsEntityFactory)2 ILanguageKit (org.whole.lang.reflect.ILanguageKit)2 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 Category (org.junit.experimental.categories.Category)1