ConfigExpression

Description

abstract class Tinman.Core.Config.ConfigExpression

Derived from

ConfigNode abstract

Abstract base class that represent expressions in a configuration script.

The default implementation of IsExpressionTypeConstant returns true.

Public / Constructors

Parse

2 overloads


public static method Parse1 → (3)

source in : string

[not-null]
The expression source code.

scope opt : IConfigScope = null

Optional type bag for resolving variable types.

expectedType opt : ConfigType = null

Optional expected type.

returns → ConfigExpression

The parsed expression.

Parses a configuration value expression.

ValidatingException

If one or more parsing errors have occurred.


public static method Parse2 → (4)

source in : string

[not-null]
The expression source code.

scope in : IConfigScope

Optional type bag for resolving variable types.

expectedType in : ConfigType

Optional expected type.

current in : Path

Optional directory to use for resolving relative path values that start with a '.' (e.g. <./a/b.txt>). All other relative paths (e.g. <a/b.txt>) will remain unchanged. If null, the current filesystem directory will be used.

returns → ConfigExpression

The parsed expression.

Parses a configuration value expression.

ValidatingException

If one or more parsing errors have occurred.

Parse​Ast


public static method ParseAst → (5)

input in : ICodeInput

[not-null]
The character input.

ast in : AstNode

[not-null]
The AST root node.

scope opt : IConfigScope = null

Optional type bag for resolving variable types.

expectedType opt : ConfigType = null

Optional expected type.

current opt : Path = null

Optional directory to use for resolving relative path values that start with a '.' (e.g. <./a/b.txt>). All other relative paths (e.g. <a/b.txt>) will remain unchanged. If null, the current filesystem directory will be used. Defaults to null.

returns → ConfigExpression

The parsed expression.

Creates a configuration value expression.

ValidatingException

If ast in is malformed.

Public / Methods

Check​Qualified​Identifier


public virtual method CheckQualifiedIdentifier → (1)

parts opt : ICollector<string> = null

The collector of name parts or null.

returns → bool

true if this expression builds a qualified identifier, false if not.

Can this expression be interpreted as a qualified identifier (e.g. Some.Name.With.Parts)?

Evaluate


public method Evaluate → (2)

scope opt : IConfigValueBag = null

The evaluation scope or null.

value opt : ConfigValue = null

The ConfigValue to store the resulting value in. If null, a new config value is created.

returns → ConfigValue

The ConfigValue that holds the evaluation result.

Evaluates this expression as if it is the right side of an assignment.

ConfigException

If an error has occurred while evaluating this expression (e.g. identifier not found).

Evaluate​Assignable


public method EvaluateAssignable → (1)

scope opt : IConfigValueBag = null

The evaluation scope or null.

returns → ConfigValue

The ConfigValue that holds the evaluation result or ConfigValue.Invalid if this expression cannot be an assignment target.

Evaluates this expression as if it is the left side of an assignment.

ConfigException

If an error has occurred while evaluating this expression (e.g. identifier not found).

Evaluate​References


public method EvaluateReferences → (2)

scope in : IConfigValueBag

[not-null]
The evaluation scope.

members opt : IVector<ConfigMember> = null

Output for collected references or null.

returns → IVectorConst<ConfigMember>

The collected config members.

Collects all config members that are referenced by this expression.

Expression​Type​Lazy


public method ExpressionTypeLazy → (1)

func opt : ConfigTypeDelegate = null

Optional delegate to call on the resolved expression type.

returns → ConfigType

The resulting config type.

Returns the type of this expression.

The actual config type is determined lazily by querying ExpressionType at a later point in time.

Is​Assignable​To


public method IsAssignableTo → (1)

other in : ConfigType

[not-null]
The other type.

returns → bool

true if this type is assignable to the given one, false if not.

Checks if this config expression if assignable to the given type.

Is​Convertible​To


public method IsConvertibleTo → (2)

other in : ConfigType

[not-null]
The other type.

always opt : bool = false

When set to true, the method will return true iff this type is always convertible to other in. When set to false, this method will return true even if a conversion might fail at runtime, causing a ConfigException to be thrown (e.g. invalid string to number).

returns → bool

true if this type is convertible to the given one, false if not.

Checks if this config expression if convertible to the given type.

Public / Attributes

Expression​Type


public attribute ExpressionType → (get)

value : ConfigType

[not-null]
The config type or ConfigType.Invalid if there are semantic errors, for example unresolved identifiers.

Returns the type of this expression.

Is​Call


[Constant]
public virtual attribute IsCall → (get)

value : bool

true if this expression calls a function, false if not.

Is this a function call expression?

Is​Expression​Type​Constant


[Constant]
public virtual attribute IsExpressionTypeConstant → (get)

value : bool

true if ExpressionType will always return the same ConfigType object,
false if ExpressionType may return different ConfigType objects.

Does this expression have a constant type?

Is​Null


public virtual attribute IsNull → (get)

value : bool

true if this expression is a null literal, false if not.

Is this expression a null literal?

Precedence


[Constant]
public abstract attribute Precedence → (get)

value : int32

The operator precedence.

The operator precedence.

0  -> For each expression
1  -> Conditional expression
2  -> Binary expression: conditional or
3  -> Binary expression: conditional and
4  -> Binary expression: logical or
5  -> Binary expression: logical xor
6  -> Binary expression: logical and
7  -> Binary expression: equality
8  -> Binary expression: comparision
9  -> Binary expression: shift
10 -> Binary expression: additive
11 -> Binary expression: multiplicative
12 -> Binary expression: power, root
13 -> Unary expression
14 -> Primary and terminal expressions

Qualified​Identifier


public attribute QualifiedIdentifier → (get)

value : string

The qualified identifier or null if this expression does not have a corresponding qualified name.

Returns the qualified identifier that corresponds to this expression.

Protected / Methods

Do​Evaluate


protected abstract method DoEvaluate → (2)

scope in : IConfigValueBag

The scope to use.

value in : ConfigValue

The output config value or null if the expression shall be evaluated to an assignment target.

returns → ConfigValue

The resulting config value.

Evaluates this expression.

ConfigException

If an error has occurred while evaluating this expression (e.g. identifier not found).

Do​Evaluate​References


protected abstract method DoEvaluateReferences → (2)

scope in : IConfigValueBag

The scope to use.

members in : IVector<ConfigMember>

The list of config type references to populate.

Determines the config types that are referenced by this expression.

Do​Write​Source​Code


protected abstract method DoWriteSourceCode → (2)

writer in : SourceCodeWriter

The source code writer (never null).

context in : Context

The context object (never null).

Produces source code by feeding the given source code writer.

IOException

If an I/O error occurs while emitting source code to writer in.

Protected / Attributes

Do​Expression​Type


protected abstract attribute DoExpressionType → (get)

value : ConfigType

[not-null]
The config type or ConfigType.Invalid if there are semantic errors (e.g. unresolved identifiers).

Returns the type of this expression.