Beispiel #1
0
        protected internal virtual Parser <BlockSyntax> BlockShortform <T>() where T : StatementSyntax =>
        from comments in CommentParser.AnyComment.Token().Many()
        from op in Parse.String("|>").Token()
        from exp in QualifiedExpression.Token().Positioned()
        from end in Parse.Char(';').Token()
        select new BlockSyntax
        {
            LeadingComments = comments.ToList(),
            Statements      = new List <StatementSyntax>()
            {
                typeof(T) == typeof(ReturnStatementSyntax) ?
                new ReturnStatementSyntax(exp).SetPos <ReturnStatementSyntax>(exp.Transform) :
                new SingleStatementSyntax(exp)
            }
        }

        .SetStart(exp.Transform.pos)
        .SetEnd(exp.Transform.pos)
        .As <BlockSyntax>();
Beispiel #2
0
 protected internal virtual Parser <IOption <ExpressionSyntax> > KeywordExpressionStatement(string keyword) =>
 KeywordExpression(keyword)
 .Token()
 .Then(_ => QualifiedExpression.Token().XOptional())
 .Then(x => Parse.Char(';').Token().Return(x));