Search in sources :

Example 31 with Start

use of de.be4.ltl.core.ctlparser.node.Start in project probparsers by bendisposto.

the class UnparsableMachineTest method testParsable.

@Test(expected = BCompoundException.class)
public void testParsable() throws Exception {
    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) AbstractParseMachineTest(util.AbstractParseMachineTest) Test(org.junit.Test)

Example 32 with Start

use of de.be4.ltl.core.ctlparser.node.Start in project probparsers by bendisposto.

the class Ticket295 method ticker295.

// #x. /* comment */ (x>1000 & x<2**10)
@Test
public void ticker295() throws Exception {
    // String input = "#FORMULA #x. /* comment */ (x>1000 & x<2**10)";
    String input1 = "#FORMULA #x. /*buh */ (  x>1000 & x<2**10)";
    String input2 = "#FORMULA #x.(/*buh */ x>1000 & x<2**10)";
    DefinitionTypes defTypes1 = new DefinitionTypes();
    final BLexer lexer1 = new BLexer(new PushbackReader(new StringReader(input1), 99), defTypes1, input1.length());
    DefinitionTypes defTypes2 = new DefinitionTypes();
    final BLexer lexer2 = new BLexer(new PushbackReader(new StringReader(input2), 99), defTypes2, input2.length());
    Parser parser1 = new Parser(lexer1);
    Parser parser2 = new Parser(lexer2);
    final Start rootNode1 = parser1.parse();
    final Start rootNode2 = parser2.parse();
    final String result1 = getTreeAsString(rootNode1);
    final String result2 = getTreeAsString(rootNode2);
    assertNotNull(rootNode1);
    assertNotNull(rootNode2);
    assertEquals(result1, result2);
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) StringReader(java.io.StringReader) Ast2String(util.Ast2String) PushbackReader(java.io.PushbackReader) Parser(de.be4.classicalb.core.parser.parser.Parser) Test(org.junit.Test)

Example 33 with Start

use of de.be4.ltl.core.ctlparser.node.Start in project probparsers by bendisposto.

the class DefinitionsErrorsTest 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) BParser(de.be4.classicalb.core.parser.BParser) Ast2String(util.Ast2String) Ast2String(util.Ast2String)

Example 34 with Start

use of de.be4.ltl.core.ctlparser.node.Start in project probparsers by bendisposto.

the class PushbackBufferOverflows method withoutPredVars.

@Test
public void withoutPredVars() throws Exception {
    String source = "#PREDICATE procs : STRING +-> {\"waiting\",\"ready\"} & current : STRING & idle : {TRUE,FALSE} & idle = FALSE & procs /= { } & { \"waiting\" } /= { } & { \"waiting\" } /\\ ran(procs) = { } & { \"ready\" } = ran(procs)";
    BParser parser = new BParser();
    Start result = parser.parse(source, false);
    assertNotNull(result);
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) Test(org.junit.Test)

Example 35 with Start

use of de.be4.ltl.core.ctlparser.node.Start in project probparsers by bendisposto.

the class PushbackBufferOverflows method withPredVars.

@Test
public void withPredVars() throws Exception {
    String source = "#PREDICATE procs : STRING +-> {\"waiting\",\"ready\"} & current : STRING & idle : {TRUE,FALSE} & idle = FALSE & procs /= { } & { \"waiting\" } /= { } & { \"waiting\" } /\\ ran(procs) = { } & { \"ready\" } = ran(procs)";
    BParser parser = new BParser();
    Start result = parser.eparse(source, new MockedDefinitions());
    assertNotNull(result);
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) MockedDefinitions(de.be4.classicalb.core.parser.MockedDefinitions) BParser(de.be4.classicalb.core.parser.BParser) Test(org.junit.Test)

Aggregations

Start (de.be4.classicalb.core.parser.node.Start)104 Test (org.junit.Test)84 BParser (de.be4.classicalb.core.parser.BParser)43 Ast2String (util.Ast2String)32 File (java.io.File)20 Start (de.be4.eventbalg.core.parser.node.Start)19 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)18 Start (de.be4.eventb.core.parser.node.Start)18 AMachineParseUnit (de.be4.eventb.core.parser.node.AMachineParseUnit)14 AMachineParseUnit (de.be4.eventbalg.core.parser.node.AMachineParseUnit)14 IOException (java.io.IOException)12 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)11 PushbackReader (java.io.PushbackReader)11 StringReader (java.io.StringReader)11 ASTProlog (de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)8 AExpressionParseUnit (de.be4.classicalb.core.parser.node.AExpressionParseUnit)7 AbstractParseMachineTest (util.AbstractParseMachineTest)7 ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)6 ClassicalPositionPrinter (de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter)6 ASTPrinter (de.be4.classicalb.core.parser.visualisation.ASTPrinter)6