Package net.sf.lapg.api

Examples of net.sf.lapg.api.Grammar


    sortGrammar((LiGrammar) g, go);
    checkGenTables(g, "syntax_tpl.tbl", new TestNotifier());
  }

  public void testNewLapgGrammar() {
    Grammar g = SyntaxUtil.parseSyntax("syntax_lapg", openStream("syntax_lapg", TESTCONTAINER), new TestNotifier(),
        new HashMap<String, Object>());
    Grammar go = SyntaxUtilOld.parseSyntax("syntax_lapg", openStream("syntax_lapg", TESTCONTAINER),
        new TestNotifier(), new HashMap<String, String>());
    Assert.assertNotNull(g);

    sortGrammar((LiGrammar) g, go);
    checkGenTables(g, "syntax_lapg.tbl", new TestNotifier());
View Full Code Here


    sortGrammar((LiGrammar) g, go);
    checkGenTables(g, "syntax_lapg.tbl", new TestNotifier());
  }

  public void testNewCheckCSharpGrammar() {
    Grammar g = SyntaxUtil.parseSyntax("syntax_cs", openStream("syntax_cs", TESTCONTAINER), new TestNotifier(),
        new HashMap<String, Object>());
    Grammar go = SyntaxUtilOld.parseSyntax("syntax_cs", openStream("syntax_cs", TESTCONTAINER), new TestNotifier(),
        new HashMap<String, String>());
    Assert.assertNotNull(g);
    sortGrammar((LiGrammar) g, go);

    TestNotifier er = new TestNotifier(
View Full Code Here

    Assert.assertTrue(g.getTemplates().startsWith("\n//#define DEBUG_syntax"));
  }

  public void testNewCheckSimple1() {
    Grammar g = SyntaxUtil.parseSyntax("syntax1", openStream("syntax1", TESTCONTAINER), new TestNotifier(),
        new HashMap<String, Object>());
    Assert.assertNotNull(g);
    Assert.assertEquals(0, g.getEoi().getIndex());

    Symbol[] syms = g.getSymbols();
    Assert.assertEquals(7, syms.length);
    Assert.assertEquals("eoi", syms[0].getName());
    Assert.assertEquals("identifier", syms[1].getName());
    Assert.assertEquals("Licon", syms[2].getName());
    Assert.assertEquals("_skip", syms[3].getName()); // TODO do not
    // collect skip
    // symbols
    Assert.assertEquals("input", syms[4].getName());
    Assert.assertEquals("list", syms[5].getName());
    Assert.assertEquals("list_item", syms[6].getName());

    Rule[] rules = g.getRules();
    Assert.assertEquals(5, rules.length);
    Assert.assertEquals("input", rules[0].getLeft().getName());
    Assert.assertEquals("list", rules[0].getRight()[0].getTarget().getName());
    Assert.assertEquals(1, rules[0].getRight().length);

    Lexem[] lexems = g.getLexems();
    Assert.assertEquals(3, lexems.length);
    Assert.assertEquals("@?[a-zA-Z_][A-Za-z_0-9]*", lexems[0].getRegexp());
    Assert.assertEquals("([1-9][0-9]*|0[0-7]*|0[xX][0-9a-fA-F]+)([uU](l|L|ll|LL)?|(l|L|ll|LL)[uU]?)?", lexems[1]
        .getRegexp());
    Assert.assertEquals("[\\t\\r\\n ]+", lexems[2].getRegexp());
View Full Code Here

    checkGenTables(g, "syntax1.tbl", new TestNotifier());
  }

  public void testNewCheckSimple2() {
    Grammar g = SyntaxUtil.parseSyntax("syntax2", openStream("syntax2", TESTCONTAINER), new TestNotifier(),
        new HashMap<String, Object>());
    Grammar go = SyntaxUtilOld.parseSyntax("syntax2", openStream("syntax2", TESTCONTAINER), new TestNotifier(),
        new HashMap<String, String>());
    Assert.assertNotNull(g);
    Assert.assertEquals(0, g.getEoi().getIndex());

    Symbol[] syms = g.getSymbols();
View Full Code Here

TOP

Related Classes of net.sf.lapg.api.Grammar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.