1
0
mirror of https://github.com/DanilaFe/abacus synced 2026-01-31 19:15:20 +00:00

Add Applicable to Operator, therby removing the need for Functions in it

This commit is contained in:
2017-08-25 14:55:05 -07:00
parent 1f0addccea
commit d04adf4da5
7 changed files with 80 additions and 43 deletions

View File

@@ -0,0 +1,15 @@
package org.nwapw.abacus.function
import org.nwapw.abacus.number.NumberInterface
/**
* An operator that operates on NumberImplementations.
*
* This is simply an alias for Operator<NumberInterface, NumberInterface>.
* @param associativity the associativity of the operator.
* @param type the type of the operator (binary, unary, etc)
* @param precedence the precedence of the operator.
*/
abstract class NumberOperator(associativity: OperatorAssociativity, type: OperatorType,
precedence: Int) :
Operator<NumberInterface, NumberInterface>(associativity, type, precedence)

View File

@@ -3,12 +3,11 @@ package org.nwapw.abacus.function
/**
* A single operator that can be used by Abacus.
*
* This is a data class that holds the information about a single operator, such as a plus or minus.
* This is a class that holds the information about a single operator, such as a plus or minus.
*
* @param associativity the associativity of this operator, used for order of operations;.
* @param type the type of this operator, used for parsing (infix / prefix / postfix and binary / unary)
* @param precedence the precedence of this operator, used for order of operations.
* @param function the function this operator applies to its arguments.
*/
data class Operator(val associativity: OperatorAssociativity, val type: OperatorType,
val precedence: Int, val function: Function)
abstract class Operator<T: Any, O: Any>(val associativity: OperatorAssociativity, val type: OperatorType,
val precedence: Int) : Applicable<T, O>()