Packages

  • package root

    This is the documentation for the Evaluator project (see GitHub).

    This is the documentation for the Evaluator project (see GitHub).

    The main package net.totietje.evaluator. The net.totietje.complex package contains an example usage of this package, which may also be useful.

    Definition Classes
    root
  • package net
    Definition Classes
    root
  • package totietje
    Definition Classes
    net
  • package complex

    This package is centered around the Complex class, with a focus on complex arithmetic.

    This package is centered around the Complex class, with a focus on complex arithmetic.

    The ComplexEvaluator object contains the evaluate(String) method for parsing a mathematical expression as a function of complex numbers.

    Definition Classes
    totietje
    Examples:
    1. val function = ComplexEvaluator.parse("log(i * x) - i * log(y)")

    2. ,
    3. val sine = Complex(3, 4).sin

  • package evaluator

    The evaluator package is designed to simplify the process of parsing a string.

    The evaluator package is designed to simplify the process of parsing a string.

    The work of parsing a string is reduced to just tokenizing an expression, that is, breaking it down into its principal parts. The Evaluator class will handle the rest.

    The AbstractEvaluator makes this even easier, though it is only applicable in some situations.

    Definition Classes
    totietje
    See also

    AbstractEvaluator

    Evaluator

  • AbstractEvaluator
  • Associativity
  • EvaluationException
  • Evaluator
  • Token
p

net.totietje

evaluator

package evaluator

The evaluator package is designed to simplify the process of parsing a string.

The work of parsing a string is reduced to just tokenizing an expression, that is, breaking it down into its principal parts. The Evaluator class will handle the rest.

The AbstractEvaluator makes this even easier, though it is only applicable in some situations.

Source
package.scala
See also

AbstractEvaluator

Evaluator

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. evaluator
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract class AbstractEvaluator [R] extends Evaluator[R]

    A skeletal implementation of the Evaluator class to avoid duplication of common logic.

    A skeletal implementation of the Evaluator class to avoid duplication of common logic.

    This class is applicable if, and only if, for each character it is unambiguous whether it is part of a word or special character. That is, every character can be either a special character, or part of a word, but not both. Furthermore, neither special characters not words can contain whitespace.

    A 'special character' here is a standalone character that has a special meaning. Special characters cannot be part of values or words. For example, + would be a special character.

    A 'word' here is a meaningful string of characters that do not contain any whitespace or special characters. For example, the constant pi is a word, as are functions such as sin. Words cannot contain special characters or they could be mistaken for two words - the word a+b would be split into a, +, and b.

    R

    What the string should be evaluated to

  2. sealed trait Associativity extends AnyRef

    This represents the associativity of an operator.

    This represents the associativity of an operator.

    Operators can be either left associative or right associative. This indicated the order in which operators of the same precedence are evaluated in the absence of parentheses - from left to right or from right to left.

    For example, the / operator is left associative, so

    2 / 2 / 2 = (2 / 2) / 2

    However, the ^ operator is right associative, so

    2 ^ 2 ^ 2 = 2 ^ (2 ^ 2)
  3. case class EvaluationException (message: String = "Syntax error", cause: Throwable = null) extends Exception with Product with Serializable

    This is thrown by an Evaluator when it is parsing an expression with a syntax error.

    This is thrown by an Evaluator when it is parsing an expression with a syntax error.

    message

    The detailed message

    cause

    The cause

  4. abstract class Evaluator [R] extends AnyRef

    An Evaluator is a string parser and evaluator.

    An Evaluator is a string parser and evaluator.

    This class is flexible, allowing a user to define their own syntax. An example use might be to parse maths expressions, such as (1 + 2) ^ 3.

    R

    What the string should be evaluated to

    See also

    ComplexEvaluator

  5. sealed trait Token [R] extends AnyRef

    Represents one of the base parts of an expression parsed by an Evaluator.

    Represents one of the base parts of an expression parsed by an Evaluator.

    R

    The type that the evaluator should return after evaluating the tokens

Value Members

  1. object Associativity

    Contains the instances of the associativity trait.

  2. object Token

    Contains all the different types of tokens.

Inherited from AnyRef

Inherited from Any

Ungrouped