s3games.engine.expr

## Class Expr

- java.lang.Object
- - s3games.engine.expr.Expr

-     public abstract class Expr
      extends java.lang.Object

  Abstract class for all expression types. Contains the enumerations of all internal operators and functions.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Expr.internalFunction` list of all supported internal functions
    `static class` | `Expr.operatorType` list of all supported internal operators

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Expr()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Expr` | `append(Expr expr)` Allows appending a new expression to this expression, thus getting a Expr_LIST if it was not already.
    `static Expr` | `booleanExpr(boolean b)` constructor method - returns a boolean expression that holds the specified logical value
    `boolean` | `equals(Expr other, Context context)` compares if the values of this expression and the other expression are the same
    `abstract Expr` | `eval(Context context)` evaluates this expression and returns the resulting value
    `int` | `getInt()` stub to be overriden by expressions that are of numeric type, otherwise throws exception
    `static Expr.internalFunction` | `getInternalFunction(java.lang.String fn)`
    `static Expr.operatorType` | `getOperatorType(java.lang.String op)` convert an operator lexeme to the respective operator
    `java.lang.String` | `getStr()` stub to be overriden by expressions that are of string type, otherwise throws exception
    `boolean` | `isFalse()` stub to be overriden by expressions that are of boolean type, otherwise returns false note: here we do not use closed-world assumption: anything else than false is not false!
    `boolean` | `isTrue()` stub to be overriden by expressions that are of boolean type, otherwise returns false
    `boolean` | `matches(IndexedName name, Context context)` stub to be overriden by expressions that are of string type - it should set the variables in the context, if the expression contains variable references
    `boolean` | `matches(int i, Context context)` stub to be overriden by expressions that are of numeric type - it should set the variables in the context, if the expression is a variable
    `boolean` | `matches(java.lang.String s, Context context)` stub to be overriden by expressions that are of string type - it should set the variables in the context, if the expression contains variable references
    `static Expr` | `numExpr(int num)` constructor method - returns a numerical expression that holds the specified number
    `static Expr` | `parseExpr(java.lang.String ln)` Parse the expression from a string representation as appears in the game specification file.
    `static Expr` | `strExpr(java.lang.String str)` constructor method - returns a string expression that holds the specified string

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Expr

          public Expr()

  - ### Method Detail

    - #### append

          public Expr append(Expr expr)

      Allows appending a new expression to this expression, thus getting a Expr_LIST if it was not already. It is used for representing multi-line named expressions.

    - #### parseExpr

          public static Expr parseExpr(java.lang.String ln)
                                throws java.lang.Exception

      Parse the expression from a string representation as appears in the game specification file. First, the expression is broken into a list of lexemes, which are then parsed into internal expression representation
      Throws:
        `java.lang.Exception`

    - #### getOperatorType

          public static Expr.operatorType getOperatorType(java.lang.String op)

      convert an operator lexeme to the respective operator

    - #### getInternalFunction

          public static Expr.internalFunction getInternalFunction(java.lang.String fn)

    - #### numExpr

          public static Expr numExpr(int num)

      constructor method - returns a numerical expression that holds the specified number

    - #### strExpr

          public static Expr strExpr(java.lang.String str)

      constructor method - returns a string expression that holds the specified string

    - #### booleanExpr

          public static Expr booleanExpr(boolean b)

      constructor method - returns a boolean expression that holds the specified logical value

    - #### getInt

          public int getInt()
                     throws java.lang.Exception

      stub to be overriden by expressions that are of numeric type, otherwise throws exception
      Throws:
        `java.lang.Exception`

    - #### getStr

          public java.lang.String getStr()
                                  throws java.lang.Exception

      stub to be overriden by expressions that are of string type, otherwise throws exception
      Throws:
        `java.lang.Exception`

    - #### isTrue

          public boolean isTrue()

      stub to be overriden by expressions that are of boolean type, otherwise returns false

    - #### isFalse

          public boolean isFalse()

      stub to be overriden by expressions that are of boolean type, otherwise returns false note: here we do not use closed-world assumption: anything else than false is not false!

    - #### matches

          public boolean matches(java.lang.String s,
                        Context context)

      stub to be overriden by expressions that are of string type - it should set the variables in the context, if the expression contains variable references

    - #### matches

          public boolean matches(int i,
                        Context context)

      stub to be overriden by expressions that are of numeric type - it should set the variables in the context, if the expression is a variable

    - #### matches

          public boolean matches(IndexedName name,
                        Context context)

      stub to be overriden by expressions that are of string type - it should set the variables in the context, if the expression contains variable references

    - #### eval

          public abstract Expr eval(Context context)
                             throws java.lang.Exception

      evaluates this expression and returns the resulting value
      Throws:
        `java.lang.Exception`

    - #### equals

          public boolean equals(Expr other,
                       Context context)
                         throws java.lang.Exception

      compares if the values of this expression and the other expression are the same
      Throws:
        `java.lang.Exception`