Search in sources :

Example 86 with Start

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

the class Helpers method parseFile.

public static void parseFile(final String filename) throws IOException, BCompoundException {
    final int dot = filename.lastIndexOf('.');
    if (dot >= 0) {
        final File machineFile = new File(filename);
        final String probfilename = filename.substring(0, dot) + ".prob";
        BParser parser = new BParser(filename);
        Start tree = parser.parseFile(machineFile, false);
        final ParsingBehaviour behaviour = new ParsingBehaviour();
        behaviour.setVerbose(true);
        PrintStream output = new PrintStream(probfilename);
        BParser.printASTasProlog(output, parser, machineFile, tree, behaviour, parser.getContentProvider());
        output.close();
    } else
        throw new IllegalArgumentException("Filename '" + filename + "' has no extension");
}
Also used : PrintStream(java.io.PrintStream) Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) File(java.io.File) ParsingBehaviour(de.be4.classicalb.core.parser.ParsingBehaviour)

Example 87 with Start

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

the class Helpers method getPrettyPrint.

public static String getPrettyPrint(final String testMachine) {
    final BParser parser = new BParser("testcase");
    Start startNode;
    try {
        startNode = parser.parse(testMachine, false);
    } catch (BCompoundException e) {
        throw new RuntimeException(e);
    }
    PrettyPrinter pp = new PrettyPrinter();
    startNode.apply(pp);
    return pp.getPrettyPrint();
}
Also used : PrettyPrinter(de.be4.classicalb.core.parser.util.PrettyPrinter) Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Example 88 with Start

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

the class LetPredicateTest method getTreeAsString.

private String getTreeAsString(final String testMachine) throws BCompoundException {
    final Start startNode = parser.parse(testMachine, false);
    final Ast2String ast2String = new Ast2String();
    startNode.apply(ast2String);
    return ast2String.toString();
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Ast2String(util.Ast2String)

Example 89 with Start

use of de.be4.ltl.core.parser.node.Start 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 90 with Start

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

the class PragmaMachineTest 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)

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