GH_ExpressionParser

References
public class GH_ExpressionParser
Provides a run-time evaluator for Grasshopper expressions.

Constructors

GH_ExpressionParser

#
public GH_ExpressionParser()

GH_ExpressionParser

#
public GH_ExpressionParser(bool bThrowExceptions)
bThrowExceptions (bool)

Properties

ThrowExceptions

#
public bool ThrowExceptions { get; set; }

Variables

#
public SortedDictionary<string, GH_Variant> Variables { get; }

Methods

AddVariable

#
public void AddVariable(string name, bool val)
name (string)
val (bool)

AddVariable

#
public void AddVariable(string name, Complex val)
name (string)
val (Complex)

AddVariable

#
public void AddVariable(string name, double val)
name (string)
val (double)

AddVariable

#
public void AddVariable(string name, int val)
name (string)
val (int)

AddVariable

#
public void AddVariable(string name, Plane val)
name (string)
val (Plane)

AddVariable

#
public void AddVariable(string name, Point3d val)
name (string)
val (Point3d)

AddVariable

#
public void AddVariable(string name, string val)
name (string)
val (string)

AddVariable

#
public void AddVariable(string name, Vector3d val)
name (string)
val (Vector3d)

AddVariableEx

#
public void AddVariableEx(string name, GH_Variant val)
name (string)
val (GH_Variant)

AddVariableEx

#
public void AddVariableEx(string name, IGH_Goo val)
name (string)
val (IGH_Goo)

BalancedCharTest

#
public static bool BalancedCharTest(string str, char char_open, char char_close, ref int error_at)
Test a string for balanced open and close chars. You can use this function to see if brackets or parenthesis have been properly used.
str (string)String to parse.
char_open (char)Char that indicates an opening statement.
char_close (char)Char that indicates a closing statement.
error_at (ref int)The index at which the first error appears or -1 if no error was found.
True if the chars are balanced, false if they are not.

CachedSymbols

#
public Queue<GH_ParserSymbol> CachedSymbols()
Retrieve a copy of the Queue of cached symbols. You can use the cached symbols as an uber-optimization to speed up successive calls to Evaluate() with an identical expression string

CacheSymbols

#
public bool CacheSymbols(string Expression)
Create a Symbols array from the expression. Use this method if you intend to evaluate the same expression multiple times. At this point, the expression has to be in correct syntax format. Use the GH_ExpressionSyntaxWriter.RewriteAll() method to make sure.
Expression (string)

ClearSymbols

#
public void ClearSymbols()
Destroy the Symbols cache.

ClearVariables

#
public void ClearVariables()
Destroy the variable cache.

DisplayFunctionList

#
public void DisplayFunctionList(IWin32Window wnd = null)
wnd (IWin32Window = null)

Evaluate

#
public GH_Variant Evaluate()
Evaluate the expression currently loaded in the Symbols cache using the currently loaded variables.

Evaluate

#
public GH_Variant Evaluate(Queue<GH_ParserSymbol> qHint)
Evaluate the expression queue without overriding any local caches. You can obtain an expression queue by calling CachedSymbols()
qHint (Queue<GH_ParserSymbol>)

Evaluate

#
public GH_Variant Evaluate(string expression)
Store a new expression in the Symbols cache and evaluate it using the current variables
expression (string)

IsValidVariableName

#
public static bool IsValidVariableName(string name)
Tests whether a string is a valid variable name for expressions. Valid names must contain at least one character, must start with an alphabetic character, and only contain alphanumeric chars and underscores.
name (string)Name to test.
True if the name is valid (might still conflict with a function name though), false if not.

Op_BinaryAddition

#
protected GH_Variant Op_BinaryAddition(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryAmpersand

#
protected GH_Variant Op_BinaryAmpersand(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryAND

#
protected GH_Variant Op_BinaryAND(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryAngle

#
protected GH_Variant Op_BinaryAngle(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryCircumflex

#
protected GH_Variant Op_BinaryCircumflex(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryCrossProduct

#
protected GH_Variant Op_BinaryCrossProduct(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryDistance

#
protected GH_Variant Op_BinaryDistance(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryDivision

#
protected GH_Variant Op_BinaryDivision(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryEquality

#
protected GH_Variant Op_BinaryEquality(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryIntegerDivision

#
protected GH_Variant Op_BinaryIntegerDivision(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryLargerThan

#
protected GH_Variant Op_BinaryLargerThan(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryLargerThanOrEqual

#
protected GH_Variant Op_BinaryLargerThanOrEqual(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryModulus

#
protected GH_Variant Op_BinaryModulus(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryMultiplication

#
protected GH_Variant Op_BinaryMultiplication(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryNearEquality

#
protected GH_Variant Op_BinaryNearEquality(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryOR

#
protected GH_Variant Op_BinaryOR(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryPull

#
protected GH_Variant Op_BinaryPull(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryPush

#
protected GH_Variant Op_BinaryPush(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinarySmallerThan

#
protected GH_Variant Op_BinarySmallerThan(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinarySmallerThanOrEqual

#
protected GH_Variant Op_BinarySmallerThanOrEqual(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinarySubtraction

#
protected GH_Variant Op_BinarySubtraction(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_BinaryXOR

#
protected GH_Variant Op_BinaryXOR(GH_Variant A, GH_Variant B)
A (GH_Variant)
B (GH_Variant)

Op_UnaryBang

#
protected GH_Variant Op_UnaryBang(GH_Variant V)
V (GH_Variant)

Op_UnaryCube

#
protected GH_Variant Op_UnaryCube(GH_Variant V)
V (GH_Variant)

Op_UnaryDeg2Rad

#
protected GH_Variant Op_UnaryDeg2Rad(GH_Variant V)
V (GH_Variant)

Op_UnaryImaginary

#
protected GH_Variant Op_UnaryImaginary(GH_Variant V)
V (GH_Variant)

Op_UnaryMinus

#
protected GH_Variant Op_UnaryMinus(GH_Variant V)
V (GH_Variant)

Op_UnaryNOT

#
protected GH_Variant Op_UnaryNOT(GH_Variant V)
V (GH_Variant)

Op_UnaryOComponent

#
protected GH_Variant Op_UnaryOComponent(GH_Variant V)
V (GH_Variant)

Op_UnaryPlus

#
protected GH_Variant Op_UnaryPlus(GH_Variant V)
V (GH_Variant)

Op_UnarySquare

#
protected GH_Variant Op_UnarySquare(GH_Variant V)
V (GH_Variant)

Op_UnaryXComponent

#
protected GH_Variant Op_UnaryXComponent(GH_Variant V)
V (GH_Variant)

Op_UnaryYComponent

#
protected GH_Variant Op_UnaryYComponent(GH_Variant V)
V (GH_Variant)

Op_UnaryZComponent

#
protected GH_Variant Op_UnaryZComponent(GH_Variant V)
V (GH_Variant)