| | | 1 | | namespace Elsa.Dsl.ElsaScript.Ast; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Base class for expression nodes. |
| | | 5 | | /// </summary> |
| | | 6 | | public abstract class ExpressionNode : AstNode |
| | | 7 | | { |
| | | 8 | | } |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Represents a literal expression. |
| | | 12 | | /// </summary> |
| | | 13 | | public class LiteralNode : ExpressionNode |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// The literal value. |
| | | 17 | | /// </summary> |
| | | 18 | | public object? Value { get; set; } |
| | | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Represents an Elsa expression with a specific language. |
| | | 23 | | /// </summary> |
| | | 24 | | public class ElsaExpressionNode : ExpressionNode |
| | | 25 | | { |
| | | 26 | | /// <summary> |
| | | 27 | | /// The expression language (e.g., "js", "cs", "py", "liquid"). |
| | | 28 | | /// If null, uses the default language from use statements. |
| | | 29 | | /// </summary> |
| | 19 | 30 | | public string? Language { get; set; } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// The expression code. |
| | | 34 | | /// </summary> |
| | 21 | 35 | | public string Expression { get; set; } = string.Empty; |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Represents a template string expression. |
| | | 40 | | /// </summary> |
| | | 41 | | public class TemplateStringNode : ExpressionNode |
| | | 42 | | { |
| | | 43 | | /// <summary> |
| | | 44 | | /// The parts of the template string (alternating between literals and expressions). |
| | | 45 | | /// </summary> |
| | | 46 | | public List<TemplatePartNode> Parts { get; set; } = []; |
| | | 47 | | } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Represents a part of a template string. |
| | | 51 | | /// </summary> |
| | | 52 | | public class TemplatePartNode : AstNode |
| | | 53 | | { |
| | | 54 | | /// <summary> |
| | | 55 | | /// Whether this is a literal or expression part. |
| | | 56 | | /// </summary> |
| | | 57 | | public bool IsExpression { get; set; } |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// The content (literal text or expression code). |
| | | 61 | | /// </summary> |
| | | 62 | | public string Content { get; set; } = string.Empty; |
| | | 63 | | } |
| | | 64 | | |
| | | 65 | | /// <summary> |
| | | 66 | | /// Represents an identifier (variable reference). |
| | | 67 | | /// </summary> |
| | | 68 | | public class IdentifierNode : ExpressionNode |
| | | 69 | | { |
| | | 70 | | /// <summary> |
| | | 71 | | /// The identifier name. |
| | | 72 | | /// </summary> |
| | | 73 | | public string Name { get; set; } = string.Empty; |
| | | 74 | | } |
| | | 75 | | |
| | | 76 | | /// <summary> |
| | | 77 | | /// Represents an array literal. |
| | | 78 | | /// </summary> |
| | | 79 | | public class ArrayLiteralNode : ExpressionNode |
| | | 80 | | { |
| | | 81 | | /// <summary> |
| | | 82 | | /// The elements of the array. |
| | | 83 | | /// </summary> |
| | | 84 | | public List<ExpressionNode> Elements { get; set; } = []; |
| | | 85 | | } |
| | | 86 | | |
| | | 87 | | /// <summary> |
| | | 88 | | /// Represents a binary expression (e.g., a + b). |
| | | 89 | | /// </summary> |
| | | 90 | | public class BinaryExpressionNode : ExpressionNode |
| | | 91 | | { |
| | | 92 | | /// <summary> |
| | | 93 | | /// The left operand. |
| | | 94 | | /// </summary> |
| | | 95 | | public ExpressionNode Left { get; set; } = null!; |
| | | 96 | | |
| | | 97 | | /// <summary> |
| | | 98 | | /// The operator. |
| | | 99 | | /// </summary> |
| | | 100 | | public string Operator { get; set; } = string.Empty; |
| | | 101 | | |
| | | 102 | | /// <summary> |
| | | 103 | | /// The right operand. |
| | | 104 | | /// </summary> |
| | | 105 | | public ExpressionNode Right { get; set; } = null!; |
| | | 106 | | } |
| | | 107 | | |
| | | 108 | | /// <summary> |
| | | 109 | | /// Represents a unary expression (e.g., ++i, i++). |
| | | 110 | | /// </summary> |
| | | 111 | | public class UnaryExpressionNode : ExpressionNode |
| | | 112 | | { |
| | | 113 | | /// <summary> |
| | | 114 | | /// The operator. |
| | | 115 | | /// </summary> |
| | | 116 | | public string Operator { get; set; } = string.Empty; |
| | | 117 | | |
| | | 118 | | /// <summary> |
| | | 119 | | /// The operand. |
| | | 120 | | /// </summary> |
| | | 121 | | public ExpressionNode Operand { get; set; } = null!; |
| | | 122 | | |
| | | 123 | | /// <summary> |
| | | 124 | | /// Whether the operator is prefix (true) or postfix (false). |
| | | 125 | | /// </summary> |
| | | 126 | | public bool IsPrefix { get; set; } |
| | | 127 | | } |