override public object Clone()
        {
            ExtendedGeneratorExpression clone = (ExtendedGeneratorExpression)FormatterServices.GetUninitializedObject(typeof(ExtendedGeneratorExpression));

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }

            clone._expressionType = _expressionType;
            if (null != _items)
            {
                clone._items = _items.Clone() as GeneratorExpressionCollection;
                clone._items.InitializeParent(clone);
            }
            return(clone);
        }
        override public object Clone()
        {
            ExtendedGeneratorExpression clone = new ExtendedGeneratorExpression();

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._isSynthetic       = _isSynthetic;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }
            clone._expressionType = _expressionType;
            if (null != _items)
            {
                clone._items = _items.Clone() as GeneratorExpressionCollection;
                clone._items.InitializeParent(clone);
            }
            return(clone);
        }
示例#3
0
        public override void OnExtendedGeneratorExpression(ExtendedGeneratorExpression node)
        {
            BlockExpression block = new BlockExpression(node.LexicalInfo);

            Block body = block.Body;
            Expression e = node.Items[0].Expression;
            foreach (GeneratorExpression ge in node.Items)
            {
                ForStatement fs = new ForStatement(ge.LexicalInfo);
                fs.Iterator = ge.Iterator;
                fs.Declarations = ge.Declarations;

                body.Add(fs);

                if (null == ge.Filter)
                {
                    body = fs.Block;
                }
                else
                {
                    fs.Block.Add(
                        NormalizeStatementModifiers.MapStatementModifier(ge.Filter, out body));
                }

            }
            body.Add(new YieldStatement(e.LexicalInfo, e));

            MethodInvocationExpression mie = new MethodInvocationExpression(node.LexicalInfo);
            mie.Target = block;

            Node parentNode = node.ParentNode;
            bool isGenerator = AstUtil.IsListMultiGenerator(parentNode);
            parentNode.Replace(node, mie);
            mie.Accept(this);

            if (isGenerator)
            {
                parentNode.ParentNode.Replace(
                    parentNode,
                    CodeBuilder.CreateConstructorInvocation(
                        TypeSystemServices.Map(ProcessGenerators.List_IEnumerableConstructor),
                        mie));
            }
        }
示例#4
0
	protected Expression  expression() //throws RecognitionException, TokenStreamException
{
		Expression e;
		
		IToken  f = null;
		IToken  f2 = null;
		
				e = null;
				
				ExtendedGeneratorExpression mge = null;
				GeneratorExpression ge = null;
			
		
		try {      // for error handling
			e=boolean_expression();
			{
				if ((LA(1)==FOR) && (LA(2)==ID))
				{
					f = LT(1);
					match(FOR);
					if (0==inputState.guessing)
					{
						
									ge = new GeneratorExpression(ToLexicalInfo(f));
									ge.Expression = e;
									e = ge;
								
					}
					generator_expression_body(ge);
					{    // ( ... )*
						for (;;)
						{
							if ((LA(1)==FOR) && (LA(2)==ID))
							{
								f2 = LT(1);
								match(FOR);
								if (0==inputState.guessing)
								{
									
													if (null == mge)
													{
														mge = new ExtendedGeneratorExpression(ToLexicalInfo(f));
														mge.Items.Add(ge);
														e = mge;
													}
													
													ge = new GeneratorExpression(ToLexicalInfo(f2));
													mge.Items.Add(ge);
												
								}
								generator_expression_body(ge);
							}
							else
							{
								goto _loop435_breakloop;
							}
							
						}
_loop435_breakloop:						;
					}    // ( ... )*
				}
				else if ((tokenSet_14_.member(LA(1))) && (tokenSet_15_.member(LA(2)))) {
				}
				else
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "expression");
				recover(ex,tokenSet_14_);
			}
			else
			{
				throw ex;
			}
		}
		return e;
	}
示例#5
0
        //throws RecognitionException, TokenStreamException
        protected Expression expression()
        {
            Expression e;

            IToken  f = null;
            IToken  f2 = null;

                e = null;

                ExtendedGeneratorExpression mge = null;
                GeneratorExpression ge = null;

            try {      // for error handling
            e=boolean_expression();
            {
                switch ( LA(1) )
                {
                case FOR:
                {
                    f = LT(1);
                    match(FOR);
                    if (0==inputState.guessing)
                    {

                                    ge = new GeneratorExpression(SourceLocationFactory.ToLexicalInfo(f));
                                    ge.Expression = e;
                                    e = ge;

                    }
                    generator_expression_body(ge);
                    {    // ( ... )*
                        for (;;)
                        {
                            if ((LA(1)==FOR))
                            {
                                f2 = LT(1);
                                match(FOR);
                                if (0==inputState.guessing)
                                {

                                                    if (null == mge)
                                                    {
                                                        mge = new ExtendedGeneratorExpression(SourceLocationFactory.ToLexicalInfo(f));
                                                        mge.Items.Add(ge);
                                                        e = mge;
                                                    }

                                                    ge = new GeneratorExpression(SourceLocationFactory.ToLexicalInfo(f2));
                                                    mge.Items.Add(ge);

                                }
                                generator_expression_body(ge);
                            }
                            else
                            {
                                goto _loop380_breakloop;
                            }

                        }
            _loop380_breakloop:						;
                    }    // ( ... )*
                    break;
                }
                case EOF:
                case ESEPARATOR:
                case DEF:
                case DO:
                case IF:
                case UNLESS:
                case WHILE:
                case ID:
                case EOS:
                case NEWLINE:
                case RPAREN:
                case RBRACK:
                case COMMA:
                case COLON:
                case RBRACE:
                case QQ_END:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_12_);
            }
            else
            {
                throw ex;
            }
            }
            return e;
        }
示例#6
0
 public override void OnExtendedGeneratorExpression(ExtendedGeneratorExpression node)
 {
     Write("(");
     Visit(node.Items[0].Expression);
     for (int i=0; i<node.Items.Count; ++i)
     {
         WriteGeneratorExpressionBody(node.Items[i]);
     }
     Write(")");
 }
		override public object Clone()
		{
		
			ExtendedGeneratorExpression clone = new ExtendedGeneratorExpression();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			clone._expressionType = _expressionType;
			if (null != _items)
			{
				clone._items = _items.Clone() as GeneratorExpressionCollection;
				clone._items.InitializeParent(clone);
			}
			return clone;


		}