Search in sources :

Example 91 with BCompoundException

use of de.be4.classicalb.core.parser.exceptions.BCompoundException 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 92 with BCompoundException

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

the class ErrorMessagesTest method testKeywordAsIdentifierInUnitDeclaration.

@Test
public void testKeywordAsIdentifierInUnitDeclaration() throws Exception {
    final String testMachine = "MACHINE Test CONSTANTS /*@unit*/ right PROPERTIES right = 1 END";
    try {
        getTreeAsString(testMachine);
        fail("Invalid identifier not detected");
    } catch (BCompoundException e) {
        BParseException e1 = (BParseException) e.getFirstException().getCause();
        assertTrue(e1.getToken().getText().equals("right"));
    }
}
Also used : BParseException(de.be4.classicalb.core.parser.exceptions.BParseException) Ast2String(util.Ast2String) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException) Test(org.junit.Test)

Example 93 with BCompoundException

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

the class ErrorMessagesTest method testKeywordAsIdentifierInSigma.

@Test
public void testKeywordAsIdentifierInSigma() throws Exception {
    final String testMachine = "#EXPRESSION \nSIGMA(a, left).(a= 1& left= 2| {1} )";
    try {
        getTreeAsString(testMachine);
        fail("Invalid identifier not detected");
    } catch (BCompoundException e) {
        BParseException e1 = (BParseException) e.getFirstException().getCause();
        assertTrue(e1.getToken().getText().equals("left"));
    }
}
Also used : BParseException(de.be4.classicalb.core.parser.exceptions.BParseException) Ast2String(util.Ast2String) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException) Test(org.junit.Test)

Example 94 with BCompoundException

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

the class PrimedIdentifierTest 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 95 with BCompoundException

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

the class PrimedIdentifierTest method testDontPrimedIdentifiersInQuantifiers.

@Test
public void testDontPrimedIdentifiersInQuantifiers() {
    final String testMachine = "#PREDICATE !a$0.(a=5 => b=6)";
    try {
        getTreeAsString(testMachine);
        fail("exception expected");
    } catch (BCompoundException e) {
        assertTrue(e.getFirstException().getCause() instanceof BParseException);
    // ok
    }
}
Also used : BParseException(de.be4.classicalb.core.parser.exceptions.BParseException) Ast2String(util.Ast2String) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException) Test(org.junit.Test)

Aggregations

BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)73 Test (org.junit.Test)64 Ast2String (util.Ast2String)62 Start (de.be4.classicalb.core.parser.node.Start)52 BParser (de.be4.classicalb.core.parser.BParser)29 CheckException (de.be4.classicalb.core.parser.exceptions.CheckException)19 File (java.io.File)15 BParseException (de.be4.classicalb.core.parser.exceptions.BParseException)9 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8 ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)7 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)7 BException (de.be4.classicalb.core.parser.exceptions.BException)7 Helpers.getTreeAsString (util.Helpers.getTreeAsString)7 BLexerException (de.be4.classicalb.core.parser.exceptions.BLexerException)5 PreParseException (de.be4.classicalb.core.parser.exceptions.PreParseException)5 LexerException (de.be4.classicalb.core.parser.lexer.LexerException)5 Node (de.be4.classicalb.core.parser.node.Node)5 ASTProlog (de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)4 IPrologTermOutput (de.prob.prolog.output.IPrologTermOutput)4