Supports c#/c++ style line comments (i.e., that begin with '//') TODO: block comments
87 lines
2.2 KiB
Plaintext
87 lines
2.2 KiB
Plaintext
%namespace Bts.DataStreamExpressions
|
|
%partial
|
|
%visibility internal
|
|
%tokentype DataStreamExpressionToken
|
|
%parsertype DataStreamExpressionParser
|
|
|
|
%union {
|
|
public int Integer;
|
|
public double Real;
|
|
public bool Boolean;
|
|
public string CsString;
|
|
public string Identifier;
|
|
public DateTime DateTime;
|
|
public DBNull Null;
|
|
public DataStreamExpression DataStream;
|
|
public StatementExpression Statement;
|
|
public PrimitiveExpression Primitive;
|
|
public ImmutableList<Argument> Arguments;
|
|
public Argument Argument;
|
|
public string ViewName;
|
|
public QuotedView QuotedView;
|
|
}
|
|
|
|
%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 LINE_COMMENT
|
|
|
|
%nonassoc EQUALS
|
|
|
|
%type <DataStream> DataStream
|
|
%type <Statement> Statement
|
|
%type <Argument> Argument
|
|
%type <Arguments> Arguments
|
|
%type <QuotedView> QuotedView
|
|
|
|
%%
|
|
|
|
DataStream :
|
|
Statement { $$ = new(System.Collections.Immutable.ImmutableList<StatementExpression>.Empty.Add($1)); }
|
|
| Statement DataStream { $$ = new($2.Statements.Insert(0, $1)); }
|
|
;
|
|
|
|
Statement :
|
|
IDENTIFIER PARENTHESIS_OPEN Arguments PARENTHESIS_CLOSE {
|
|
$$ = new PrimitiveExpression($1.Identifier, $3);
|
|
}
|
|
| IDENTIFIER {
|
|
$$ = new ViewNameExpression($1.Identifier);
|
|
}
|
|
| IDENTIFIER EQUALS Statement {
|
|
$$ = new Assignment($1.Identifier, $3);
|
|
}
|
|
| LINE_COMMENT Statement {
|
|
$$ = $2;
|
|
}
|
|
| Statement LINE_COMMENT {
|
|
$$ = $1;
|
|
}
|
|
;
|
|
|
|
Arguments :
|
|
{
|
|
$$ = System.Collections.Immutable.ImmutableList<Argument>.Empty;
|
|
}
|
|
| Argument {
|
|
$$ = System.Collections.Immutable.ImmutableList<Argument>.Empty.Add($1);
|
|
}
|
|
| Arguments COMMA Argument {
|
|
$$ = $1.Add($3);
|
|
}
|
|
;
|
|
|
|
Argument :
|
|
CS_STRING_CONSTANT { $$ = new($1.CsString); }
|
|
| BOOLEAN_CONSTANT { $$ = new($1.Boolean); }
|
|
| INTEGER_CONSTANT { $$ = new($1.Integer); }
|
|
| REAL_CONSTANT { $$ = new($1.Real); }
|
|
| DATE_TIME_CONSTANT { $$ = new($1.DateTime); }
|
|
| NULL_CONSTANT { $$ = new($1.Null); }
|
|
| Statement { $$ = new($1); }
|
|
| QuotedView { $$ = new($1); }
|
|
;
|
|
|
|
QuotedView :
|
|
QUOTE_OPEN DataStream QUOTE_CLOSE { $$ = new($2.printView(0)); }
|
|
;
|