All lex/yacc scanners/parsers are now generated with a proper dotnet nuget pkg, YaccLexTools. * Implements BooleanExpressionFilter with the new Parser.
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
namespace Bts.DataStreamExpressions;
|
|
|
|
using BCG;
|
|
|
|
using System.Text;
|
|
|
|
public class DataStreamExpression {
|
|
public DataStreamExpression(ImmutableList<StatementExpression> statements) =>
|
|
Statements = statements;
|
|
|
|
public ImmutableList<StatementExpression> Statements { get; }
|
|
|
|
public string print(int startPos, IList<string> activeBindings) {
|
|
var sb = new StringBuilder();
|
|
foreach (var st in Statements) {
|
|
sb.Append(new string(' ', startPos));
|
|
sb.Append(st.print(startPos, activeBindings));
|
|
sb.AppendLine(";");
|
|
}
|
|
sb.AppendLine();
|
|
return sb.ToString();
|
|
}
|
|
|
|
public string printView(int startPos) {
|
|
var sb = new StringBuilder();
|
|
foreach (var st in Statements) {
|
|
sb.Append(new string(' ', startPos));
|
|
sb.AppendLine(st.printView(startPos));
|
|
}
|
|
sb.AppendLine();
|
|
return sb.ToString();
|
|
}
|
|
|
|
public ViewStream getView(IDictionary<string, StatementExpression> env) {
|
|
for (int i = 0; i < Statements.Count - 1; i++) {
|
|
Statements[i].getView(env);
|
|
}
|
|
return Statements[^1].getView(env);
|
|
}
|
|
}
|