Search in sources :

Example 56 with BParser

use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.

the class StructuralTest method testVariablesClause.

@Test
public void testVariablesClause() throws Exception {
    final String testMachine = "MACHINE SimplyStructure\nVARIABLES aa, b, Cc\nINVARIANT aa : NAT & b : NAT & Cc : NAT\nINITIALISATION aa:=1 || b:=2 || c:=3\nEND";
    // 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)

Example 57 with BParser

use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.

the class StructuralTest method testSetsClause.

@Test
public void testSetsClause() throws Exception {
    final String testMachine = "MACHINE SimplyStructure SETS GGG; Hhh; JJ = {dada, dudu, TUTUT}; iII; kkk = {LLL} 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)

Example 58 with BParser

use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.

the class SyntaxErrorsDetectedOnTokenStreamTest method getTreeAsString.

private String getTreeAsString(final String testMachine) throws BCompoundException {
    // System.out.println("Parsing: \"" + testMachine + "\":");
    final BParser parser = new BParser("testcase");
    final Start startNode = parser.parse(testMachine, false);
    // startNode.apply(new ASTPrinter());
    final Ast2String ast2String = new Ast2String();
    startNode.apply(ast2String);
    final String string = ast2String.toString();
    // System.out.println();
    return string;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Ast2String(util.Ast2String) Ast2String(util.Ast2String)

Example 59 with BParser

use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.

the class DropHaskellRegressionTests method test.

@Test
public void test() throws BCompoundException, IOException {
    String name = "src/test/resources/parsable/InfiniteParityFunction.mch";
    BParser parser = new BParser(name);
    parser.parseFile(new File(name), false);
    String code = "not(finite({x|x>2}))";
    BParser parser2 = new BParser(name);
    parser2.getDefinitions().addDefinitions(parser.getDefinitions());
    Start parse = parser2.parse(BParser.FORMULA_PREFIX + " " + code, false, parser.getContentProvider());
    assertNotNull(parse);
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) File(java.io.File) Test(org.junit.Test)

Example 60 with BParser

use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.

the class ParseableButProblematicOnWindowsUnixLF 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) AbstractParseMachineTest(util.AbstractParseMachineTest) Test(org.junit.Test)

Aggregations

Start (de.be4.classicalb.core.parser.node.Start)63 BParser (de.be4.classicalb.core.parser.BParser)53 Test (org.junit.Test)39 File (java.io.File)23 Ast2String (util.Ast2String)21 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)18 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)11 ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)7 PrintStream (java.io.PrintStream)7 AbstractParseMachineTest (util.AbstractParseMachineTest)7 IOException (java.io.IOException)6 ASTPrinter (de.be4.classicalb.core.parser.visualisation.ASTPrinter)5 ClassicalBModel (de.prob.model.classicalb.ClassicalBModel)4 OutputStream (java.io.OutputStream)4 BLexer (de.be4.classicalb.core.parser.BLexer)3 IDefinitions (de.be4.classicalb.core.parser.IDefinitions)3 LexerException (de.be4.classicalb.core.parser.lexer.LexerException)3 EOF (de.be4.classicalb.core.parser.node.EOF)3 Token (de.be4.classicalb.core.parser.node.Token)3 ProBError (de.prob.exception.ProBError)3