Search in sources :

Example 76 with Start

use of de.be4.classicalb.core.parser.node.Start in project prob2 by bendisposto.

the class PredicateConjunctionSplitterTest method testComplexPredicates3.

@Test
public void testComplexPredicates3() throws Exception {
    Start parse = BParser.parse("#PREDICATE a=1 & ( b=1 => c = 1 & d=1) & e=1");
    PredicateConjunctionSplitter splitter = new PredicateConjunctionSplitter();
    parse.apply(splitter);
    assertEquals(3, splitter.getPredicates().size());
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Test(org.junit.Test)

Example 77 with Start

use of de.be4.classicalb.core.parser.node.Start in project prob2 by bendisposto.

the class PredicateConjunctionSplitterTest method testSinglePredicate.

@Test
public void testSinglePredicate() throws Exception {
    Start parse = BParser.parse("#PREDICATE a=1");
    PredicateConjunctionSplitter splitter = new PredicateConjunctionSplitter();
    parse.apply(splitter);
    assertEquals(1, splitter.getPredicates().size());
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Test(org.junit.Test)

Example 78 with Start

use of de.be4.classicalb.core.parser.node.Start in project prob2 by bendisposto.

the class PredicateConjunctionSplitterTest method testComplexPredicates2b.

@Test
public void testComplexPredicates2b() throws Exception {
    Start parse = BParser.parse("#PREDICATE #x.(x:NAT & x < 6) & a<6 ");
    PredicateConjunctionSplitter splitter = new PredicateConjunctionSplitter();
    parse.apply(splitter);
    assertEquals(2, splitter.getPredicates().size());
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Test(org.junit.Test)

Example 79 with Start

use of de.be4.classicalb.core.parser.node.Start in project prob2 by bendisposto.

the class TLAFactory method parseAllMachines.

/**
 * Given an {@link Start} ast, {@link File} f, and {@link BParser} bparser,
 * all machines are loaded.
 *
 * @param ast
 *            {@link Start} representing the abstract syntax tree for the
 *            machine
 * @param f
 *            {@link File} containing machine
 * @param bparser
 *            {@link BParser} for parsing
 * @return {@link RecursiveMachineLoader} rml with all loaded machines
 * @throws BCompoundException if the machines could not be loaded
 */
public RecursiveMachineLoader parseAllMachines(final Start ast, final File f, final BParser bparser) throws BCompoundException {
    final RecursiveMachineLoader rml = new RecursiveMachineLoader(f.getParent(), bparser.getContentProvider());
    rml.loadAllMachines(f, ast, bparser.getDefinitions());
    logger.trace("Done parsing '{}'", f.getAbsolutePath());
    return rml;
}
Also used : RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)

Example 80 with Start

use of de.be4.classicalb.core.parser.node.Start in project prob2 by bendisposto.

the class TLAFactory method parseFile.

/**
 * Parse a file into an AST {@link Start}.
 *
 * @param model
 *            {@link File} containing B machine
 * @param bparser
 *            {@link BParser} for parsing
 * @return {@link Start} AST after parsing model with {@link BParser}
 *         bparser
 * @throws IOException if an I/O error occurred
 * @throws BCompoundException if the file could not be parsed
 */
public Start parseFile(final File model, final BParser bparser) throws IOException, BCompoundException {
    logger.trace("Parsing main file '{}'", model.getAbsolutePath());
    Start ast = null;
    ast = bparser.parseFile(model, false);
    return ast;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start)

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