Search in sources :

Example 61 with Parser

use of de.be4.classicalb.core.parser.parser.Parser 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 62 with Parser

use of de.be4.classicalb.core.parser.parser.Parser 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)

Example 63 with Parser

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

the class StringLiteralNotClosedTest method getTreeAsString.

private String getTreeAsString(final String testMachine) throws BCompoundException {
    // System.out.println("Parsing \"" + testMachine + "\"");
    final BParser parser = new BParser("testcase");
    parser.getOptions().setGrammar(RulesGrammar.getInstance());
    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(string);
    return string;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Ast2String(util.Ast2String) Ast2String(util.Ast2String)

Example 64 with Parser

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

the class SatProblem method getTreeAsString.

private String getTreeAsString(final String testMachine) throws BCompoundException, LexerException, IOException {
    final BParser parser = new BParser("testcase");
    Start ast = parser.eparse(testMachine, new Definitions());
    final Ast2String ast2String = new Ast2String();
    ast.apply(ast2String);
    final String string = ast2String.toString();
    return string;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Definitions(de.be4.classicalb.core.parser.Definitions) BParser(de.be4.classicalb.core.parser.BParser) Ast2String(util.Ast2String) Ast2String(util.Ast2String)

Example 65 with Parser

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

the class PredVarsTest method getTreeAsString.

private String getTreeAsString(final String testMachine) throws BCompoundException, LexerException, IOException {
    final BParser parser = new BParser("testcase");
    Start ast = parser.eparse(testMachine, new Definitions());
    final Ast2String ast2String = new Ast2String();
    ast.apply(ast2String);
    final String string = ast2String.toString();
    return string;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Definitions(de.be4.classicalb.core.parser.Definitions) BParser(de.be4.classicalb.core.parser.BParser) Ast2String(util.Ast2String) Ast2String(util.Ast2String)

Aggregations

Start (de.be4.classicalb.core.parser.node.Start)51 BParser (de.be4.classicalb.core.parser.BParser)41 Test (org.junit.Test)31 Ast2String (util.Ast2String)20 File (java.io.File)15 IOException (java.io.IOException)13 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)10 StringReader (java.io.StringReader)9 PushbackReader (java.io.PushbackReader)8 AbstractParseMachineTest (util.AbstractParseMachineTest)7 PrintStream (java.io.PrintStream)6 LexerException (de.be4.classicalb.core.parser.lexer.LexerException)5 ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)4 PreParseException (de.be4.classicalb.core.parser.exceptions.PreParseException)4 Reader (java.io.Reader)4 ArrayList (java.util.ArrayList)4 IDefinitions (de.be4.classicalb.core.parser.IDefinitions)3 NodeIdAssignment (de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment)3 Start (de.be4.eventbalg.core.parser.node.Start)3 LtlParseException (de.be4.ltl.core.parser.LtlParseException)3