Package net.sf.lapg.test

Examples of net.sf.lapg.test.TestNotifier


    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(
        "syntax_cs,3: symbol `error` is useless\n" + "syntax_cs,44: symbol `Lfixed` is useless\n"
            + "syntax_cs,76: symbol `Lstackalloc` is useless\n"
            + "syntax_cs,149: symbol `comment` is useless\n"
            + "syntax_cs,155: symbol `'/*'` is useless\n"
            + "syntax_cs,157: symbol `anysym1` is useless\n"
            + "syntax_cs,159: symbol `'*/'` is useless\n",

        "syntax_cs,481: input: using_directivesopt attributesopt modifiersopt Lclass ID class_baseopt '{' attributesopt modifiersopt operator_declarator '{' Lif '(' expression ')' embedded_statement\n"
            + "shift/reduce conflict (next: Lelse)\n"
            + "    embedded_statement ::= Lif '(' expression ')' embedded_statement\n"
            + "\n"
            + "conflicts: 1 shift/reduce and 0 reduce/reduce\n");

    checkGenTables(g, "syntax_cs.tbl", er);
    er.assertDone();

    Assert.assertTrue(g.getTemplates().startsWith("\n//#define DEBUG_syntax"));
  }
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());
    Assert.assertEquals(" continue; ", lexems[2].getAction().getContents());

    checkGenTables(g, "syntax1.tbl", new TestNotifier());
  }
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();
    Assert.assertEquals(9, syms.length);
    Assert.assertEquals("eoi", syms[0].getName());
    Assert.assertEquals("a", syms[1].getName());
    Assert.assertEquals("b", syms[2].getName());
    Assert.assertEquals("'('", syms[3].getName());
    Assert.assertEquals("')'", syms[4].getName());
    Assert.assertEquals("input", syms[5].getName());
    Assert.assertEquals("list", syms[6].getName());
    Assert.assertEquals("item", syms[7].getName());
    Assert.assertEquals("listopt", syms[8].getName());
    Assert.assertEquals(8, g.getRules().length);
    Assert.assertEquals("  ${for a in b}..!..$$  ", g.getRules()[7].getAction().getContents());

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

TOP

Related Classes of net.sf.lapg.test.TestNotifier

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.