use of de.be4.classicalb.core.parser.exceptions.CheckException in project probparsers by bendisposto.
the class PrimedIdentifierCheck method caseAPrimedIdentifierExpression.
@Override
public void caseAPrimedIdentifierExpression(final APrimedIdentifierExpression node) {
final String id = getIdentifier(node.getIdentifier());
final String grade = node.getGrade().getText();
if (!"0".equals(grade)) {
exceptions.add(new CheckException("construct $ only allowed with 0 (you should use " + id + "$0)", node));
}
}
use of de.be4.classicalb.core.parser.exceptions.CheckException in project probparsers by bendisposto.
the class SubstitutionTest method testParallelAssignWithNonIdentifier.
@Test
public void testParallelAssignWithNonIdentifier() throws BCompoundException {
final String testMachine = "#SUBSTITUTION xx,yy,5 := 5, 3, zz";
try {
getTreeAsString(testMachine);
fail("Expected exception");
} catch (final BCompoundException e) {
// final CheckException cause = (CheckException) e.getCause();
// assertEquals(1, cause.getNodes().length);
// assertNotNull(cause.getNodes()[0]);
}
}
use of de.be4.classicalb.core.parser.exceptions.CheckException in project probparsers by bendisposto.
the class DefinitionsTest method testParamsCount1.
@Test
public void testParamsCount1() {
final String testMachine = "MACHINE Test\nDEFINITIONS\ndefExpr(x)==g(x)\nOPERATIONS\nop=BEGIN defExpr(x); defExpr END\nEND";
try {
getTreeAsString(testMachine);
fail("Expected exception was not thrown");
} catch (final BCompoundException e) {
final CheckException cause = (CheckException) e.getCause();
assertEquals(1, cause.getNodes().length);
assertNotNull(cause.getNodes()[0]);
assertEquals("Number of parameters doesn't match declaration of definition", cause.getLocalizedMessage());
// IGNORE, is expected
}
}
use of de.be4.classicalb.core.parser.exceptions.CheckException in project probparsers by bendisposto.
the class DefinitionsTest method testExprOrSubst3.
@Test
public void testExprOrSubst3() {
final String testMachine = "MACHINE Test\nDEFINITIONS\ndefExpr==g(x)\nOPERATIONS\nop=PRE defExpr=42 THEN defExpr END\nEND";
try {
getTreeAsString(testMachine);
fail("Expected exception was not thrown");
} catch (final BCompoundException e) {
final CheckException cause = (CheckException) e.getCause();
assertEquals("Expecting substitution here but found definition with type 'Expression'", cause.getLocalizedMessage());
// IGNORE, is expected
}
}
use of de.be4.classicalb.core.parser.exceptions.CheckException in project probparsers by bendisposto.
the class DefinitionsTest method testExprOrSubst4.
@Test
public void testExprOrSubst4() {
final String testMachine = "MACHINE Test\nDEFINITIONS\ndefExpr==g(x)\nOPERATIONS\nop=BEGIN defExpr; a:=defExpr END\nEND";
try {
getTreeAsString(testMachine);
fail("Expected exception was not thrown");
} catch (final BCompoundException e) {
final CheckException cause = (CheckException) e.getCause();
assertEquals("Expecting expression here but found definition with type 'Substitution'", cause.getLocalizedMessage());
// IGNORE, is expected
}
}
Aggregations