Files
spark/src/DataStreamSuite/ColumnMapExpressions/ColumnMapExpressionGrammar.y
T
John Colvin 248e37577f feat: Add DataStreamExpressions
All lex/yacc scanners/parsers are now generated with a proper dotnet
nuget pkg, YaccLexTools.

* Implements BooleanExpressionFilter with the new Parser.
2023-09-29 13:10:49 -04:00

41 lines
1.1 KiB
Plaintext

%namespace Bts.ColumnMapExpressions
%partial
%visibility internal
%tokentype ColumnMapExpressionToken
%parsertype ColumnMapExpressionParser
%union {
public string Identifier;
public KeyValuePair<string, string> MappedColumn;
public System.Collections.Immutable.ImmutableDictionary<string, string> MappedColumns;
public ColumnMapExpression Expression;
}
%token IDENTIFIER, MAP, NEGATE
%type <MappedColumns> MappedColumns
%type <Expression> Expression
%type <MappedColumn> MappedColumn
%%
Expression :
NEGATE MappedColumns { $$ = new($2, false); }
| NEGATE { $$ = new(System.Collections.Immutable.ImmutableDictionary<string, string>.Empty, false); }
| MappedColumns { $$ = new($1, true); }
;
MappedColumn :
IDENTIFIER {
$$ = new($1.Identifier, $1.Identifier);
}
| IDENTIFIER MAP IDENTIFIER {
$$ = new($1.Identifier, $3.Identifier);
}
;
MappedColumns :
MappedColumn { $$ = System.Collections.Immutable.ImmutableDictionary<string, string>.Empty.Add($1.Key, $1.Value); }
| MappedColumn MappedColumns { $$ = $2.Add($1.Key, $1.Value); }
;