use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class SyntaxErrorsDetectedOnTokenStreamTest method checkForDuplicateSemicolon.
@Test
public void checkForDuplicateSemicolon() throws Exception {
String s = "MACHINE DuplicateSemicolon\nOPERATIONS\n Foo = BEGIN skip END;\n ;r <-- Get = BEGIN r := xx END\nEND";
try {
getTreeAsString(s);
fail("Missing Semicolon was not detected");
} catch (BCompoundException e) {
System.out.println(e.getMessage());
assertTrue(e.getMessage().contains("Two succeeding"));
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class SyntaxErrorsDetectedOnTokenStreamTest method checkForSingleLineCommentBetweenDuplicateAnd.
@Test
public void checkForSingleLineCommentBetweenDuplicateAnd() throws Exception {
String s = "MACHINE Definitions\nPROPERTIES 1=1 & // comment 1 comment \n & 2 = 2 END";
try {
getTreeAsString(s);
fail("Duplicate & was not detected.");
} catch (BCompoundException e) {
System.out.println(e.getMessage());
assertTrue(e.getMessage().contains("& &"));
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class SyntaxErrorsDetectedOnTokenStreamTest method checkForCommentBetweenDuplicateAnd.
@Test
public void checkForCommentBetweenDuplicateAnd() throws Exception {
String s = "MACHINE Definitions\nPROPERTIES 1=1 & /* comment */\n & 2 = 2 END";
try {
getTreeAsString(s);
fail("Duplicate & was not detected.");
} catch (BCompoundException e) {
System.out.println(e.getMessage());
assertTrue(e.getMessage().contains("& &"));
final BLexerException ex = (BLexerException) e.getCause();
// checking the position of the second &
assertEquals(3, ex.getLastLine());
assertEquals(2, ex.getLastPos());
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class SyntaxErrorsDetectedOnTokenStreamTest method checkForDublicateDefinitionClause.
@Test
public void checkForDublicateDefinitionClause() throws Exception {
String s = "MACHINE Definitions \n DEFINITIONS\n foo == 1\n CONSTANTS k \n DEFINITIONS\n bar == 1 \nEND";
try {
getTreeAsString(s);
fail("Duplicate 'DEFINITION' clause was not detected.");
} catch (BCompoundException e) {
System.out.println(e.getMessage());
assertTrue(e.getMessage().contains("[5,2] Clause 'DEFINITIONS' is used more than once"));
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class SyntaxErrorsDetectedOnTokenStreamTest method checkForDublicateAndInDefinitionsClause.
@Test
public void checkForDublicateAndInDefinitionsClause() throws Exception {
String s = "MACHINE Definitions\nDEFINITIONS\n foo == 1=1 && 2=2 \nEND";
try {
getTreeAsString(s);
fail("Duplicate & 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,14]"));
assertTrue(e.getMessage().contains("& &"));
}
}
Aggregations