Search in sources :

Example 51 with Parser

use of de.be4.ltl.core.ctlparser.parser.Parser in project probparsers by bendisposto.

the class ByteOrderMarkTests method testParsable.

@Test
public void testParsable() throws Exception {
    final BParser parser = new BParser(machine.getName());
    Start start = parser.parseFile(machine, false);
    start.apply(new PositionTester());
    assertNotNull(start);
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) AbstractParseMachineTest(util.AbstractParseMachineTest) Test(org.junit.Test)

Example 52 with Parser

use of de.be4.ltl.core.ctlparser.parser.Parser in project probparsers by bendisposto.

the class DefinitionFilesTest method testRealFiles.

/*
	 * test with real files
	 */
@Test
public void testRealFiles() throws Exception {
    final BParser parser = new BParser("testcase");
    File machine = new File("src/test/resources/parsable/DefinitionFileTest.mch");
    parser.parseFile(machine, false);
    final IDefinitions definitions = parser.getDefinitions();
    final APredicateDefinitionDefinition def1 = (APredicateDefinitionDefinition) definitions.getDefinition("GRD2");
    assertEquals("GRD2", def1.getName().getText());
    assertEquals(0, def1.getParameters().size());
    assertTrue(def1.getRhs() instanceof PPredicate);
    final APredicateDefinitionDefinition def2 = (APredicateDefinitionDefinition) definitions.getDefinition("GRD1");
    assertEquals("GRD1", def2.getName().getText());
    assertEquals(0, def2.getParameters().size());
    assertTrue(def2.getRhs() instanceof PPredicate);
}
Also used : APredicateDefinitionDefinition(de.be4.classicalb.core.parser.node.APredicateDefinitionDefinition) IDefinitions(de.be4.classicalb.core.parser.IDefinitions) BParser(de.be4.classicalb.core.parser.BParser) PPredicate(de.be4.classicalb.core.parser.node.PPredicate) File(java.io.File) Test(org.junit.Test)

Example 53 with Parser

use of de.be4.ltl.core.ctlparser.parser.Parser in project probparsers by bendisposto.

the class DefinitionFilesTest method testOneDefinitionFile.

@Test
public void testOneDefinitionFile() throws BCompoundException {
    final String testMachine = "MACHINE Test\nDEFINITIONS \"DefFile\"; def1 == xx\nINVARIANT def2 = def3\nEND";
    final BParser parser = new BParser("testcase");
    parser.parse(testMachine, true, this);
    final IDefinitions definitions = parser.getDefinitions();
    final AExpressionDefinitionDefinition def1 = (AExpressionDefinitionDefinition) definitions.getDefinition("def1");
    assertEquals("def1", def1.getName().getText());
    assertEquals(0, def1.getParameters().size());
    assertTrue(def1.getRhs() instanceof AIdentifierExpression);
    final AExpressionDefinitionDefinition def2 = (AExpressionDefinitionDefinition) definitions.getDefinition("def2");
    assertEquals("def2", def2.getName().getText());
    assertEquals(0, def2.getParameters().size());
    assertTrue(def2.getRhs() instanceof AIdentifierExpression);
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) IDefinitions(de.be4.classicalb.core.parser.IDefinitions) AExpressionDefinitionDefinition(de.be4.classicalb.core.parser.node.AExpressionDefinitionDefinition) BParser(de.be4.classicalb.core.parser.BParser) Test(org.junit.Test)

Example 54 with Parser

use of de.be4.ltl.core.ctlparser.parser.Parser in project probparsers by bendisposto.

the class DefinitionsOrderTest method testLinearOrder.

@Test
public void testLinearOrder() throws IOException, BCompoundException {
    machine = new File(PATH + "DefinitionsOccurInLinearOrder.mch");
    final BParser parser = new BParser(machine.getName());
    Start start = parser.parseFile(machine, false);
    assertNotNull(start);
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) File(java.io.File) Test(org.junit.Test)

Example 55 with Parser

use of de.be4.ltl.core.ctlparser.parser.Parser in project probparsers by bendisposto.

the class StructuralTest method testClause1.

@Test
public void testClause1() throws Exception {
    final String testMachine = "MACHINE SimplyStructure END";
    // System.out.println("Parsing: \"" + testMachine + "\":");
    final BParser parser = new BParser("testcase");
    final Start startNode = parser.parse(testMachine, true);
    assertNotNull(startNode);
// TODO more tests
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Ast2String(util.Ast2String) Test(org.junit.Test)

Aggregations

Start (de.be4.classicalb.core.parser.node.Start)51 BParser (de.be4.classicalb.core.parser.BParser)41 Test (org.junit.Test)31 Ast2String (util.Ast2String)20 File (java.io.File)15 IOException (java.io.IOException)13 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)10 StringReader (java.io.StringReader)9 PushbackReader (java.io.PushbackReader)8 AbstractParseMachineTest (util.AbstractParseMachineTest)7 PrintStream (java.io.PrintStream)6 LexerException (de.be4.classicalb.core.parser.lexer.LexerException)5 ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)4 PreParseException (de.be4.classicalb.core.parser.exceptions.PreParseException)4 Reader (java.io.Reader)4 ArrayList (java.util.ArrayList)4 IDefinitions (de.be4.classicalb.core.parser.IDefinitions)3 NodeIdAssignment (de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment)3 Start (de.be4.eventbalg.core.parser.node.Start)3 LtlParseException (de.be4.ltl.core.parser.LtlParseException)3