Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
LangMatches.cs
1using System.Threading.Tasks;
2using Waher.Script;
6
8{
13 {
23 : base(Value, Type, Start, Length, Expression)
24 {
25 }
26
30 public override string FunctionName => nameof(LangMatches);
31
35 public override string[] DefaultArgumentNames => new string[] { "Language", "Pattern" };
36
40 public override bool UpgradeScalarsToSameSet => true;
41
50 {
51 if (string.IsNullOrEmpty(Argument1))
52 return BooleanValue.False;
53
54 if (Argument2 == "*")
55 return BooleanValue.True;
56
57 if (Argument2.IndexOf('-') >= 0)
58 return string.Compare(Argument1, Argument2, true) == 0 ? BooleanValue.True : BooleanValue.False;
59
60 int i = Argument1.IndexOf('-');
61 if (i >= 0)
62 Argument1 = Argument1.Substring(0, i);
63
64 return string.Compare(Argument1, Argument2, true) == 0 ? BooleanValue.True : BooleanValue.False;
65 }
66
74 public override Task<IElement> EvaluateScalarAsync(string Argument1, string Argument2, Variables Variables)
75 {
76 return Task.FromResult(this.EvaluateScalar(Argument1, Argument2, Variables));
77 }
78 }
79}
LangMatches(Language,Pattern)
Definition: LangMatches.cs:13
override Task< IElement > EvaluateScalarAsync(string Argument1, string Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
Definition: LangMatches.cs:74
override string FunctionName
Name of the function
Definition: LangMatches.cs:30
override string[] DefaultArgumentNames
Default Argument names
Definition: LangMatches.cs:35
LangMatches(ScriptNode Value, ScriptNode Type, int Start, int Length, Expression Expression)
LangMatches(Language,Pattern)
Definition: LangMatches.cs:22
override IElement EvaluateScalar(string Argument1, string Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
Definition: LangMatches.cs:49
override bool UpgradeScalarsToSameSet
If scalars should be upgraded to the same set before evaluation.
Definition: LangMatches.cs:40
Class managing a script expression.
Definition: Expression.cs:41
Base class for funcions of two scalar variables.
ScriptNode Argument2
Function argument 2.
ScriptNode Argument1
Function argument 1.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Boolean-valued number.
Definition: BooleanValue.cs:12
static readonly BooleanValue False
Constant false value.
static readonly BooleanValue True
Constant true value.
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:21