Extend dsl to support explicit param names

This commit is contained in:
John Colvin committed 2024-11-29 15:05:53 +00:00
1 parent 1674e37506
commit 53ac678b58
3 files changed
+47 -9

No files matched your search

@@ -2,15 +2,40 @@ namespace Bts.DataStreamExpressions;
public class Argument {
public Argument() { }
public Argument(string str) => String = str;
public Argument(bool? boolean) => Boolean = boolean;
public Argument(int? integer) => Integer = integer;
public Argument(double? real) => Real = real;
public Argument(DateTime? dateTime) => DateTime = dateTime;
public Argument(DBNull? @null) => Null = @null;
public Argument(StatementExpression? statementExp) => StatementExp = statementExp;
public Argument(QuotedView? quotedView) => QuotedView = quotedView;
public Argument(string str, string? name = null) {
String = str;
Name = name;
}
public Argument(bool? boolean, string? name = null) {
Boolean = boolean;
Name = name;
}
public Argument(int? integer, string? name = null) {
Integer = integer;
Name = name;
}
public Argument(double? real, string? name = null) {
Real = real;
Name = name;
}
public Argument(DateTime? dateTime, string? name = null) {
DateTime = dateTime;
Name = name;
}
public Argument(DBNull? @null, string? name = null) {
Null = @null;
Name = name;
}
public Argument(StatementExpression? statementExp, string? name = null) {
StatementExp = statementExp;
Name = name;
}
public Argument(QuotedView? quotedView, string? name = null) {
QuotedView = quotedView;
Name = name;
}
public string? Name { get; }
public string? String { get; }
public bool? Boolean { get; }
public int? Integer { get; }
@@ -22,7 +22,7 @@
}
%token BOOLEAN_CONSTANT, INTEGER_CONSTANT, REAL_CONSTANT, DATE_TIME_CONSTANT, CS_STRING_CONSTANT, NULL_CONSTANT
%token PARENTHESIS_OPEN, PARENTHESIS_CLOSE, COMMA, IDENTIFIER, EQUALS, QUOTE_OPEN, QUOTE_CLOSE
%token PARENTHESIS_OPEN, PARENTHESIS_CLOSE, COMMA, COLON, IDENTIFIER, EQUALS, QUOTE_OPEN, QUOTE_CLOSE
%token LINE_COMMENT
%nonassoc EQUALS
@@ -72,13 +72,21 @@ Arguments :
Argument :
CS_STRING_CONSTANT { $$ = new($1.CsString); }
| IDENTIFIER COLON CS_STRING_CONSTANT { $$ = new($3.CsString, $1.Identifier); }
| BOOLEAN_CONSTANT { $$ = new($1.Boolean); }
| IDENTIFIER COLON BOOLEAN_CONSTANT { $$ = new($3.Boolean, $1.Identifier); }
| INTEGER_CONSTANT { $$ = new($1.Integer); }
| IDENTIFIER COLON INTEGER_CONSTANT { $$ = new($3.Integer, $1.Identifier); }
| REAL_CONSTANT { $$ = new($1.Real); }
| IDENTIFIER COLON REAL_CONSTANT { $$ = new($3.Real, $1.Identifier); }
| DATE_TIME_CONSTANT { $$ = new($1.DateTime); }
| IDENTIFIER COLON DATE_TIME_CONSTANT { $$ = new($3.DateTime, $1.Identifier); }
| NULL_CONSTANT { $$ = new($1.Null); }
| IDENTIFIER COLON NULL_CONSTANT { $$ = new($3.Null, $1.Identifier); }
| Statement { $$ = new($1); }
| IDENTIFIER COLON Statement { $$ = new($3, $1.Identifier); }
| QuotedView { $$ = new($1); }
| IDENTIFIER COLON QuotedView { $$ = new($3, $1.Identifier); }
;
QuotedView :
@@ -31,6 +31,7 @@ Identifier {Letter}({Letter}*[0-9]*_*)*
OpenParenthesis \(
CloseParenthesis \)
Comma ,
Colon :
QuoteOpen \[
QuoteClose \]
@@ -90,6 +91,10 @@ LineComment \/\/[^\n\r]*(\n|\r|\r\n)
return (int)DataStreamExpressionToken.COMMA;
}
{Colon} {
return (int)DataStreamExpressionToken.COLON;
}
{QuoteOpen} {
return (int)DataStreamExpressionToken.QUOTE_CLOSE;
}