Search in sources :

Example 26 with BCompoundException

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

the class DefinitionsErrorsTest method checkAtSymbolInDefinitions.

@Test
public void checkAtSymbolInDefinitions() throws Exception {
    String s = "MACHINE Definitions \n DEFINITIONS \n foo == BEGIN\n @ END \nEND";
    try {
        getTreeAsString(s);
        fail("Invalid substitution was not detected.");
    } catch (BCompoundException e) {
        System.out.println(e.getMessage());
        // there is no token available, hence the position is in the text
        assertTrue(e.getMessage().contains("[4,2]"));
    }
}
Also used : Ast2String(util.Ast2String) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException) Test(org.junit.Test)

Example 27 with BCompoundException

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

the class DefinitionsErrorsTest method checkForInvalidFormula.

@Test
public void checkForInvalidFormula() throws Exception {
    String s = "MACHINE Definitions \n DEFINITIONS\n foo == \n 1+; \nEND";
    try {
        getTreeAsString(s);
        fail("Invalid formula was not detected.");
    } catch (BCompoundException e) {
        System.out.println(e.getMessage());
        // there is no token available, hence the position is in the text
        assertTrue(e.getMessage().contains("[4,4]"));
    }
}
Also used : Ast2String(util.Ast2String) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException) Test(org.junit.Test)

Example 28 with BCompoundException

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

the class DefinitionsErrorsTest method checkForErrorPositionInDefinitionWithMultilineComments.

@Test
public void checkForErrorPositionInDefinitionWithMultilineComments() throws Exception {
    String s = "MACHINE Definitions \n DEFINITIONS \n foo == 1=1\n /* \n comment\n comment2\n comment3 \n */\n&& 1=1 \nEND";
    System.out.println(s);
    try {
        getTreeAsString(s);
        fail("Invalid definition was not detected.");
    } catch (BCompoundException e) {
        System.out.println(e.getMessage());
        assertTrue(e.getMessage().contains("[9,2]"));
    }
}
Also used : Ast2String(util.Ast2String) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException) Test(org.junit.Test)

Example 29 with BCompoundException

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

the class DefinitionsErrorsTest method checkForInvalidFormula3.

@Test
public void checkForInvalidFormula3() throws Exception {
    String s = "MACHINE Definitions \n DEFINITIONS\n foo(xx) == (xx : OBJECTS -->(1..card(OBJECTS))\n; \nEND";
    try {
        getTreeAsString(s);
        fail("Invalid formula was not detected.");
    } catch (BCompoundException e) {
        System.out.println(e.getMessage());
        // there is no token available, hence the position is in the text
        assertTrue(e.getMessage().contains("[4,1]"));
        assertTrue(e.getMessage().contains("expecting: ')'"));
    }
}
Also used : Ast2String(util.Ast2String) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException) Test(org.junit.Test)

Example 30 with BCompoundException

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

the class DefinitionsErrorsTest method checkForInvalidFormula2.

@Test
public void checkForInvalidFormula2() throws Exception {
    String s = "MACHINE Definitions \n DEFINITIONS\n foo == \n 1=; \nEND";
    try {
        getTreeAsString(s);
        fail("Invalid formula was not detected.");
    } catch (BCompoundException e) {
        System.out.println(e.getMessage());
        // there is no token available, hence the position is in the text
        assertTrue(e.getMessage().contains("[4,4]"));
    }
}
Also used : 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