Functions and Braces¶
Functions are round or square braces preceded with a literal (e.g., F1(x), F1(x) {}, m1[i,j], m1[i,j]{}). Functions are parsed to expression items of type UniversalExpressionParser.ExpressionItems.IBracesExpressionItem with the value of property ILiteralExpressionItem NameLiteral { get; } equal to a literal that precedes the braces.
Braces are a pair of round or square braces ((e.g., (x), (x) {}, [i,j], [i,j]{})). Braces are parsed to expression items of type UniversalExpressionParser.ExpressionItems.IBracesExpressionItem with the value of property ILiteralExpressionItem NameLiteral { get; } equal to null.
Examples of functions¶
1// The statements below do not make much sense.
2// They just demonstrate different ways the square and round braces can be used
3// in expressions.
4var x = x1+f1(x2, x3+x4*5+x[1])+
5 matrix1[[y1+3, f1(x4)], x3, f2(x3, m2[x+5])];
6
7f1(x, y) => x+y;
8
9f2[x, y]
10{
11 // Normally matrixes do not have bodies like functions doo. This is just to demo that
12 // the parser allows this.
13}
Click here to see the visualized instance of UniversalExpressionParser.IParseExpressionResult
Examples of braces¶
1// The statements below do not make much sense.
2// They just demonstrate different ways the square and round braces can be used
3// in expressions.
4var x = ((x1, x2, x3), [x4, x5+1, x6], y);
5x += (x2, x4) + 2*[x3, x4];
Click here to see the visualized instance of UniversalExpressionParser.IParseExpressionResult