use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class StructuralTest method checkForMissingSemicolon.
@Test
public void checkForMissingSemicolon() throws Exception {
String s = "MACHINE MissingSemicolon\nOPERATIONS\n Foo=BEGIN skip END\n BAR= BEGIN r := xx END\nEND";
try {
getTreeAsString(s);
fail("Missing Semicolon was not detected");
} catch (BCompoundException e) {
final CheckException cause = (CheckException) e.getCause();
Node node = cause.getNodes()[0];
assertEquals(4, node.getStartPos().getLine());
assertEquals(3, node.getStartPos().getPos());
assertTrue(e.getMessage().contains("Semicolon missing"));
}
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class StructuralTest method checkForInvalidSemicolon.
@Test
public void checkForInvalidSemicolon() throws Exception {
String s = "MACHINE MissingSemicolon\nOPERATIONS\n Foo=BEGIN skip END\n;\nEND";
try {
getTreeAsString(s);
fail("Invalid Semicolon was not detected");
} catch (BCompoundException e) {
final CheckException cause = (CheckException) e.getCause();
Node node = cause.getNodes()[0];
System.out.println(cause.getMessage());
assertEquals(4, node.getStartPos().getLine());
assertEquals(1, node.getStartPos().getPos());
assertTrue(e.getMessage().contains("Invalid semicolon after last operation"));
}
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class UnitPragmaTest method printAST.
private String printAST(final Node node) {
final StringWriter swriter = new StringWriter();
NodeIdAssignment nodeids = new NodeIdAssignment();
node.apply(nodeids);
IPrologTermOutput pout = new PrologTermOutput(new PrintWriter(swriter), false);
PositionPrinter pprinter = new ClassicalPositionPrinter(nodeids);
ASTProlog prolog = new ASTProlog(pout, pprinter);
node.apply(prolog);
swriter.flush();
return swriter.toString();
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class ReferencedMachines method caseAPackageParseUnit.
@Override
public void caseAPackageParseUnit(APackageParseUnit node) {
determineRootDirectory(node.getPackage(), node);
List<PImportPackage> copy = new ArrayList<>(node.getImports());
for (PImportPackage e : copy) {
e.apply(this);
}
node.getParseUnit().apply(this);
// delete this node
node.replaceBy(node.getParseUnit());
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class ReferencedMachines method caseAMachineHeader.
@Override
public void caseAMachineHeader(AMachineHeader node) {
machineName = Utils.getTIdentifierListAsString(node.getName());
final String fileNameWithoutExtension = Utils.getFileWithoutExtension(mainFile.getName());
if (isMachineNameMustMatchFileName && !machineName.equals(fileNameWithoutExtension)) {
CheckException ch = new CheckException(String.format("Machine name does not match the file name: '%s' vs '%s'", machineName, fileNameWithoutExtension), node);
throw new VisitorException(ch);
}
}
Aggregations