Exemplo n.º 1
0
        public static string ApplyToString( ApplyStatement applyStatement, string spaces, bool isExtended )
        {
            var builder = new StringBuilder();

            builder.Append( "<%apply" );
            builder.Append( spaces );
            builder.Append( applyStatement.ApplyMethod );

            if (isExtended) builder.Append( "([" );
            else builder.Append( "(" );
            builder.Append( spaces );
            builder.Append( applyStatement.Parameters );
            builder.Append( spaces );
            if (isExtended) builder.Append( "])" );
            else builder.Append( ")" );

            builder.Append( spaces );
            builder.Append( "from" );
            builder.Append( spaces );
            builder.Append( applyStatement.From );

            builder.Append( "%>" );

            return builder.ToString();
        }
        public CodeWriter JoinStatement( ApplyStatement statement, string tempWriter, string list )
        {
            var writer = new CodeWriter();

            writer.Indent = 0;
            writer.Append( "foreach (var item in " );
            writer.AppendText( statement.From );
            writer.Indent = 0;
            writer.AppendLine( ")" );
            writer.AppendLine( "{" );
            writer.Indent = 1;
            writer.AppendText( tempWriter );
            writer.Indent = 0;
            writer.Append( " = this.Invoke( \"" );
            writer.AppendText( statement.ApplyMethod );
            writer.Indent = 0;
            writer.Append( "\", " );
            writer.AppendText( statement.Parameters );
            writer.Indent = 0;
            writer.AppendLine( " );" );
            writer.Indent = 1;
            writer.AppendText( list );
            writer.Indent = 0;
            writer.Append( ".Add( " );
            writer.AppendText( tempWriter );
            writer.Indent = 0;
            writer.AppendLine( " );" );
            writer.Append( "}" );

            return writer;
        }
Exemplo n.º 3
0
        private static void MainTestMethod( ApplyStatement apply, string spaces, bool isExtended )
        {
            var applyStatementText = ApplyToString( apply, spaces, isExtended );
            var actualApply = ParserHelper.ParseApply( applyStatementText );

            AssertHelper.AssertApply( apply, actualApply );
        }
Exemplo n.º 4
0
 private static void MainTestMethod2( ApplyStatement apply, bool isExtended )
 {
     MainTestMethod( apply, " ", isExtended );
     MainTestMethod( apply, "\r\n\t", isExtended );
 }
Exemplo n.º 5
0
 void Apply(out ApplyStatement applyStatement)
 {
     string methodName; string parameters = null; string from;
     while (!(la.kind == 0 || la.kind == 5)) {SynErr(52); Get();}
     Expect(5);
     Token start = t;
     Expect(1);
     methodName = t.val;
     int startPos = -1; int endPos = -1;
     if (la.kind == 24) {
     Get();
     startPos = t.pos + t.val.Length;
     while (StartOf(11)) {
         Get();
     }
     endPos = la.pos;
     Expect(25);
     } else if (la.kind == 22) {
     Get();
     startPos = t.pos + t.val.Length;
     while (StartOf(12)) {
         Get();
     }
     endPos = la.pos;
     Expect(23);
     } else SynErr(53);
     if (startPos > 0 && endPos > 0)
        parameters = scanner.buffer.GetString( startPos, endPos ).Trim();
     while (!(la.kind == 0 || la.kind == 16)) {SynErr(54); Get();}
     Expect(16);
     int startFrom = la.pos;
     while (StartOf(6)) {
     Get();
     }
     from = scanner.buffer.GetString( startFrom, la.pos ).Trim();
     while (!(la.kind == 0 || la.kind == 10)) {SynErr(55); Get();}
     Expect(10);
     applyStatement = new ApplyStatement( new StatementPosition( start, t ), methodName, parameters, from );
 }