private static Statement convertAstToAssignStatement(ASTStatement ast, Path prefix) throws SyntaxException { // Sanity check. Ensure that this is a assignment statement. assert (ast.getStatementType() == StatementType.ASSIGN); AssignmentStatement statement = null; // Get the identifier and create the path. Resolve this against the // prefix if the given path is relative. Path path = createPathFromIdentifier(ast); path = Path.resolve(prefix, path); // Create the assignment statement. assert (ast.jjtGetNumChildren() <= 1); if (ast.jjtGetNumChildren() == 0) { // This is a delete statement. Element element = Null.VALUE; statement = AssignmentStatement.createAssignmentStatement( ast.getSourceRange(), path, element, ast.getConditionalFlag(), !ast.getFinalFlag()); } else { // This is a normal assignment statement. ASTOperation child = (ASTOperation) ast.jjtGetChild(0); Operation dml = astToDml(child, true); statement = AssignmentStatement.createAssignmentStatement( ast.getSourceRange(), path, dml, ast.getConditionalFlag(), !ast.getFinalFlag()); } return statement; }
private static Path convertAstToPrefixStatement(ASTStatement ast) throws SyntaxException { // Sanity check. assert (ast.getStatementType() == StatementType.PREFIX); if (!"".equals(ast.getIdentifier())) { // Normal path was given check that it is absolute. Path path = createPathFromIdentifier(ast); if (!path.isAbsolute()) { throw SyntaxException.create( ast.getSourceRange(), MessageUtils.MSG_PREFIX_MUST_BE_ABSOLUTE_PATH, path.toString()); } return path; } else { // Empty path was given so just return null to indicate there is no // prefix. return null; } }