Search in sources :

Example 1 with RecursiveMachineLoader

use of de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader in project probparsers by bendisposto.

the class FilePragmaTest method testFilePragma2.

@Test(expected = BCompoundException.class)
public void testFilePragma2() throws IOException, BCompoundException {
    String PATH = "src/test/resources/pragmas/filePragma/";
    String file = PATH + "Main2.mch";
    File f = new File(file);
    BParser bparser = new BParser();
    Start ast = bparser.parseFile(f, false);
    assertNotNull(ast);
    RecursiveMachineLoader rml = new RecursiveMachineLoader(PATH, bparser.getContentProvider());
    rml.loadAllMachines(f, ast, bparser.getDefinitions());
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader) Ast2String(util.Ast2String) File(java.io.File) Test(org.junit.Test)

Example 2 with RecursiveMachineLoader

use of de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader 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 3 with RecursiveMachineLoader

use of de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader in project probparsers by bendisposto.

the class AtelierBCompatibilityTest method testSysExtension.

@Test
public void testSysExtension() throws IOException, BCompoundException {
    String PATH = "src/test/resources/atelierb/sys_extension/";
    String file = PATH + "main.sys";
    File f = new File(file);
    BParser bparser = new BParser();
    Start ast = bparser.parseFile(f, false);
    assertNotNull(ast);
    RecursiveMachineLoader rml = new RecursiveMachineLoader(PATH, bparser.getContentProvider());
    rml.loadAllMachines(f, ast, bparser.getDefinitions());
}
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 4 with RecursiveMachineLoader

use of de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader in project probparsers by bendisposto.

the class FilePragmaTest method testFilePragma.

@Test
public void testFilePragma() throws IOException, BCompoundException {
    String PATH = "src/test/resources/pragmas/filePragma/";
    String file = PATH + "Main1.mch";
    File f = new File(file);
    BParser bparser = new BParser();
    Start ast = bparser.parseFile(f, false);
    assertNotNull(ast);
    RecursiveMachineLoader rml = new RecursiveMachineLoader(PATH, bparser.getContentProvider(), new ParsingBehaviour());
    rml.loadAllMachines(f, ast, bparser.getDefinitions());
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader) Ast2String(util.Ast2String) File(java.io.File) ParsingBehaviour(de.be4.classicalb.core.parser.ParsingBehaviour) Test(org.junit.Test)

Example 5 with RecursiveMachineLoader

use of de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader in project probparsers by bendisposto.

the class BParser method printASTasProlog.

public static void printASTasProlog(final PrintStream out, final BParser parser, final File bfile, final Start tree, final ParsingBehaviour parsingBehaviour, IDefinitionFileProvider contentProvider) throws BCompoundException {
    final RecursiveMachineLoader rml = new RecursiveMachineLoader(bfile.getParent(), contentProvider, parsingBehaviour);
    rml.loadAllMachines(bfile, tree, parser.getDefinitions());
    rml.printAsProlog(new PrintWriter(out));
}
Also used : RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader) PrintWriter(java.io.PrintWriter)

Aggregations

RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)11 BParser (de.be4.classicalb.core.parser.BParser)8 File (java.io.File)8 Start (de.be4.classicalb.core.parser.node.Start)7 ClassicalBModel (de.prob.model.classicalb.ClassicalBModel)4 Test (org.junit.Test)4 ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)2 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)2 StructuredPrologOutput (de.prob.prolog.output.StructuredPrologOutput)2 PrologTerm (de.prob.prolog.term.PrologTerm)2 Ast2String (util.Ast2String)2 CachingDefinitionFileProvider (de.be4.classicalb.core.parser.CachingDefinitionFileProvider)1 ProBError (de.prob.exception.ProBError)1 CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)1 ClassicalBFactory (de.prob.scripting.ClassicalBFactory)1 TLA2BException (de.tla2b.exceptions.TLA2BException)1 Translator (de.tla2bAst.Translator)1 FileNotFoundException (java.io.FileNotFoundException)1 PrintWriter (java.io.PrintWriter)1 URL (java.net.URL)1