Search in sources :

Example 6 with Definitions

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

the class SyntaxErrorsDetectedOnTokenStreamTest method checkForClauseAfterConjunction.

@Test
public void checkForClauseAfterConjunction() throws Exception {
    String s = "MACHINE Definitions\nPROPERTIES\n 1=1 & VARIABLES";
    try {
        getTreeAsString(s);
        fail("& VARIABLES was not detected");
    } catch (BCompoundException e) {
        System.out.println(e.getMessage());
        assertTrue(e.getMessage().contains("& VARIABLES"));
    }
}
Also used : Ast2String(util.Ast2String) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException) Test(org.junit.Test)

Example 7 with Definitions

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

the class DefinitionsErrorsTest method checkForInvalidDefinition.

@Test
public void checkForInvalidDefinition() throws Exception {
    String s = "MACHINE Definitions \n DEFINITIONS \n foo == BEING x :=1 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("[3,15]"));
        assertTrue(e.getMessage().contains("expecting end of definition"));
    }
}
Also used : Ast2String(util.Ast2String) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException) Test(org.junit.Test)

Example 8 with Definitions

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

the class DefinitionsErrorsTest method checkForInvalidSubstitution.

@Test
public void checkForInvalidSubstitution() throws Exception {
    String s = "MACHINE Definitions \n DEFINITIONS \n foo == BEGIN\n x=1 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,3]"));
    }
}
Also used : Ast2String(util.Ast2String) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException) Test(org.junit.Test)

Example 9 with Definitions

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

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

Aggregations

Test (org.junit.Test)19 Ast2String (util.Ast2String)17 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)16 BParser (de.be4.classicalb.core.parser.BParser)6 Token (de.be4.classicalb.core.preparser.node.Token)6 PreParseException (de.be4.classicalb.core.parser.exceptions.PreParseException)5 AExpressionDefinitionDefinition (de.be4.classicalb.core.parser.node.AExpressionDefinitionDefinition)5 IDefinitions (de.be4.classicalb.core.parser.IDefinitions)4 BLexerException (de.be4.classicalb.core.parser.exceptions.BLexerException)4 HashSet (java.util.HashSet)4 Definitions (de.be4.classicalb.core.parser.Definitions)3 Start (de.be4.classicalb.core.parser.node.Start)3 TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)3 File (java.io.File)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 CheckException (de.be4.classicalb.core.parser.exceptions.CheckException)2 AIdentifierExpression (de.be4.classicalb.core.parser.node.AIdentifierExpression)2 APredicateDefinitionDefinition (de.be4.classicalb.core.parser.node.APredicateDefinitionDefinition)2 ASubstitutionDefinitionDefinition (de.be4.classicalb.core.parser.node.ASubstitutionDefinitionDefinition)2