/*
 * #%L
 * SciJava mathematical expression parser.
 * %%
 * Copyright (C) 2015 Board of Regents of the University of
 * Wisconsin-Madison.
 * %%
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * #L%
 */

package org.scijava.sjep;

import java.util.Arrays;
import java.util.List;

import org.scijava.sjep.Operator.Associativity;

import static org.scijava.sjep.Operator.Associativity.EITHER;
import static org.scijava.sjep.Operator.Associativity.LEFT;
import static org.scijava.sjep.Operator.Associativity.RIGHT;

/**
 * A collection of standard {@link Operator}s.
 *
 * @author Curtis Rueden
 */
public final class Operators {

	// -- unary --

	public static final Operator NEG = op("-", 1, RIGHT, 2);

	// -- multiplicative --

	public static final Operator MUL = op("*", 2, EITHER, 3);
	public static final Operator DIV = op("/", 2, LEFT, 3);

	// -- additive --

	public static final Operator ADD = op("+", 2, EITHER, 2);
	public static final Operator SUB = op("-", 2, LEFT, 2);

	// -- extra --

	public static final Operator POW = op("^", 2, RIGHT, 4);

	private Operators() {
		// NB: Prevent instantiation of utility class.
	}

	/** Gets the standard list of operators. */
	public static List<Operator> standardList() {
		return Arrays.asList(Operators.NEG, Operators.ADD, Operators.SUB,
			Operators.MUL, Operators.DIV, Operators.POW);
	}

	// -- Helper methods --

	private static Operator op(final String symbol, final int arity,
		final Associativity associativity, final double precedence)
	{
		return new DefaultOperator(symbol, arity, associativity, precedence);
	}

}

@@ -1584,70 +1584,8 @@
 y;%0A%0A
-import static org.scijava.sjep.Operator.Associativity.EITHER;%0A
 impo
@@ -1966,22 +1966,20 @@
 %22*%22, 2, 
-EITHER
+LEFT
 , 3);%0A%09p
@@ -2105,14 +2105,12 @@
  2, 
-EITHER
+LEFT
 , 2)

use LEFT association for ADD and MUL