You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by lr...@apache.org on 2015/12/03 19:45:50 UTC

[19/78] [abbrv] [partial] incubator-systemml git commit: Move files to new package folder structure

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/parser/DataIdentifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/parser/DataIdentifier.java b/src/main/java/com/ibm/bi/dml/parser/DataIdentifier.java
deleted file mode 100644
index 709be3f..0000000
--- a/src/main/java/com/ibm/bi/dml/parser/DataIdentifier.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package com.ibm.bi.dml.parser;
-
-
-public class DataIdentifier extends Identifier 
-{
-	
-	protected String 	_name;
-	protected String 	_valueTypeString;	
-	protected String 	_defaultValue;
-	
-	public DataIdentifier(DataIdentifier passed){
-		setProperties(passed);
-		_kind = Kind.Data;
-		_name = passed.getName();
-		_valueTypeString = passed.getValueType().toString();	
-		_defaultValue = passed.getDefaultValue();
-		
-		// set location information
-		setFilename(passed.getFilename());
-		setBeginLine(passed.getBeginLine());
-		setBeginColumn(passed.getBeginColumn());
-		setEndLine(passed.getEndLine());
-		setEndColumn(passed.getEndColumn());
-	}
-	
-	public Expression rewriteExpression(String prefix) throws LanguageException{
-		DataIdentifier newId = new DataIdentifier(this);
-		String newIdName = prefix + this._name;
-		newId.setName(newIdName);
-				
-		return newId;
-	}
-	
-	public DataIdentifier(String name){
-		super();
-		_name = name;
-		_kind = Kind.Data;
-		_defaultValue = null;
-
-	}
-	
-	/*
-	public DataIdentifier(String name, int line, int col){
-		super();
-		_name = name;
-		_kind = Kind.Data;
-		_defaultValue = null;	
-	}
-	*/
-	public DataIdentifier(){
-		_name = null;
-		_kind = null;
-		_defaultValue = null;
-	}
-	
-
-	public void setTypeInfo( String valueType, String dataType) throws ParseException{
-		
-		if (valueType.equalsIgnoreCase("int") || valueType.equalsIgnoreCase("integer"))
-			this.setValueType(ValueType.INT);
-		else if (valueType.equalsIgnoreCase("double"))
-			this.setValueType(ValueType.DOUBLE);
-		else if (valueType.equalsIgnoreCase("string"))
-			this.setValueType(ValueType.STRING);
-		else if (valueType.equalsIgnoreCase("boolean"))
-			this.setValueType(ValueType.BOOLEAN);
-		else if (valueType.equalsIgnoreCase("object"))
-			this.setValueType(ValueType.OBJECT);
-		else {
-			// provide location for this exception in the parser
-			LOG.error(this.printErrorLocation() + "function parameter has unknown value type " + valueType);
-			throw new ParseException(this.printErrorLocation() + "function parameter has unknown value type " + valueType);
-		}
-		
-		if (dataType.equalsIgnoreCase("object"))
-			this.setDataType(DataType.OBJECT);
-		else if (dataType.equalsIgnoreCase("SCALAR"))
-			this.setDataType(DataType.SCALAR);
-		else if (dataType.equalsIgnoreCase("MATRIX"))
-			this.setDataType(DataType.MATRIX);
-		else {
-			// provide location for this exception in the parser
-			LOG.error(this.printErrorLocation() + "function parameter has unknown data type " + valueType);
-			throw new ParseException(this.printErrorLocation() + "function parameter has unknown data type " + valueType);
-		}
-		
-	}
-	
-	public String getName(){
-		return _name;
-	}
-	public void setName(String name){
-		_name = name;
-	}
-	public String getDefaultValue(){
-		return _defaultValue;
-	}
-	public void setDefaultValue(String val){
-		_defaultValue = val;
-	}
-	
-	@Override
-	public String toString() {
-		return _name;
-	}
-
-	@Override
-	public VariableSet variablesRead() {
-		VariableSet result = new VariableSet();
-		result.addVariable(_name, this);
-		return result;
-	}
-
-	@Override
-	public VariableSet variablesUpdated() {
-		return null;
-	}
-	
-	/**
-	 * Method to specify if an expression returns multiple outputs.
-	 * This method must be overridden by all child classes.
-	 * @return
-	 */
-	public boolean multipleReturns() throws LanguageException {
-		throw new LanguageException("multipleReturns() must be overridden in the subclass.");
-	}
-	
-	@Override
-	public boolean equals(Object that) 
-	{
-		if( !(that instanceof DataIdentifier) )
-			return false;
-			
-		DataIdentifier target = (DataIdentifier)that;
-		if(getName()!=null && !getName().equals(target.getName()))
-			return false;
-		if(getDataType()!=null && !getDataType().equals(target.getDataType()))
-			return false;
-		if(getValueType() != null && !getValueType().equals(target.getValueType()))
-			return false;
-		if(getFormatType()!= null && !this.getFormatType().equals(target.getFormatType()))
-			return false;
-		if(!(this.getDim1() == target.getDim1()))
-			return false;
-		if(!(this.getDim2() == target.getDim2()))
-			return false;
-		
-		return true;
-		
-	}
-	
-	@Override
-	public int hashCode()
-	{
-		return super.hashCode();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/parser/DoubleIdentifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/parser/DoubleIdentifier.java b/src/main/java/com/ibm/bi/dml/parser/DoubleIdentifier.java
deleted file mode 100644
index 257f652..0000000
--- a/src/main/java/com/ibm/bi/dml/parser/DoubleIdentifier.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package com.ibm.bi.dml.parser;
-
-import com.ibm.bi.dml.runtime.util.UtilFunctions;
-
-
-
-public class DoubleIdentifier extends ConstIdentifier 
-{
-	
-	private double _val;
-	
-	
-	public DoubleIdentifier(double val, String filename, int blp, int bcp, int elp, int ecp){
-		super();
-		 _val = val;
-		_kind = Kind.Data;
-		this.setDimensions(0,0);
-        this.computeDataType();
-        this.setValueType(ValueType.DOUBLE);
-        this.setAllPositions(filename, blp, bcp, elp, ecp);
-	}
-	
-	public DoubleIdentifier(DoubleIdentifier d, String filename, int blp, int bcp, int elp, int ecp){
-		super();
-		 _val = d.getValue();
-		_kind = Kind.Data;
-		this.setDimensions(0,0);
-        this.computeDataType();
-        this.setValueType(ValueType.DOUBLE);
-        this.setAllPositions(filename, blp, bcp, elp, ecp);
-	}
-	
-	public Expression rewriteExpression(String prefix) throws LanguageException{
-		return this;
-	}
-	
-	// Used only by the parser for unary operation
-	public void multiplyByMinusOne() {
-		_val = -1 * _val;
-	}
-	
-	public double getValue(){
-		return _val;
-	}
-	
-	public void setValue(double v) {
-		_val = v;
-	}
-	
-	public String toString(){
-		return Double.toString(_val);
-	}
-	
-	@Override
-	public VariableSet variablesRead() {
-		return null;
-	}
-
-	@Override
-	public VariableSet variablesUpdated() {
-		return null;
-	}
-	
-	@Override
-	public long getLongValue() {
-		return UtilFunctions.toLong(getValue());
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/parser/Expression.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/parser/Expression.java b/src/main/java/com/ibm/bi/dml/parser/Expression.java
deleted file mode 100644
index 478b099..0000000
--- a/src/main/java/com/ibm/bi/dml/parser/Expression.java
+++ /dev/null
@@ -1,513 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package com.ibm.bi.dml.parser;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.ibm.bi.dml.hops.Hop.FileFormatTypes;
-
-
-public abstract class Expression 
-{
-	
-	public enum Kind {
-		UnaryOp, BinaryOp, BooleanOp, BuiltinFunctionOp, ParameterizedBuiltinFunctionOp, DataOp, Data, Literal, RelationalOp, ExtBuiltinFunctionOp, FunctionCallOp
-	};
-
-	public enum BinaryOp {
-		PLUS, MINUS, MULT, DIV, MODULUS, INTDIV, MATMULT, POW, INVALID
-	};
-
-	public enum RelationalOp {
-		LESSEQUAL, LESS, GREATEREQUAL, GREATER, EQUAL, NOTEQUAL, INVALID
-	};
-
-	public enum BooleanOp {
-		CONDITIONALAND, CONDITIONALOR, LOGICALAND, LOGICALOR, NOT, INVALID
-	};
-
-	public enum BuiltinFunctionOp { 
-		ABS, 
-		ACOS,
-		ASIN, 
-		ATAN,
-		AVG,
-		CAST_AS_MATRIX, 
-		CAST_AS_SCALAR,
-		CAST_AS_DOUBLE, 
-		CAST_AS_INT,
-		CAST_AS_BOOLEAN,
-		COLMEAN,
-		COLMAX,
-		COLMIN, 
-		COLSUM,
-		COS,
-		COV, 
-		CUMMAX,
-		CUMMIN,
-		CUMPROD,
-		CUMSUM,
-		DIAG,
-		EXP,
-		INTERQUANTILE, 
-		IQM, 
-		LENGTH, 
-		LOG, 
-		MAX,
-		MEAN,
-		MIN, 
-		MOMENT, 
-		NCOL, 
-		NROW,
-		OUTER,
-		PPRED, 
-		PROD,
-		QUANTILE,
-		RANGE,
-		ROUND,
-		ROWINDEXMAX, 
-		ROWMAX,
-		ROWMEAN, 
-		ROWMIN,
-		ROWINDEXMIN,
-		ROWSUM, 
-		SEQ,
-		SIN, 
-		SQRT,
-		SUM, 
-		TABLE,
-		TAN,
-		TRACE, 
-		TRANS,
-		QR,
-		LU,
-		EIGEN,
-		SOLVE,
-		CEIL,
-		FLOOR,
-		CBIND, //previously APPEND
-		RBIND,
-		MEDIAN,
-		INVERSE,
-		SAMPLE
-	};
-
-	public enum ParameterizedBuiltinFunctionOp {
-		GROUPEDAGG, RMEMPTY, REPLACE, ORDER, 
-		// Distribution Functions
-		CDF, INVCDF, PNORM, QNORM, PT, QT, PF, QF, PCHISQ, QCHISQ, PEXP, QEXP,
-		TRANSFORM, 
-		INVALID
-	};
-	
-	public enum DataOp {
-		READ, WRITE, RAND, MATRIX, INVALID	
-	}
-
-	public enum FunctCallOp {
-		INTERNAL, EXTERNAL
-	};
-	
-	public enum ExtBuiltinFunctionOp {
-		EIGEN, CHOLESKY
-	};
-
-	public enum AggOp {
-		SUM, MIN, MAX, INVALID
-	};
-
-	public enum ReorgOp {
-		TRANSPOSE, DIAG
-	};
-
-	//public enum DataOp {
-	//	READ, WRITE
-	//};
-
-	public enum DataType {
-		MATRIX, SCALAR, FRAME, OBJECT, UNKNOWN;
-		
-		public boolean isMatrix() {
-			return (this == MATRIX);
-		}
-		public boolean isScalar() {
-			return (this == SCALAR);
-		}
-	};
-
-	public enum ValueType {
-		INT, DOUBLE, STRING, BOOLEAN, OBJECT, UNKNOWN
-	};
-
-	public enum FormatType {
-		TEXT, BINARY, MM, CSV, UNKNOWN
-	};
-	
-	protected static final Log LOG = LogFactory.getLog(Expression.class.getName());
-
-	public abstract Expression rewriteExpression(String prefix) throws LanguageException;
-		
-	
-	protected Kind _kind;
-	protected Identifier[] _outputs;
-
-	private static int _tempId;
-
-	public Expression() {
-		_outputs = null;
-	}
-
-	public void setOutput(Identifier output) {
-		if ( _outputs == null) {
-			_outputs = new Identifier[1];
-		}
-		_outputs[0] = output;
-	}
-
-	public Kind getKind() {
-		return _kind;
-	}
-
-	public Identifier getOutput() {
-		if (_outputs != null && _outputs.length > 0)
-			return _outputs[0];
-		else
-			return null;
-	}
-	
-	public Identifier[] getOutputs() {
-		return _outputs;
-	}
-	
-	public void validateExpression(HashMap<String, DataIdentifier> ids, HashMap<String, ConstIdentifier> currConstVars, boolean conditional) 
-		throws LanguageException 
-	{
-		raiseValidateError("Should never be invoked in Baseclass 'Expression'", false);
-	}
-	
-	public void validateExpression(MultiAssignmentStatement mas, HashMap<String, DataIdentifier> ids, HashMap<String, ConstIdentifier> currConstVars, boolean conditional) 
-		throws LanguageException 
-	{
-		raiseValidateError("Should never be invoked in Baseclass 'Expression'", false);
-	}
-	
-	public static BinaryOp getBinaryOp(String val) {
-		if (val.equalsIgnoreCase("+"))
-			return BinaryOp.PLUS;
-		else if (val.equalsIgnoreCase("-"))
-			return BinaryOp.MINUS;
-		else if (val.equalsIgnoreCase("*"))
-			return BinaryOp.MULT;
-		else if (val.equalsIgnoreCase("/"))
-			return BinaryOp.DIV;
-		else if (val.equalsIgnoreCase("%%"))
-			return BinaryOp.MODULUS;
-		else if (val.equalsIgnoreCase("%/%"))
-			return BinaryOp.INTDIV;
-		else if (val.equalsIgnoreCase("^"))
-			return BinaryOp.POW;
-		else if (val.equalsIgnoreCase("%*%"))
-			return BinaryOp.MATMULT;
-		return BinaryOp.INVALID;
-	}
-
-	public static RelationalOp getRelationalOp(String val) {
-		if (val == null) 
-			return null;
-		else if (val.equalsIgnoreCase("<"))
-			return RelationalOp.LESS;
-		else if (val.equalsIgnoreCase("<="))
-			return RelationalOp.LESSEQUAL;
-		else if (val.equalsIgnoreCase(">"))
-			return RelationalOp.GREATER;
-		else if (val.equalsIgnoreCase(">="))
-			return RelationalOp.GREATEREQUAL;
-		else if (val.equalsIgnoreCase("=="))
-			return RelationalOp.EQUAL;
-		else if (val.equalsIgnoreCase("!="))
-			return RelationalOp.NOTEQUAL;
-		return RelationalOp.INVALID;
-	}
-
-	public static BooleanOp getBooleanOp(String val) {
-		if (val.equalsIgnoreCase("&&"))
-			return BooleanOp.CONDITIONALAND;
-		else if (val.equalsIgnoreCase("&"))
-			return BooleanOp.LOGICALAND;
-		else if (val.equalsIgnoreCase("||"))
-			return BooleanOp.CONDITIONALOR;
-		else if (val.equalsIgnoreCase("|"))
-			return BooleanOp.LOGICALOR;
-		else if (val.equalsIgnoreCase("!"))
-			return BooleanOp.NOT;
-		return BooleanOp.INVALID;
-	}
-
-	/**
-	 * Convert format types from parser to Hops enum : default is text
-	 */
-	
-	public static FileFormatTypes convertFormatType(String fn) {
-		if (fn == null)
-			return FileFormatTypes.TEXT;
-		if (fn.equalsIgnoreCase(DataExpression.FORMAT_TYPE_VALUE_TEXT)) {
-			return FileFormatTypes.TEXT;
-		}
-		if (fn.equalsIgnoreCase(DataExpression.FORMAT_TYPE_VALUE_BINARY)) {
-			return FileFormatTypes.BINARY;
-		}
-		if (fn.equalsIgnoreCase(DataExpression.FORMAT_TYPE_VALUE_MATRIXMARKET))  {
-			return FileFormatTypes.MM;
-		}
-		if (fn.equalsIgnoreCase(DataExpression.FORMAT_TYPE_VALUE_CSV))  {
-			return FileFormatTypes.CSV;
-		}
-		// ToDo : throw parse exception for invalid / unsupported format type
-		return FileFormatTypes.TEXT;
-	}
-    
-	/**
-	 * Construct Hops from parse tree : Create temporary views in expressions
-	 */
-	public static String getTempName() {
-		return "parsertemp" + _tempId++;
-	}
-
-	public abstract VariableSet variablesRead();
-
-	public abstract VariableSet variablesUpdated();
-
-	public static DataType computeDataType(Expression e1, Expression e2, boolean cast) throws LanguageException {
-		return computeDataType(e1.getOutput(), e2.getOutput(), cast);
-	}
-
-	public static DataType computeDataType(Identifier id1, Identifier id2, boolean cast) throws LanguageException {
-		DataType d1 = id1.getDataType();
-		DataType d2 = id2.getDataType();
-
-		if (d1 == d2)
-			return d1;
-
-		if (cast) {
-			if (d1 == DataType.MATRIX && d2 == DataType.SCALAR)
-				return DataType.MATRIX;
-			if (d1 == DataType.SCALAR && d2 == DataType.MATRIX)
-				return DataType.MATRIX;
-		}
-
-		//raise error with id1 location
-		id1.raiseValidateError("Invalid Datatypes for operation "+d1+" "+d2, false, 
-				LanguageException.LanguageErrorCodes.INVALID_PARAMETERS);
-		return null; //never reached because unconditional
-	}
-
-	public static ValueType computeValueType(Expression e1, Expression e2, boolean cast) throws LanguageException {
-		return computeValueType(e1.getOutput(), e2.getOutput(), cast);
-	}
-
-	public static ValueType computeValueType(Identifier id1, Identifier id2, boolean cast) throws LanguageException {
-		ValueType v1 = id1.getValueType();
-		ValueType v2 = id2.getValueType();
-
-		if (v1 == v2)
-			return v1;
-
-		if (cast) {
-			if (v1 == ValueType.DOUBLE && v2 == ValueType.INT)
-				return ValueType.DOUBLE;
-			if (v2 == ValueType.DOUBLE && v1 == ValueType.INT)
-				return ValueType.DOUBLE;
-			
-			// String value type will override others
-			// Primary operation involving strings is concatenation (+)
-			if ( v1 == ValueType.STRING || v2 == ValueType.STRING )
-				return ValueType.STRING;
-		}
-
-		//raise error with id1 location
-		id1.raiseValidateError("Invalid Valuetypes for operation "+v1+" "+v2, false, 
-				LanguageException.LanguageErrorCodes.INVALID_PARAMETERS);
-		return null; //never reached because unconditional
-	}
-
-	@Override
-	public boolean equals(Object that)
-	{
-		//empty check for robustness
-		if( that == null || !(that instanceof Expression) )
-			return false;
-		
-		Expression thatExpr = (Expression) that;
-		
-		//approach is to compare string representation of expression
-		String thisStr = this.toString();
-		String thatStr = thatExpr.toString();
-		
-		return thisStr.equalsIgnoreCase(thatStr);
-	}
-	
-	@Override
-	public int hashCode()
-	{
-		//use identity hash code
-		return super.hashCode();
-	}
-	
-	///////////////////////////////////////////////////////////////
-	// validate error handling (consistent for all expressions)
-	
-	/**
-	 * 
-	 * @param msg
-	 * @param conditional
-	 * @throws LanguageException
-	 */
-	public void raiseValidateError( String msg, boolean conditional ) 
-		throws LanguageException
-	{
-		raiseValidateError(msg, conditional, null);
-	}
-	
-	/**
-	 * 
-	 * @param msg
-	 * @param conditional
-	 * @param code
-	 * @throws LanguageException
-	 */
-	public void raiseValidateError( String msg, boolean conditional, String errorCode ) 
-		throws LanguageException
-	{
-		if( conditional )  //warning if conditional
-		{
-			String fullMsg = this.printWarningLocation() + msg;
-			
-			LOG.warn( fullMsg );
-		}
-		else  //error and exception if unconditional
-		{
-			String fullMsg = this.printErrorLocation() + msg;
-			
-			LOG.error( fullMsg );			
-			if( errorCode != null )
-				throw new LanguageException( fullMsg, errorCode );
-			else 
-				throw new LanguageException( fullMsg );
-		}
-	}
-	
-	
-	/**
-	 * Returns the matrix characteristics for scalar-scalar, scalar-matrix, matrix-scalar, matrix-matrix
-	 * operations. This method is aware of potentially unknowns and matrix-vector (col/row) operations.
-	 * 
-	 * Format: rlen, clen, brlen, bclen.
-	 * 
-	 * @param left
-	 * @param right
-	 * @return
-	 */
-	public static long[] getBinaryMatrixCharacteristics( Expression left, Expression right )
-	{
-		long[] ret = new long[]{ -1, -1, -1, -1 };
-		
-		Identifier idleft = left.getOutput();
-		Identifier idright = right.getOutput();
-		
-		if( idleft.getDataType()==DataType.SCALAR && idright.getDataType()==DataType.SCALAR ) {
-			ret[0] = 0; 
-			ret[1] = 0; 
-			ret[2] = 0; 
-			ret[3] = 0; 
-		}
-		else if( idleft.getDataType()==DataType.SCALAR && idright.getDataType()==DataType.MATRIX ) {
-			ret[0] = idright.getDim1(); 
-			ret[1] = idright.getDim2(); 
-			ret[2] = idright.getRowsInBlock(); 
-			ret[3] = idright.getColumnsInBlock();
-		}
-		else if( idleft.getDataType()==DataType.MATRIX && idright.getDataType()==DataType.SCALAR ) {
-			ret[0] = idleft.getDim1(); 
-			ret[1] = idleft.getDim2(); 
-			ret[2] = idleft.getRowsInBlock(); 
-			ret[3] = idleft.getColumnsInBlock();
-		}
-		else if( idleft.getDataType()==DataType.MATRIX && idright.getDataType()==DataType.MATRIX ) {
-			ret[0] = idleft.getDim1(); 
-			ret[1] = idleft.getDim2(); 
-			ret[2] = idleft.getRowsInBlock(); 
-			ret[3] = idleft.getColumnsInBlock();
-			if( ret[0] < 0 && idright.getDim1() > 1 ) //robustness for row vectors
-				ret[0] = idright.getDim1();
-			if( ret[1] < 0 && idright.getDim2() > 1 ) //robustness for row vectors
-				ret[1] = idright.getDim2();
-		}
-		
-		return ret;
-	}
-	
-	///////////////////////////////////////////////////////////////////////////
-	// store exception info + position information for expressions
-	///////////////////////////////////////////////////////////////////////////
-	private String _filename;
-	private int _beginLine, _beginColumn;
-	private int _endLine, _endColumn;
-	private ArrayList<String> _parseExceptionList = new ArrayList<String>();
-	
-	public void setFilename(String passed)  { _filename = passed;   }
-	public void setBeginLine(int passed)    { _beginLine = passed;   }
-	public void setBeginColumn(int passed) 	{ _beginColumn = passed; }
-	public void setEndLine(int passed) 		{ _endLine = passed;   }
-	public void setEndColumn(int passed)	{ _endColumn = passed; }
-	public void setParseExceptionList(ArrayList<String> passed) { _parseExceptionList = passed;}
-	
-	public void setAllPositions(String filename, int blp, int bcp, int elp, int ecp){
-		_filename    = filename;
-		_beginLine	 = blp; 
-		_beginColumn = bcp; 
-		_endLine 	 = elp;
-		_endColumn 	 = ecp;
-	}
-
-	public String getFilename()	{ return _filename;   }
-	public int getBeginLine()	{ return _beginLine;   }
-	public int getBeginColumn() { return _beginColumn; }
-	public int getEndLine() 	{ return _endLine;   }
-	public int getEndColumn()	{ return _endColumn; }
-	public ArrayList<String> getParseExceptionList() { return _parseExceptionList; }
-	
-	public String printErrorLocation(){
-		return "ERROR: " + _filename + " -- line " + _beginLine + ", column " + _beginColumn + " -- ";
-	}
-	
-	public String printErrorLocation(int beginLine, int beginColumn){
-		return "ERROR: " + _filename + " -- line " + beginLine + ", column " + beginColumn + " -- ";
-	}
-	
-	public String printWarningLocation(){
-		return "WARNING: " + _filename + " -- line " + _beginLine + ", column " + _beginColumn + " -- ";
-	}
-	
-	public String printInfoLocation(){
-		return "INFO: " + _filename + " -- line " + _beginLine + ", column " + _beginColumn + " -- ";
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/parser/ExternalFunctionStatement.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/parser/ExternalFunctionStatement.java b/src/main/java/com/ibm/bi/dml/parser/ExternalFunctionStatement.java
deleted file mode 100644
index 65bd878..0000000
--- a/src/main/java/com/ibm/bi/dml/parser/ExternalFunctionStatement.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package com.ibm.bi.dml.parser;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-
-
-public class ExternalFunctionStatement extends FunctionStatement
-{
-		
-	//valid attribute names
-	public static final String CLASS_NAME    = "classname";
-	public static final String EXEC_TYPE     = "exectype";
-	//public static final String EXEC_LOCATION = "execlocation"; 	//MB: obsolete
-	public static final String CONFIG_FILE   = "configfile";
-	
-	//valid attribute values for execlocation and 
-	public static final String FILE_BASED    = "file";
-	public static final String IN_MEMORY     = "mem";
-	//public static final String MASTER        = "master";	//MB: obsolete
-	//public static final String WORKER        = "worker";	//MB: obsolete
-	
-	//default values for optional attributes
-	public static final String DEFAULT_EXEC_TYPE = FILE_BASED;
-	//public static final String DEFAULT_EXEC_LOCATION = MASTER; 	//MB: obsolete
-	
-	//all parameters
-	private HashMap<String,String> _otherParams;
-	
-	
-	public ExternalFunctionStatement(){
-		super();
-	}
-	
-	
-	
-	public ExternalFunctionStatement( ArrayList<DataIdentifier> functionInputs, ArrayList<DataIdentifier> functionOutputs, HashMap<String,String> map)
-	{
-		super();
-		_inputParams = functionInputs; 
-		_outputParams = (functionOutputs == null) ? new ArrayList<DataIdentifier>() : functionOutputs;
-		setOtherParams(map);
-	}
-	
-	
-	public void setOtherParams(HashMap<String,String> params){
-		_otherParams = params;
-	}
-	
-	public HashMap<String,String> getOtherParams(){
-		return _otherParams;
-	}
-	
-	/**
-	 * Validates all attributes and attribute values.
-	 * 
-	 * @throws LanguageException
-	 */
-	public void validateParameters(StatementBlock sb) //always unconditional  
-		throws LanguageException 
-	{
-		
-		//warnings for all not defined attributes
-		for( String varName : _otherParams.keySet() )
-			if( !(   varName.equals(CLASS_NAME) || varName.equals(EXEC_TYPE) 
-				  || varName.equals(CONFIG_FILE) ) )                                                  
-			{
-				LOG.warn( printWarningLocation() + "External function specifies undefined attribute type '"+varName+"'.");
-			}
-		
-		//class name (required)
-		if( !_otherParams.containsKey(CLASS_NAME) ){
-			sb.raiseValidateError("External function does not specify the required attribute '"+CLASS_NAME+"'.", false);
-		}
-		else if ( _otherParams.get(CLASS_NAME)==null ) {
-			sb.raiseValidateError("External function specifies empty '"+CLASS_NAME+"'.", false);
-		}
-		
-		//exec type (optional, default: file)
-		if( _otherParams.containsKey( EXEC_TYPE ) )
-		{
-			//check specified values
-			String execType = _otherParams.get(EXEC_TYPE);
-			if( !(execType.equals(FILE_BASED) || execType.equals(IN_MEMORY)) ) { //always unconditional (invalid parameter)
-				sb.raiseValidateError("External function specifies invalid value for (optional) attribute '"+EXEC_TYPE+"' (valid values: "+FILE_BASED+","+IN_MEMORY+").", false);
-			}
-		}
-		else
-		{
-			//put default values
-			_otherParams.put(EXEC_TYPE, DEFAULT_EXEC_TYPE);
-		}
-	}
-	
-	@Override
-	public boolean controlStatement() 
-	{
-		return true;
-	}
-	
-	@Override
-	public String toString(){
-		StringBuilder sb = new StringBuilder();
-		sb.append(_name + " = ");
-		
-		sb.append("externalfunction ( ");
-		for (int i=0; i<_inputParams.size(); i++){
-			DataIdentifier curr = _inputParams.get(i);
-			sb.append(curr.getName());
-			if (curr.getDefaultValue() != null) sb.append(" = " + curr.getDefaultValue());
-			if (i < _inputParams.size()-1) sb.append(", ");
-		}
-		sb.append(") return (");
-		
-		for (int i=0; i<_outputParams.size(); i++){
-			sb.append(_outputParams.get(i).getName());
-			if (i < _outputParams.size()-1) sb.append(", ");
-		}
-		sb.append(")\n implemented in (");
-		
-		int j = 0;
-		for (String key : _otherParams.keySet()){
-			sb.append(key + " = " + _otherParams.get(key));
-			if (j < _otherParams.keySet().size()-1) sb.append(", ");
-			j++;
-		}
-		
-		sb.append(") \n");
-		return sb.toString();
-	}
-
-	@Override
-	public void initializeforwardLV(VariableSet activeIn) throws LanguageException{
-		LOG.error(this.printErrorLocation() + "should never call initializeforwardLV for ExternalFunctionStatement");
-		throw new LanguageException(this.printErrorLocation() + "should never call initializeforwardLV for ExternalFunctionStatement");
-	}
-	
-	@Override
-	public VariableSet initializebackwardLV(VariableSet lo) throws LanguageException{
-		LOG.error(this.printErrorLocation() + "should never call initializeforwardLV for ExternalFunctionStatement");
-		throw new LanguageException(this.printErrorLocation() + "should never call initializeforwardLV for ExternalFunctionStatement");
-		
-	}
-	
-	@Override
-	public VariableSet variablesRead() {
-		LOG.warn(this.printWarningLocation() + "should not call variablesRead from ExternalFunctionStatement ");
-		return new VariableSet();
-	}
-
-	@Override
-	public VariableSet variablesUpdated() {
-		LOG.warn(this.printWarningLocation() + "should not call variablesRead from ExternalFunctionStatement ");
-		return new VariableSet();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/parser/ForStatement.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/parser/ForStatement.java b/src/main/java/com/ibm/bi/dml/parser/ForStatement.java
deleted file mode 100644
index b6c6ce4..0000000
--- a/src/main/java/com/ibm/bi/dml/parser/ForStatement.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package com.ibm.bi.dml.parser;
-
-import java.util.ArrayList;
-
-
-
-public class ForStatement extends Statement
-{	
-
-	
-	protected IterablePredicate 		_predicate;
-	protected ArrayList<StatementBlock> _body;
-	
-	public Statement rewriteStatement(String prefix) throws LanguageException{
-		LOG.error(this.printErrorLocation() + "should not call rewriteStatement for ForStatement");
-		throw new LanguageException(this.printErrorLocation() + "should not call rewriteStatement for ForStatement");
-	}
-	
-	public ForStatement(){
-		 _predicate = null;
-		 _body = new ArrayList<StatementBlock>();
-	}
-	
-	public void setPredicate(IterablePredicate pred){
-		_predicate = pred;
-	}
-	
-	
-	public void addStatementBlock(StatementBlock sb){
-		_body.add(sb);
-	}
-	
-	public IterablePredicate getIterablePredicate(){
-		return _predicate;
-	}
-	
-	public ArrayList<StatementBlock> getBody(){
-		return _body;
-	}
-	
-	public void setBody(ArrayList<StatementBlock> body){
-		_body = body;
-	}
-	
-	
-	@Override
-	public boolean controlStatement() {
-		return true;
-	}
-	
-	public void mergeStatementBlocks(){
-		_body = StatementBlock.mergeStatementBlocks(_body);
-	}
-	
-	public String toString(){
-		StringBuilder sb = new StringBuilder();
-		sb.append("for ");
-		sb.append(_predicate.toString());
-		sb.append(" { \n");
-		for (StatementBlock block : _body){
-			sb.append(block.toString());
-		}
-		sb.append("}\n");
-		return sb.toString();
-	}
-
-	public void initializeforwardLV(VariableSet activeIn) throws LanguageException{
-		LOG.error(this.printErrorLocation() + "should never call initializeforwardLV for ForStatement");
-		throw new LanguageException(this.printErrorLocation() + "should never call initializeforwardLV for ForStatement");
-	}
-	
-	public VariableSet initializebackwardLV(VariableSet lo) throws LanguageException{
-		LOG.error(this.printErrorLocation() + "should never call initializeforwardLV for ForStatement");
-		throw new LanguageException(this.printErrorLocation() + "should never call initializeforwardLV for ForStatement");
-		
-	}
-	
-	@Override
-	public VariableSet variablesRead() {
-		LOG.error(this.printErrorLocation() + "should not call variablesRead from ForStatement ");
-		return new VariableSet();
-	}
-
-	@Override
-	public VariableSet variablesUpdated() {
-		LOG.error(this.printErrorLocation() +  "should not call variablesRead from ForStatement ");
-		return new VariableSet();
-	}
-} 
- 

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/parser/ForStatementBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/parser/ForStatementBlock.java b/src/main/java/com/ibm/bi/dml/parser/ForStatementBlock.java
deleted file mode 100644
index 0e4c05c..0000000
--- a/src/main/java/com/ibm/bi/dml/parser/ForStatementBlock.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package com.ibm.bi.dml.parser;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import com.ibm.bi.dml.hops.Hop;
-import com.ibm.bi.dml.hops.HopsException;
-import com.ibm.bi.dml.hops.OptimizerUtils;
-import com.ibm.bi.dml.hops.recompile.Recompiler;
-import com.ibm.bi.dml.lops.Lop;
-import com.ibm.bi.dml.runtime.instructions.cp.BooleanObject;
-import com.ibm.bi.dml.runtime.instructions.cp.DoubleObject;
-
-
-public class ForStatementBlock extends StatementBlock 
-{
-	
-	protected Hop _fromHops        = null;
-	protected Hop _toHops          = null;
-	protected Hop _incrementHops   = null;
-	
-	protected Lop _fromLops        = null;
-	protected Lop _toLops          = null;
-	protected Lop _incrementLops   = null;
-
-	protected boolean _requiresFromRecompile      = false;
-	protected boolean _requiresToRecompile        = false;
-	protected boolean _requiresIncrementRecompile = false;
-	
-	
-	public IterablePredicate getIterPredicate(){
-		return ((ForStatement)_statements.get(0)).getIterablePredicate();
-	}
-
-	@Override
-	public VariableSet validate(DMLProgram dmlProg, VariableSet ids, HashMap<String,ConstIdentifier> constVars, boolean conditional) 
-		throws LanguageException, ParseException, IOException 
-	{	
-		if (_statements.size() > 1){
-			raiseValidateError("ForStatementBlock should have only 1 statement (for statement)", conditional);
-		}
-		ForStatement fs = (ForStatement) _statements.get(0);
-		IterablePredicate predicate = fs.getIterablePredicate();
-		
-		// Record original size information before loop for ALL variables 
-		// Will compare size / type info for these after loop completes
-		// Replace variables with changed size with unknown value 
-		VariableSet origVarsBeforeBody = new VariableSet();
-		for (String key : ids.getVariableNames()){
-			DataIdentifier origId = ids.getVariable(key);
-			DataIdentifier copyId = new DataIdentifier(origId);
-			origVarsBeforeBody.addVariable(key, copyId);
-		}
-			
-		//////////////////////////////////////////////////////////////////////////////
-		// FIRST PASS: process the predicate / statement blocks in the body of the for statement
-		///////////////////////////////////////////////////////////////////////////////
-		
-		//remove updated vars from constants
-		for( String var : _updated.getVariableNames() )
-			if( constVars.containsKey( var ) )
-				constVars.remove( var );
-		
-		predicate.validateExpression(ids.getVariables(), constVars, conditional);
-		ArrayList<StatementBlock> body = fs.getBody();
-		
-		//perform constant propagation for ( from, to, incr )
-		//(e.g., useful for reducing false positives in parfor dependency analysis)
-		performConstantPropagation(constVars);
-		
-		//validate body
-		_dmlProg = dmlProg;
-		for(StatementBlock sb : body)
-		{
-			ids = sb.validate(dmlProg, ids, constVars, true);
-			constVars = sb.getConstOut();
-		}
-		
-		if (!body.isEmpty()){
-			_constVarsIn.putAll(body.get(0).getConstIn());
-			_constVarsOut.putAll(body.get(body.size()-1).getConstOut());
-		}
-		
-		// for each updated variable 
-		boolean revalidationRequired = false;
-		for (String key : _updated.getVariableNames())
-		{	
-			DataIdentifier startVersion = origVarsBeforeBody.getVariable(key);
-			DataIdentifier endVersion   = ids.getVariable(key);
-			
-			if (startVersion != null && endVersion != null)
-			{
-				//handle data type change (reject) 
-				if (!startVersion.getOutput().getDataType().equals(endVersion.getOutput().getDataType())){
-					raiseValidateError("ForStatementBlock has unsupported conditional data type change of variable '"+key+"' in loop body.", conditional);
-				}	
-				
-				//handle size change
-				long startVersionDim1 	= (startVersion instanceof IndexedIdentifier)   ? ((IndexedIdentifier)startVersion).getOrigDim1() : startVersion.getDim1(); 
-				long endVersionDim1		= (endVersion instanceof IndexedIdentifier) ? ((IndexedIdentifier)endVersion).getOrigDim1() : endVersion.getDim1(); 
-				long startVersionDim2 	= (startVersion instanceof IndexedIdentifier)   ? ((IndexedIdentifier)startVersion).getOrigDim2() : startVersion.getDim2(); 
-				long endVersionDim2		= (endVersion instanceof IndexedIdentifier) ? ((IndexedIdentifier)endVersion).getOrigDim2() : endVersion.getDim2(); 
-				
-				boolean sizeUnchanged = ((startVersionDim1 == endVersionDim1) &&
-						                 (startVersionDim2 == endVersionDim2) );
-				
-				//handle sparsity change
-				//NOTE: nnz not propagated via validate, and hence, we conservatively assume that nnz have been changed.
-				//long startVersionNNZ 	= startVersion.getNnz();
-				//long endVersionNNZ    = endVersion.getNnz(); 
-				//boolean nnzUnchanged  = (startVersionNNZ == endVersionNNZ);
-				boolean nnzUnchanged = false;
-				
-				// IF size has changed -- 
-				if (!sizeUnchanged || !nnzUnchanged){
-					revalidationRequired = true;
-					DataIdentifier recVersion = new DataIdentifier(endVersion);
-					if(!sizeUnchanged)
-						recVersion.setDimensions(-1, -1);
-					if(!nnzUnchanged)
-						recVersion.setNnz(-1);
-					origVarsBeforeBody.addVariable(key, recVersion);
-				}
-			}
-		}
-		
-		// revalidation is required -- size was updated for at least 1 variable
-		if (revalidationRequired){
-		
-			// update ids to the reconciled values
-			ids = origVarsBeforeBody;
-			
-			//////////////////////////////////////////////////////////////////////////////
-			// SECOND PASS: process the predicate / statement blocks in the body of the for statement
-			///////////////////////////////////////////////////////////////////////////////
-			
-			//remove updated vars from constants
-			for( String var : _updated.getVariableNames() )
-				if( constVars.containsKey( var ) )
-					constVars.remove( var );
-					
-			//perform constant propagation for ( from, to, incr )
-			//(e.g., useful for reducing false positives in parfor dependency analysis)
-			performConstantPropagation(constVars);
-			
-			predicate.validateExpression(ids.getVariables(), constVars, conditional);
-			body = fs.getBody();
-			
-			//validate body
-			_dmlProg = dmlProg;
-			for(StatementBlock sb : body)
-			{
-				ids = sb.validate(dmlProg, ids, constVars, true);
-				constVars = sb.getConstOut();
-			}
-			if (!body.isEmpty()){
-				_constVarsIn.putAll(body.get(0).getConstIn());
-				_constVarsOut.putAll(body.get(body.size()-1).getConstOut());
-			}
-		}
-		
-		return ids;
-	}
-	
-	public VariableSet initializeforwardLV(VariableSet activeInPassed) throws LanguageException {
-		
-		ForStatement fstmt = (ForStatement)_statements.get(0);
-		if (_statements.size() > 1){
-			LOG.error(_statements.get(0).printErrorLocation() + "ForStatementBlock should have only 1 statement (for statement)");
-			throw new LanguageException(_statements.get(0).printErrorLocation() + "ForStatementBlock should have only 1 statement (for statement)");
-		}
-		
-		_read = new VariableSet();
-		_read.addVariables(fstmt.getIterablePredicate().variablesRead());
-		_updated.addVariables(fstmt.getIterablePredicate().variablesUpdated());
-		
-		_gen = new VariableSet();
-		_gen.addVariables(fstmt.getIterablePredicate().variablesRead());
-
-		// add the iterVar from iterable predicate to kill set 
-		_kill.addVariables(fstmt.getIterablePredicate().variablesUpdated());
-		
-		VariableSet current = new VariableSet();
-		current.addVariables(activeInPassed);
-		current.addVariables(_updated);
-		
-		
-		for( StatementBlock sb : fstmt.getBody())
-		{
-			current = sb.initializeforwardLV(current);	
-			
-			// for each generated variable in this block, check variable not killed
-			// in prior statement block in while stmt blody
-			for (String varName : sb._gen.getVariableNames()){
-				
-				// IF the variable is NOT set in the while loop PRIOR to this stmt block, 
-				// THEN needs to be generated
-				if (!_kill.getVariableNames().contains(varName)){
-					_gen.addVariable(varName, sb._gen.getVariable(varName));	
-				}
-			}
-			
-			_read.addVariables(sb._read);
-			_updated.addVariables(sb._updated);
-		
-			// only add kill variables for statement blocks guaranteed to execute
-			if (!(sb instanceof WhileStatementBlock) && !(sb instanceof ForStatementBlock) ){
-				_kill.addVariables(sb._kill);
-			}	
-		}
-		
-		// set preliminary "warn" set -- variables that if used later may cause runtime error
-		// if the loop is not executed
-		// warnSet = (updated MINUS (updatedIfBody INTERSECT updatedElseBody)) MINUS current
-		for (String varName : _updated.getVariableNames()){
-			if (!activeInPassed.containsVariable(varName)) {
-				_warnSet.addVariable(varName, _updated.getVariable(varName));
-			}
-		}
-		
-		// activeOut includes variables from passed live in and updated in the while body
-		_liveOut = new VariableSet();
-		_liveOut.addVariables(current);
-		_liveOut.addVariables(_updated);
-		return _liveOut;
-	}
-
-	public VariableSet initializebackwardLV(VariableSet loPassed) throws LanguageException{
-		
-		ForStatement fstmt = (ForStatement)_statements.get(0);
-			
-		VariableSet lo = new VariableSet();
-		lo.addVariables(loPassed);
-		
-		// calls analyze for each statement block in while stmt body
-		int numBlocks = fstmt.getBody().size();
-		for (int i = numBlocks - 1; i >= 0; i--){
-			lo = fstmt.getBody().get(i).analyze(lo);
-		}	
-		
-		VariableSet loReturn = new VariableSet();
-		loReturn.addVariables(lo);
-		return loReturn;
-	
-	}
-
-	public ArrayList<Hop> get_hops() throws HopsException {
-		
-		if (_hops != null && !_hops.isEmpty()){
-			LOG.error(this.printBlockErrorLocation() + "there should be no HOPs associated with the ForStatementBlock");
-			throw new HopsException(this.printBlockErrorLocation() + "there should be no HOPs associated with the ForStatementBlock");
-		}
-		
-		return _hops;
-	}
-
-	public void setFromHops(Hop hops) { _fromHops = hops; }
-	public void setToHops(Hop hops) { _toHops = hops; }
-	public void setIncrementHops(Hop hops) { _incrementHops = hops; }
-	
-	public Hop getFromHops()      { return _fromHops; }
-	public Hop getToHops()        { return _toHops; }
-	public Hop getIncrementHops() { return _incrementHops; }
-
-	public void setFromLops(Lop lops) { 
-		_fromLops = lops; 
-	}
-	public void setToLops(Lop lops) { _toLops = lops; }
-	public void setIncrementLops(Lop lops) { _incrementLops = lops; }
-	
-	public Lop getFromLops()      { return _fromLops; }
-	public Lop getToLops()        { return _toLops; }
-	public Lop getIncrementLops() { return _incrementLops; }
-
-	
-	
-	public VariableSet analyze(VariableSet loPassed) throws LanguageException{
- 		
-		VariableSet predVars = new VariableSet();
-		IterablePredicate ip = ((ForStatement)_statements.get(0)).getIterablePredicate(); 
-		
-		predVars.addVariables(ip.variablesRead());
-		predVars.addVariables(ip.variablesUpdated());
-		
-		VariableSet candidateLO = new VariableSet();
-		candidateLO.addVariables(loPassed);
-		candidateLO.addVariables(_gen);
-		candidateLO.addVariables(predVars);
-		
-		VariableSet origLiveOut = new VariableSet();
-		origLiveOut.addVariables(_liveOut);
-		origLiveOut.addVariables(predVars);
-		origLiveOut.addVariables(_gen);
-		
-		_liveOut = new VariableSet();
-	 	for (String name : candidateLO.getVariableNames()){
-	 		if (origLiveOut.containsVariable(name)){
-	 			_liveOut.addVariable(name, candidateLO.getVariable(name));
-	 		}
-	 	}
-	 	
-		initializebackwardLV(_liveOut);
-		
-		// set final warnSet: remove variables NOT in live out
-		VariableSet finalWarnSet = new VariableSet();
-		for (String varName : _warnSet.getVariableNames()){
-			if (_liveOut.containsVariable(varName)){
-				finalWarnSet.addVariable(varName,_warnSet.getVariable(varName));
-			}
-		}
-		_warnSet = finalWarnSet;
-		
-		// for now just print the warn set
-		for (String varName : _warnSet.getVariableNames()) {
-			if( !ip.getIterVar().getName().equals( varName)  )
-				LOG.warn(_warnSet.getVariable(varName).printWarningLocation() + "Initialization of " + varName + " depends on for execution");
-		}
-		
-		// Cannot remove kill variables
-		_liveIn = new VariableSet();
-		_liveIn.addVariables(_liveOut);
-		_liveIn.addVariables(_gen);
-		
-		VariableSet liveInReturn = new VariableSet();
-		liveInReturn.addVariables(_liveIn);
-		
-		return liveInReturn;
-	}
-	
-
-	public void performConstantPropagation(HashMap<String, ConstIdentifier> currConstVars) 
-		throws LanguageException
-	{
-		IterablePredicate ip = getIterPredicate();
-		
-		// handle replacement in from expression
-		Expression replacementExpr = replaceConstantVar(ip.getFromExpr(), currConstVars); 
-		if (replacementExpr != null)
-			ip.setFromExpr(replacementExpr);
-		
-		// handle replacment in to expression
-		replacementExpr = replaceConstantVar(ip.getToExpr(), currConstVars);  
-		if (replacementExpr != null)
-			ip.setToExpr(replacementExpr);
-		
-		// handle replacement in increment expression
-		replacementExpr = replaceConstantVar(ip.getIncrementExpr(), currConstVars);
-		if (replacementExpr != null)
-			ip.setIncrementExpr(replacementExpr);
-	}
-	
-	private Expression replaceConstantVar(Expression expr, HashMap<String, ConstIdentifier> currConstVars)
-	{
-		Expression ret = null;
-		
-		if (expr instanceof DataIdentifier && !(expr instanceof IndexedIdentifier)) 
-		{	
-			// check if the DataIdentifier variable is a ConstIdentifier
-			String identifierName = ((DataIdentifier)expr).getName();
-			if (currConstVars.containsKey(identifierName))
-			{
-				ConstIdentifier constValue = currConstVars.get(identifierName);
-				//AUTO CASTING (using runtime operations for consistency)
-				switch( constValue.getValueType() ) 
-				{
-					case DOUBLE: 
-						ret = new IntIdentifier(new DoubleObject(((DoubleIdentifier)constValue).getValue()).getLongValue(),
-								expr.getFilename(), expr.getBeginLine(), expr.getBeginColumn(), 
-								expr.getEndLine(), expr.getEndColumn());
-						break;
-					case INT:    
-						ret = new IntIdentifier((IntIdentifier)constValue,
-								expr.getFilename(), expr.getBeginLine(), expr.getBeginColumn(), 
-								expr.getEndLine(), expr.getEndColumn());
-						break;
-					case BOOLEAN: 
-						ret = new IntIdentifier(new BooleanObject(((BooleanIdentifier)constValue).getValue()).getLongValue(),
-								expr.getFilename(), expr.getBeginLine(), expr.getBeginColumn(), 
-								expr.getEndLine(), expr.getEndColumn());
-						break;
-						
-					default:
-						//do nothing
-				}
-			}
-		}
-		else
-		{
-			//do nothing, cannot replace full expression
-			ret = expr;
-		}
-		
-		return ret;
-	}
-	
-	/////////
-	// materialized hops recompilation flags
-	////
-	
-	public void updatePredicateRecompilationFlags() 
-		throws HopsException
-	{
-		if( OptimizerUtils.ALLOW_DYN_RECOMPILATION )
-		{
-			_requiresFromRecompile = Recompiler.requiresRecompilation(getFromHops());
-			_requiresToRecompile = Recompiler.requiresRecompilation(getToHops());
-			_requiresIncrementRecompile = Recompiler.requiresRecompilation(getIncrementHops());
-		}
-	}
-	
-	public boolean requiresFromRecompilation()
-	{
-		return _requiresFromRecompile;
-	}
-	
-	public boolean requiresToRecompilation()
-	{
-		return _requiresToRecompile;
-	}
-	
-	public boolean requiresIncrementRecompilation()
-	{
-		return _requiresIncrementRecompile;
-	}
-	
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/parser/FunctionCallIdentifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/parser/FunctionCallIdentifier.java b/src/main/java/com/ibm/bi/dml/parser/FunctionCallIdentifier.java
deleted file mode 100644
index 2e67f01..0000000
--- a/src/main/java/com/ibm/bi/dml/parser/FunctionCallIdentifier.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package com.ibm.bi.dml.parser;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.io.IOException;
-
-
-public class FunctionCallIdentifier extends DataIdentifier 
-{
-	
-	private ArrayList<ParameterExpression> _paramExprs;
-	private FunctCallOp _opcode;	// stores whether internal or external
-	private String _namespace;		// namespace of the function being called (null if current namespace is to be used)
-
-	/**
-	 * setFunctionName: sets the function namespace (if specified) and name
-	 * @param functionName the (optional) namespace information and name of function.  If both namespace and name are specified, they are concatinated with "::"
-	 * @throws ParseException 
-	 */
-	public void setFunctionName(String functionName) throws ParseException{
-		_name = functionName;
-	}
-	
-	public void setFunctionNamespace(String passed) throws ParseException{
-		_namespace 	= passed;
-	}
-	
-	public String getNamespace(){
-		return _namespace;
-	}
-	
-	public ArrayList<ParameterExpression> getParamExprs(){
-		return _paramExprs;
-	}
-	
-	public Expression rewriteExpression(String prefix) throws LanguageException {
-			
-		ArrayList<ParameterExpression> newParameterExpressions = new ArrayList<ParameterExpression>();
-		for (ParameterExpression paramExpr : _paramExprs)
-			newParameterExpressions.add(new ParameterExpression(paramExpr.getName(), paramExpr.getExpr().rewriteExpression(prefix)));
-		
-		// rewrite each output expression
-		FunctionCallIdentifier fci = new FunctionCallIdentifier(newParameterExpressions);
-		
-		fci.setBeginLine(this.getBeginLine());
-		fci.setBeginColumn(this.getBeginColumn());
-		fci.setEndLine(this.getEndLine());
-		fci.setEndColumn(this.getEndColumn());
-			
-		fci._name = this._name;
-		fci._namespace = this._namespace;
-		fci._opcode = this._opcode;
-		fci._kind = Kind.FunctionCallOp;	 
-		
-		return fci;
-	}
-	
-	
-	
-	public FunctionCallIdentifier(){}
-	
-	public FunctionCallIdentifier(ArrayList<ParameterExpression> paramExpressions) {
-		
-		_paramExprs = paramExpressions;
-		_opcode = null;
-		_kind = Kind.FunctionCallOp;	 
-	}
-	
-	
-	
-	public FunctCallOp getOpCode() {
-		return _opcode;
-	}
-	
-	/**
-	 * Validate parse tree : Process ExtBuiltinFunction Expression is an
-	 * assignment statement
-	 * 
-	 * NOTE: this does not override the normal validateExpression because it needs to pass dmlp!
-	 * 
-	 * @throws LanguageException
-	 */
-	public void validateExpression(DMLProgram dmlp, HashMap<String, DataIdentifier> ids, HashMap<String, ConstIdentifier> constVars, boolean conditional) 
-		throws LanguageException, IOException
-	{
-		// Step 1: check the namespace exists, and that function is defined in the namespace
-		if (dmlp.getNamespaces().get(_namespace) == null){
-			raiseValidateError("namespace " + _namespace + " is not defined ", conditional);
-		}
-		FunctionStatementBlock fblock = dmlp.getFunctionStatementBlock(_namespace, _name);
-		if (fblock == null){
-			raiseValidateError("function " + _name + " is undefined in namespace " + _namespace, conditional);
-		}
-		
-		// Step 2: set opcode (whether internal or external function) -- based on whether FunctionStatement
-		// in FunctionStatementBlock is ExternalFunctionStatement or FunctionStatement
-		if (fblock.getStatement(0) instanceof ExternalFunctionStatement)
-			_opcode = Expression.FunctCallOp.EXTERNAL;
-		else
-			_opcode = Expression.FunctCallOp.INTERNAL;
-		
-		// Step 3: check all parameters to be either unnamed or named for functions
-		boolean hasNamed = false, hasUnnamed = false;
-		for( ParameterExpression paramExpr : _paramExprs ) {
-			if (paramExpr.getName() == null)
-				hasUnnamed = true;
-			else
-				hasNamed = true;
-		}
-		if (hasNamed && hasUnnamed){
-			raiseValidateError(" In DML, functions can only have named parameters " +
-					"(e.g., name1=value1, name2=value2) or unnamed parameters (e.g, value1, value2). " + 
-					_name + " has both parameter types.", conditional);
-		}
-		
-		// Step 4: validate expressions for each passed parameter
-		for( ParameterExpression paramExpr : _paramExprs ) {
-			if (paramExpr.getExpr() instanceof FunctionCallIdentifier) {
-				raiseValidateError("UDF function call not supported as parameter to function call", false);
-			}
-			paramExpr.getExpr().validateExpression(ids, constVars, conditional);
-		}
-		
-		// Step 5: constant propagation into function call statement
-		for( ParameterExpression paramExpr : _paramExprs ) {
-			Expression expri = paramExpr.getExpr();
-			if( expri instanceof DataIdentifier && !(expri instanceof IndexedIdentifier)
-				&& constVars.containsKey(((DataIdentifier)expri).getName()) )
-			{
-				//replace varname with constant in function call expression
-				paramExpr.setExpr(constVars.get(((DataIdentifier)expri).getName()));
-			}
-		}
-	
-		// Step 6: check correctness of number of arguments and their types 
-		FunctionStatement fstmt = (FunctionStatement)fblock.getStatement(0);
-		if (fstmt.getInputParams().size() < _paramExprs.size()) { 
-			raiseValidateError("function " + _name 
-					+ " has incorrect number of parameters. Function requires " 
-					+ fstmt.getInputParams().size() + " but was called with " + _paramExprs.size(), conditional);
-		}
-		
-		// Step 7: set the outputs for the function
-		_outputs = new Identifier[fstmt.getOutputParams().size()];
-		for(int i=0; i < fstmt.getOutputParams().size(); i++) {
-			_outputs[i] = new DataIdentifier(fstmt.getOutputParams().get(i));
-		}
-		
-		return;
-	}
-	
-	@Override
-	public String toString() {
-		StringBuilder sb = new StringBuilder();
-		if (_namespace != null && _namespace.length() > 0 && !_namespace.equals(".defaultNS")) 
-			sb.append(_namespace + "::"); 
-		sb.append(_name);
-		sb.append(" ( ");		
-				
-		for (int i = 0; i < _paramExprs.size(); i++){
-			sb.append(_paramExprs.get(i).toString());
-			if (i<_paramExprs.size() - 1) 
-				sb.append(",");
-		}
-		sb.append(" )");
-		return sb.toString();
-	}
-
-	@Override
-	public VariableSet variablesRead() {
-		VariableSet result = new VariableSet();
-		for (int i = 0; i < _paramExprs.size(); i++)
-			result.addVariables(_paramExprs.get(i).getExpr().variablesRead());
-		return result;
-	}
-
-	@Override
-	public VariableSet variablesUpdated() {
-		VariableSet result = new VariableSet();
-		for (int i=0; i< _outputs.length; i++)
-			result.addVariable( ((DataIdentifier)_outputs[i]).getName(), (DataIdentifier)_outputs[i] );
-		return result;
-	}
-
-	@Override
-	public boolean multipleReturns() {
-		return true;
-	}
-}
-
-

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/parser/FunctionStatement.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/parser/FunctionStatement.java b/src/main/java/com/ibm/bi/dml/parser/FunctionStatement.java
deleted file mode 100644
index 98d58d0..0000000
--- a/src/main/java/com/ibm/bi/dml/parser/FunctionStatement.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package com.ibm.bi.dml.parser;
-
-import java.util.ArrayList;
-
-import com.ibm.bi.dml.lops.Lop;
-
-
-public class FunctionStatement extends Statement
-{
-		
-	private ArrayList<StatementBlock> _body;
-	protected String _name;
-	protected ArrayList <DataIdentifier> _inputParams;
-	protected ArrayList <DataIdentifier> _outputParams;
-	
-	public Statement rewriteStatement(String prefix) throws LanguageException{
-		LOG.error(this.printErrorLocation() + "should not call rewriteStatement for FunctionStatement");
-		throw new LanguageException(this.printErrorLocation() + "should not call rewriteStatement for FunctionStatement");
-	}
-	
-	public FunctionStatement(){
-		 _body = new ArrayList<StatementBlock>();
-		 _name = null;
-		 _inputParams = new ArrayList<DataIdentifier>();
-		 _outputParams = new ArrayList<DataIdentifier>();
-	}
-	
-	public ArrayList<DataIdentifier> getInputParams(){
-		return _inputParams;
-	}
-	
-	public ArrayList<DataIdentifier> getOutputParams(){
-		return _outputParams;
-	}
-	
-	public void setInputParams(ArrayList<DataIdentifier> inputParams){
-		_inputParams = inputParams;
-	}
-	
-	public void setOutputParams(ArrayList<DataIdentifier> outputParams){
-		_outputParams = outputParams;
-	}
-	
-	public void setName(String fname){
-		_name = fname;
-	}
-	
-	public String getName(){
-		return _name;
-	}
-	
-	public void addStatementBlock(StatementBlock sb){
-		_body.add(sb);
-	}
-	
-	public ArrayList<StatementBlock> getBody(){
-		return _body;
-	}
-	
-	public void setBody(ArrayList<StatementBlock> body){
-		_body = body;
-	}
-	
-	
-	@Override
-	public boolean controlStatement() {
-		return true;
-	}
-
-	public void mergeStatementBlocks(){
-		_body = StatementBlock.mergeStatementBlocks(_body);
-	}
-	
-	public String toString(){
-		StringBuilder sb = new StringBuilder();
-		sb.append(_name + " = ");
-		
-		sb.append("function ( ");
-		
-		for (int i=0; i<_inputParams.size(); i++){
-			DataIdentifier curr = _inputParams.get(i);
-			sb.append(curr.getName());
-			if (curr.getDefaultValue() != null) sb.append(" = " + curr.getDefaultValue());
-			if (i < _inputParams.size()-1) sb.append(", ");
-		}
-		sb.append(") return (");
-		
-		for (int i=0; i<_outputParams.size(); i++){
-			sb.append(_outputParams.get(i).getName());
-			if (i < _outputParams.size()-1) sb.append(", ");
-		}
-		sb.append(") { \n");
-		
-		for (StatementBlock block : _body){
-			sb.append(block.toString());
-		}
-		sb.append("} \n");
-		return sb.toString();
-	}
-
-	public void initializeforwardLV(VariableSet activeIn) throws LanguageException{
-		LOG.error(this.printErrorLocation() + "should never call initializeforwardLV for FunctionStatement");
-		throw new LanguageException(this.printErrorLocation() + "should never call initializeforwardLV for FunctionStatement");
-	}
-	
-	public VariableSet initializebackwardLV(VariableSet lo) throws LanguageException{
-		LOG.error(this.printErrorLocation() + "should never call initializeforwardLV for FunctionStatement");
-		throw new LanguageException(this.printErrorLocation() + "should never call initializeforwardLV for FunctionStatement");
-		
-	}
-	
-	@Override
-	public VariableSet variablesRead() {
-		LOG.warn(this.printWarningLocation() + " -- should not call variablesRead from FunctionStatement ");
-		return new VariableSet();
-	}
-
-	@Override
-	public VariableSet variablesUpdated() {
-		LOG.warn(this.printWarningLocation() + " -- should not call variablesRead from FunctionStatement ");
-		return new VariableSet();
-	}
-	
-	public static String[] createFunctionCallVariables( ArrayList<Lop> lops )
-	{
-		String[] ret = new String[lops.size()]; //vars in order
-		
-		for( int i=0; i<lops.size(); i++ )
-		{	
-			Lop llops = lops.get(i);
-			if( llops.getType()==Lop.Type.Data )
-				ret[i] = llops.getOutputParameters().getLabel(); 
-		}
-		
-		return ret;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/parser/FunctionStatementBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/parser/FunctionStatementBlock.java b/src/main/java/com/ibm/bi/dml/parser/FunctionStatementBlock.java
deleted file mode 100644
index faf9ac5..0000000
--- a/src/main/java/com/ibm/bi/dml/parser/FunctionStatementBlock.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package com.ibm.bi.dml.parser;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import com.ibm.bi.dml.hops.Hop;
-import com.ibm.bi.dml.hops.HopsException;
-import com.ibm.bi.dml.hops.FunctionOp.FunctionType;
-import com.ibm.bi.dml.parser.Expression.DataType;
-import com.ibm.bi.dml.parser.Expression.ValueType;
-
-
-public class FunctionStatementBlock extends StatementBlock 
-{
-		
-	private boolean _recompileOnce = false;
-	
-	/**
-	 *  TODO: DRB:  This needs to be changed to reflect:
-	 *  
-	 *    1)  Default values for variables -- need to add R styled check here to make sure that once vars with 
-	 *    default values start, they keep going to the right
-	 *    
-	 *    2)  The other parameters for External Functions
-	 * @throws IOException 
-	 */
-	@Override
-	public VariableSet validate(DMLProgram dmlProg, VariableSet ids, HashMap<String,ConstIdentifier> constVars, boolean conditional) 
-		throws LanguageException, ParseException, IOException 
-	{
-		
-		if (_statements.size() > 1){
-			LOG.error(this.printBlockErrorLocation() + "FunctionStatementBlock should have only 1 statement (FunctionStatement)");
-			throw new LanguageException(this.printBlockErrorLocation() + "FunctionStatementBlock should have only 1 statement (FunctionStatement)");
-		}
-		FunctionStatement fstmt = (FunctionStatement) _statements.get(0);
-			
-		// validate all function input parameters
-		ArrayList<DataIdentifier> inputValues = fstmt.getInputParams();
-        for( DataIdentifier inputValue : inputValues ) {
-            //check all input matrices have value type double
-            if( inputValue.getDataType()==DataType.MATRIX && inputValue.getValueType()!=ValueType.DOUBLE ) {
-                raiseValidateError("for function " + fstmt.getName() + ", input variable " + inputValue.getName() 
-                                 + " has an unsupported value type of " + inputValue.getValueType() + ".", false);
-            }
-        }
-		
-		// handle DML-bodied functions
-		if (!(fstmt instanceof ExternalFunctionStatement))
-		{			
-			// perform validate for function body
-			this._dmlProg = dmlProg;
-			for(StatementBlock sb : fstmt.getBody())
-			{
-				ids = sb.validate(dmlProg, ids, constVars, conditional);
-				constVars = sb.getConstOut();
-			}
-			if (fstmt.getBody().size() > 0)
-				_constVarsIn.putAll(fstmt.getBody().get(0).getConstIn());
-			
-			if (fstmt.getBody().size() > 1)
-				_constVarsOut.putAll(fstmt.getBody().get(fstmt.getBody().size()-1).getConstOut());
-			
-			// for each return value, check variable is defined and validate the return type
-			// if returnValue type known incorrect, then throw exception
-			ArrayList<DataIdentifier> returnValues = fstmt.getOutputParams();
-			for (DataIdentifier returnValue : returnValues){
-				DataIdentifier curr = ids.getVariable(returnValue.getName());
-				if (curr == null){
-					raiseValidateError("for function " + fstmt.getName() + ", return variable " + returnValue.getName() + " must be defined in function ", conditional);
-				}
-				
-				if (curr.getDataType() == DataType.UNKNOWN){
-					raiseValidateError("for function " + fstmt.getName() + ", return variable " + curr.getName() + " data type of " + curr.getDataType() + " may not match data type in function signature of " + returnValue.getDataType(), true);
-				}
-				
-				if (curr.getValueType() == ValueType.UNKNOWN){
-					raiseValidateError("for function " + fstmt.getName() + ", return variable " + curr.getName() + " data type of " + curr.getValueType() + " may not match data type in function signature of " + returnValue.getValueType(), true);
-				}
-				
-				if (curr.getDataType() != DataType.UNKNOWN && !curr.getDataType().equals(returnValue.getDataType()) ){
-					raiseValidateError("for function " + fstmt.getName() + ", return variable " + curr.getName() + " data type of " + curr.getDataType() + " does not match data type in function signature of " + returnValue.getDataType(), conditional);
-				}
-				
-				if (curr.getValueType() != ValueType.UNKNOWN && !curr.getValueType().equals(returnValue.getValueType())){
-					
-					// attempt to convert value type: handle conversion from scalar DOUBLE or INT
-					if (curr.getDataType() == DataType.SCALAR && returnValue.getDataType() == DataType.SCALAR){ 
-						if (returnValue.getValueType() == ValueType.DOUBLE){
-							if (curr.getValueType() == ValueType.INT){
-								IntIdentifier currIntValue = (IntIdentifier)constVars.get(curr.getName());
-								if (currIntValue != null){
-									DoubleIdentifier currDoubleValue = new DoubleIdentifier(currIntValue.getValue(), 
-											curr.getFilename(), curr.getBeginLine(), curr.getBeginColumn(), 
-											curr.getEndLine(), curr.getEndColumn());
-									constVars.put(curr.getName(), currDoubleValue);
-								}
-								LOG.warn(curr.printWarningLocation() + "for function " + fstmt.getName() 
-										+ ", return variable " + curr.getName() + " value type of " 
-										+ curr.getValueType() + " does not match value type in function signature of " 
-										+ returnValue.getValueType() + " but was safely cast");
-								curr.setValueType(ValueType.DOUBLE);
-								ids.addVariable(curr.getName(), curr);
-							}
-							else {
-								// THROW EXCEPTION -- CANNOT CONVERT
-								LOG.error(curr.printErrorLocation() + "for function " + fstmt.getName() 
-										+ ", return variable " + curr.getName() + " value type of " 
-										+ curr.getValueType() + " does not match value type in function signature of " 
-										+ returnValue.getValueType() + " and cannot safely cast value");
-								throw new LanguageException(curr.printErrorLocation() + "for function " 
-										+ fstmt.getName() + ", return variable " + curr.getName() 
-										+ " value type of " + curr.getValueType() 
-										+ " does not match value type in function signature of " 
-										+ returnValue.getValueType() + " and cannot safely cast value");
-							}
-						}
-						if (returnValue.getValueType() == ValueType.INT){
-							// THROW EXCEPTION -- CANNOT CONVERT
-							LOG.error(curr.printErrorLocation() + "for function " + fstmt.getName() 
-									+ ", return variable " + curr.getName() + " value type of " 
-									+ curr.getValueType() + " does not match value type in function signature of " 
-									+ returnValue.getValueType() + " and cannot safely cast " + curr.getValueType() 
-									+ " as " + returnValue.getValueType());
-							throw new LanguageException(curr.printErrorLocation() + "for function " + fstmt.getName() 
-									+ ", return variable " + curr.getName() + " value type of " + curr.getValueType() 
-									+ " does not match value type in function signature of " 
-									+ returnValue.getValueType() + " and cannot safely cast " + curr.getValueType() 
-									+ " as " + returnValue.getValueType());
-							
-						} 
-					}	
-					else {
-						LOG.error(curr.printErrorLocation() + "for function " + fstmt.getName() + ", return variable " + curr.getName() + " value type of " + curr.getValueType() + " does not match value type in function signature of " + returnValue.getValueType() + " and cannot safely cast double as int");
-						throw new LanguageException(curr.printErrorLocation() + "for function " + fstmt.getName() + ", return variable " + curr.getName() + " value type of " + curr.getValueType() + " does not match value type in function signature of " + returnValue.getValueType() + " and cannot safely cast " + curr.getValueType() + " as " + returnValue.getValueType());
-					}
-				}
-				
-			}
-		}
-		// handle external functions
-		else 
-		{
-			//validate specified attributes and attribute values
-			ExternalFunctionStatement efstmt = (ExternalFunctionStatement) fstmt;
-			efstmt.validateParameters(this);
-			
-			//validate child statements
-			this._dmlProg = dmlProg;
-			for(StatementBlock sb : efstmt.getBody()) 
-			{
-				ids = sb.validate(dmlProg, ids, constVars, conditional);
-				constVars = sb.getConstOut();
-			}
-		}
-		
-		
-
-		return ids;
-	}
-
-	public FunctionType getFunctionOpType()
-	{
-		FunctionType ret = FunctionType.UNKNOWN;
-		
-		FunctionStatement fstmt = (FunctionStatement) _statements.get(0);
-		if (fstmt instanceof ExternalFunctionStatement) 
-		{
-			ExternalFunctionStatement efstmt = (ExternalFunctionStatement) fstmt;
-			String execType = efstmt.getOtherParams().get(ExternalFunctionStatement.EXEC_TYPE);
-			if( execType!=null ){
-				if(execType.equals(ExternalFunctionStatement.IN_MEMORY))
-					ret = FunctionType.EXTERNAL_MEM;
-				else
-					ret = FunctionType.EXTERNAL_FILE;
-			}
-		}
-		else
-		{
-			ret = FunctionType.DML; 
-		}
-		
-		return ret;
-	}
-	
-	public VariableSet initializeforwardLV(VariableSet activeInPassed) throws LanguageException {
-		
-		FunctionStatement fstmt = (FunctionStatement)_statements.get(0);
-		if (_statements.size() > 1){
-			LOG.error(this.printBlockErrorLocation() + "FunctionStatementBlock should have only 1 statement (while statement)");
-			throw new LanguageException(this.printBlockErrorLocation() + "FunctionStatementBlock should have only 1 statement (while statement)");
-		}
-		
-		_read = new VariableSet();
-		_gen = new VariableSet();
-				
-		VariableSet current = new VariableSet();
-		current.addVariables(activeInPassed);
-		
-		for( StatementBlock sb : fstmt.getBody() )
-		{
-			current = sb.initializeforwardLV(current);	
-			
-			// for each generated variable in this block, check variable not killed
-			// in prior statement block in while stmt blody
-			for (String varName : sb._gen.getVariableNames()){
-				
-				// IF the variable is NOT set in the while loop PRIOR to this stmt block, 
-				// THEN needs to be generated
-				if (!_kill.getVariableNames().contains(varName)){
-					_gen.addVariable(varName, sb._gen.getVariable(varName));	
-				}
-			}
-			
-			_read.addVariables(sb._read);
-			_updated.addVariables(sb._updated);
-		
-			// only add kill variables for statement blocks guaranteed to execute
-			if (!(sb instanceof WhileStatementBlock) && !(sb instanceof ForStatementBlock) ){
-				_kill.addVariables(sb._kill);
-			}	
-		}
-		
-		// activeOut includes variables from passed live in and updated in the while body
-		_liveOut = new VariableSet();
-		_liveOut.addVariables(current);
-		_liveOut.addVariables(_updated);
-		return _liveOut;
-	}
-
-	public VariableSet initializebackwardLV(VariableSet loPassed) throws LanguageException{
-		
-		FunctionStatement wstmt = (FunctionStatement)_statements.get(0);
-			
-		VariableSet lo = new VariableSet();
-		lo.addVariables(loPassed);
-		
-		// calls analyze for each statement block in while stmt body
-		int numBlocks = wstmt.getBody().size();
-		for (int i = numBlocks - 1; i >= 0; i--){
-			lo = wstmt.getBody().get(i).analyze(lo);
-		}	
-		
-		VariableSet loReturn = new VariableSet();
-		loReturn.addVariables(lo);
-		return loReturn;
-	
-	}
-	
-	
-	public ArrayList<Hop> get_hops() throws HopsException {
-		
-		if (_hops != null && _hops.size() > 0){
-			LOG.error(this.printBlockErrorLocation() + "there should be no HOPs associated with the FunctionStatementBlock");
-			throw new HopsException(this.printBlockErrorLocation() + "there should be no HOPs associated with the FunctionStatementBlock");
-		}
-		
-		return _hops;
-	}
-	
-	
-	public VariableSet analyze(VariableSet loPassed) throws LanguageException{
-		LOG.error(this.printBlockErrorLocation() + "Both liveIn and liveOut variables need to be specified for liveness analysis for FunctionStatementBlock");
-		throw new LanguageException(this.printBlockErrorLocation() + "Both liveIn and liveOut variables need to be specified for liveness analysis for FunctionStatementBlock");	
-	}
-	
-	
-	public VariableSet analyze(VariableSet liPassed, VariableSet loPassed) throws LanguageException{
- 		
-		VariableSet candidateLO = new VariableSet();
-		candidateLO.addVariables(loPassed);
-		candidateLO.addVariables(_gen);
-		
-		VariableSet origLiveOut = new VariableSet();
-		origLiveOut.addVariables(_liveOut);
-		
-		_liveOut = new VariableSet();
-	 	for (String name : candidateLO.getVariableNames()){
-	 		if (origLiveOut.containsVariable(name)){
-	 			_liveOut.addVariable(name, candidateLO.getVariable(name));
-	 		}
-	 	}
-	 	
-		initializebackwardLV(_liveOut);
-		
-		// Cannot remove kill variables
-		_liveIn = new VariableSet();
-		_liveIn.addVariables(liPassed);
-		
-		VariableSet liveInReturn = new VariableSet();
-		liveInReturn.addVariables(_liveIn);
-		
-		return liveInReturn;
-	}
-	
-	public void setRecompileOnce( boolean flag ) {
-		_recompileOnce = flag;
-	}
-	
-	public boolean isRecompileOnce() {
-		return _recompileOnce;
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/parser/Identifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/parser/Identifier.java b/src/main/java/com/ibm/bi/dml/parser/Identifier.java
deleted file mode 100644
index 522b513..0000000
--- a/src/main/java/com/ibm/bi/dml/parser/Identifier.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package com.ibm.bi.dml.parser;
-
-import java.util.HashMap;
-
-import com.ibm.bi.dml.parser.LanguageException.LanguageErrorCodes;
-
-public abstract class Identifier extends Expression
-{
-	
-	protected DataType _dataType;
-	protected ValueType _valueType;
-	protected long _dim1;
-	protected long _dim2;
-	protected long _rows_in_block;
-	protected long _columns_in_block;
-	protected long _nnz;
-	protected FormatType _formatType;
-		
-	public Identifier(Identifier i)
-	{
-		_dataType = i.getDataType();
-		_valueType = i.getValueType();
-		if( i instanceof IndexedIdentifier ) {
-			IndexedIdentifier ixi = (IndexedIdentifier)i; 
-			_dim1 = ixi.getOrigDim1();
-			_dim2 = ixi.getOrigDim2();
-		}
-		else {
-			_dim1 = i.getDim1();
-			_dim2 = i.getDim2();
-		}
-		_rows_in_block = i.getRowsInBlock();
-		_columns_in_block = i.getColumnsInBlock();
-		_nnz = i.getNnz();
-		_formatType = i.getFormatType();
-		
-		// copy position information
-		setBeginLine(i.getBeginLine());
-		setBeginColumn(i.getBeginColumn());
-		setEndLine(i.getEndLine());
-		setEndColumn(i.getEndColumn());
-	}
-	
-	public Identifier()
-	{
-		_dim1 = -1;
-		_dim2 = -1;
-		_dataType = DataType.UNKNOWN;
-		_valueType = ValueType.UNKNOWN;
-		_rows_in_block = -1;
-		_columns_in_block = -1;
-		_nnz = -1;
-		setOutput(this);
-		_formatType = null;
-	}
-	
-	public void setProperties(Identifier i)
-	{			
-		if (i == null) 
-			return;
-		
-		_dataType = i.getDataType();
-		_valueType = i.getValueType();
-		if (i instanceof IndexedIdentifier) {
-			_dim1 = ((IndexedIdentifier)i).getOrigDim1();
-			_dim2 = ((IndexedIdentifier)i).getOrigDim2();
-		}
-		else {
-			_dim1 = i.getDim1();
-			_dim2 = i.getDim2();
-		}
-		_rows_in_block = i.getRowsInBlock();
-		_columns_in_block = i.getColumnsInBlock();
-		_nnz = i.getNnz();
-		_formatType = i.getFormatType();
-				
-	}
-	
-	public void setDimensionValueProperties(Identifier i)
-	{
-		if (i instanceof IndexedIdentifier) {
-			IndexedIdentifier ixi = (IndexedIdentifier)i; 
-			_dim1 = ixi.getOrigDim1();
-			_dim2 = ixi.getOrigDim2();
-		}
-		else {
-			_dim1 = i.getDim1();
-			_dim2 = i.getDim2();
-		}
-		_nnz = i.getNnz();
-		_dataType = i.getDataType();
-		_valueType = i.getValueType();
-	}
-	
-	public void setDataType(DataType dt){
-		_dataType = dt;
-	}
-	
-	public void setValueType(ValueType vt){
-		_valueType = vt;
-	}
-	
-	public void setFormatType(FormatType ft){
-		_formatType = ft;
-	}
-	
-	public void setDimensions(long dim1, long dim2){
-		_dim1 = dim1;
-		_dim2 = dim2;
-	}
-		
-	public void setBlockDimensions(long dim1, long dim2){
-		 _rows_in_block = dim1;
-		 _columns_in_block = dim2;
-	}
-	
-	public void setNnz(long nnzs){
-		_nnz = nnzs;
-	}
-	
-	public long getDim1(){
-		return _dim1;
-	}
-	
-	public long getDim2(){
-		return _dim2;
-	}
-	
-	public DataType getDataType(){
-		return _dataType;
-	}
-	
-	public ValueType getValueType(){
-		return _valueType;
-	}
-	
-	public FormatType getFormatType(){
-		return _formatType;
-	}
-	
-	public long getRowsInBlock(){
-		return _rows_in_block;
-	}
-	
-	public long getColumnsInBlock(){
-		return _columns_in_block;
-	}
-	
-	public long getNnz(){
-		return _nnz;
-	}
-	
-	@Override
-	public void validateExpression(HashMap<String,DataIdentifier> ids, HashMap<String,ConstIdentifier> constVars, boolean conditional) 
-		throws LanguageException 
-	{
-		
-		if( getOutput() instanceof DataIdentifier ) {
-			
-			// set properties for Data identifier
-			String name = ((DataIdentifier)this.getOutput()).getName();
-			Identifier id = ids.get(name);
-			if ( id == null ){
-				//undefined variables are always treated unconditionally as error in order to prevent common script-level bugs
-				raiseValidateError("Undefined Variable (" + name + ") used in statement", false, LanguageErrorCodes.INVALID_PARAMETERS);
-			}
-			this.getOutput().setProperties(id);
-			
-			// validate IndexedIdentifier -- which is substype of DataIdentifer with index
-			if (this.getOutput() instanceof IndexedIdentifier){
-				
-				// validate the row / col index bounds (if defined)
-				IndexedIdentifier indexedIdentiferOut = (IndexedIdentifier)this.getOutput();
-				
-				if (indexedIdentiferOut.getRowLowerBound() != null) {
-					indexedIdentiferOut.getRowLowerBound().validateExpression(ids, constVars, conditional);
-					
-					Expression tempExpr = indexedIdentiferOut.getRowLowerBound(); 
-					if (tempExpr.getOutput().getDataType() == Expression.DataType.MATRIX){	
-						raiseValidateError("Matrix values for row lower index bound are not supported, which includes indexed identifiers.", conditional);
-					}
-					
-				}
-				if (indexedIdentiferOut.getRowUpperBound() != null) {
-					indexedIdentiferOut.getRowUpperBound().validateExpression(ids, constVars, conditional);
-					
-					Expression tempExpr = indexedIdentiferOut.getRowUpperBound(); 
-					if (tempExpr.getOutput().getDataType() == Expression.DataType.MATRIX){	
-						raiseValidateError("Matrix values for row upper index bound are not supported, which includes indexed identifiers.", conditional);
-					}
-				
-				}
-				if (indexedIdentiferOut.getColLowerBound() != null) {
-					indexedIdentiferOut.getColLowerBound().validateExpression(ids,constVars, conditional);	
-				
-					Expression tempExpr = indexedIdentiferOut.getColLowerBound(); 
-					if (tempExpr.getOutput().getDataType() == Expression.DataType.MATRIX){	
-						raiseValidateError("Matrix values for column lower index bound are not supported, which includes indexed identifiers.", conditional);
-					}
-				
-				}
-				if (indexedIdentiferOut.getColUpperBound() != null) {
-					indexedIdentiferOut.getColUpperBound().validateExpression(ids, constVars, conditional);
-					
-					Expression tempExpr = indexedIdentiferOut.getColUpperBound(); 
-					if (tempExpr.getOutput().getDataType() == Expression.DataType.MATRIX){	
-						raiseValidateError("Matrix values for column upper index bound are not supported, which includes indexed identifiers.", conditional);
-					}
-				
-				}
-				
-				IndexPair updatedIndices = ((IndexedIdentifier)this.getOutput()).calculateIndexedDimensions(ids, constVars, conditional);
-				((IndexedIdentifier)this.getOutput()).setDimensions(updatedIndices._row, updatedIndices._col);
-				
-			}
-							
-		} else {
-			this.getOutput().setProperties(this.getOutput());
-		}
-	}
-	
-	public void computeDataType() {
-				
-		if ((_dim1 == 0) && (_dim2 == 0)) {
-			_dataType = DataType.SCALAR;
-		} else if ((_dim1 >= 1) || (_dim2 >= 1)){
-			// Vector also set as matrix
-			// Data type is set as matrix, if either of dimensions is -1
-			_dataType = DataType.MATRIX;
-		} else _dataType = DataType.UNKNOWN;	 
-		
-	}
-	
-	public void setBooleanProperties(){
-		_dataType = DataType.SCALAR;
-		_valueType = ValueType.BOOLEAN;
-		_dim1 = 0;
-		_dim2 = 0;
-		_rows_in_block = 0;
-		_columns_in_block = 0;
-		_nnz = -1;
-		_formatType = null;
-	}
-	
-	public void setIntProperties(){
-		_dataType = DataType.SCALAR;
-		_valueType = ValueType.INT;
-		_dim1 = 0;
-		_dim2 = 0;
-		_rows_in_block = 0;
-		_columns_in_block = 0;
-		_nnz = -1;
-		_formatType = null;
-	}
-	
-	
-	public boolean isScalarBoolean(){
-		return (_valueType == ValueType.BOOLEAN) && (_dataType == DataType.SCALAR);
-	}
-	
-	public boolean dimsKnown(){
-		return ( _dim1 > 0 && _dim2 > 0);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/parser/IfStatement.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/parser/IfStatement.java b/src/main/java/com/ibm/bi/dml/parser/IfStatement.java
deleted file mode 100644
index 620d9de..0000000
--- a/src/main/java/com/ibm/bi/dml/parser/IfStatement.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- */
-
-package com.ibm.bi.dml.parser;
-
-import java.util.ArrayList;
-
-
-
-public class IfStatement extends Statement
-{
-	
-	private ConditionalPredicate _predicate;
-	private ArrayList<StatementBlock> _ifBody;
-	private ArrayList<StatementBlock> _elseBody;
-	
-	public Statement rewriteStatement(String prefix) throws LanguageException{
-		LOG.error(this.printErrorLocation() + "should not call rewriteStatement for IfStatement");
-		throw new LanguageException(this.printErrorLocation() + "should not call rewriteStatement for IfStatement");
-	}
-	
-	public IfStatement(){
-		 _predicate = null;
-		 _ifBody = new ArrayList<StatementBlock>();
-		 _elseBody = new ArrayList<StatementBlock>();
-	}
-	
-	public void setConditionalPredicate(ConditionalPredicate pred){
-		_predicate = pred;
-	}
-	
-	
-	public void addStatementBlockIfBody(StatementBlock sb){
-		_ifBody.add(sb);
-	}
-	
-	public void addStatementBlockElseBody(StatementBlock sb){
-		_elseBody.add(sb);
-	}
-	
-	public ConditionalPredicate getConditionalPredicate(){
-		return _predicate;
-	}
-	
-	public ArrayList<StatementBlock> getIfBody(){
-		return _ifBody;
-	}
-	
-	public ArrayList<StatementBlock> getElseBody(){
-		return _elseBody;
-	}
-	
-	public void setIfBody(ArrayList<StatementBlock> body){
-		_ifBody = body;
-	}
-	
-	public void setElseBody(ArrayList<StatementBlock> body){
-		_elseBody = body;
-	}
-	
-	
-	@Override
-	public boolean controlStatement() {
-		return true;
-	}
-	
-	public void initializeforwardLV(VariableSet activeIn) throws LanguageException{
-		LOG.error(this.printErrorLocation() + "should never call initializeforwardLV for IfStatement");
-		throw new LanguageException(this.printErrorLocation() + "should never call initializeforwardLV for IfStatement");
-		
-	}
-
-	public VariableSet initializebackwardLV(VariableSet lo) throws LanguageException{
-		LOG.error(this.printErrorLocation() + "should never call initializeforwardLV for IfStatement");
-		throw new LanguageException(this.printErrorLocation() + "should never call initializeforwardLV for IfStatement");
-		
-	}
-
-	public void mergeStatementBlocksIfBody(){
-		_ifBody = StatementBlock.mergeStatementBlocks(_ifBody);
-	}
-	
-	public void mergeStatementBlocksElseBody(){
-		if (!_elseBody.isEmpty())
-			_elseBody = StatementBlock.mergeStatementBlocks(_elseBody);
-	}
-	
-	public VariableSet variablesReadIfBody() {
-		
-		return null;
-		
-	}
-	
-	public VariableSet variablesReadElseBody() {
-		
-		LOG.warn("WARNING: line " + this.getBeginLine() + ", column " + this.getBeginColumn() + " --  should not call variablesReadElseBody from IfStatement ");
-		return null;
-	}
-	
-	public  VariableSet variablesUpdatedIfBody() {
-		
-		LOG.warn("WARNING: line " + this.getBeginLine() + ", column " + this.getBeginColumn() + " --  should not call variablesUpdatedIfBody from IfStatement ");
-		return null;
-	}
-	
-	public  VariableSet variablesUpdatedElseBody() {
-		
-		LOG.warn("WARNING: line " + this.getBeginLine() + ", column " + this.getBeginColumn() + " --  should not call variablesUpdatedElseBody from IfStatement ");
-		return null;
-	}
-	
-	
-	public String toString(){
-		StringBuilder sb = new StringBuilder();
-		sb.append("if ( ");
-		sb.append(_predicate.toString());
-		sb.append(") { \n");
-		for (StatementBlock block : _ifBody){
-			sb.append(block.toString());
-		}
-		sb.append("}\n");
-		if (!_elseBody.isEmpty()){
-			sb.append(" else { \n");
-			for (StatementBlock block : _elseBody){
-				sb.append(block.toString());
-			}
-			sb.append("}\n");
-		}
-		return sb.toString();
-	}
-
-	
-	public VariableSet variablesKill() {
-		return new VariableSet();
-	}
-
-	@Override
-	public VariableSet variablesRead() {
-		LOG.warn("WARNING: line " + this.getBeginLine() + ", column " + this.getBeginColumn() + " --  should not call variablesRead from IfStatement ");
-		return null;
-	}
-
-	@Override
-	public VariableSet variablesUpdated() {
-		LOG.warn("WARNING: line " + this.getBeginLine() + ", column " + this.getBeginColumn() + " --  should not call variablesUpdated from IfStatement ");
-		return null;
-	}
-}