Exemplo n.º 1
0
 public static Statement CreateModifiedStatement(StatementModifier modifier, Statement node)
 {
     Block block;
     Statement stmt = MapStatementModifier(modifier, out block);
     block.Add(node);
     return stmt;
 }
Exemplo n.º 2
0
        public static Statement MapStatementModifier(StatementModifier modifier, out Block block)
        {
            switch (modifier.Type)
            {
                case StatementModifierType.If:
                {
                    IfStatement stmt = new IfStatement(modifier.LexicalInfo);
                    stmt.Condition = modifier.Condition;
                    stmt.TrueBlock = new Block();
                    block = stmt.TrueBlock;
                    return stmt;
                }

                case StatementModifierType.Unless:
                {
                    UnlessStatement stmt = new UnlessStatement(modifier.LexicalInfo);
                    stmt.Condition = modifier.Condition;
                    block = stmt.Block;
                    return stmt;
                }

                case StatementModifierType.While:
                {
                    WhileStatement stmt = new WhileStatement(modifier.LexicalInfo);
                    stmt.Condition = modifier.Condition;
                    block = stmt.Block;
                    return stmt;
                }
            }
            throw CompilerErrorFactory.NotImplemented(modifier, string.Format("modifier {0} supported", modifier.Type));
        }
Exemplo n.º 3
0
        override public object Clone()
        {
            StatementModifier clone = new StatementModifier();

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._isSynthetic       = _isSynthetic;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }
            clone._type = _type;
            if (null != _condition)
            {
                clone._condition = _condition.Clone() as Expression;
                clone._condition.InitializeParent(clone);
            }
            return(clone);
        }
Exemplo n.º 4
0
        override public object Clone()
        {
            StatementModifier clone = (StatementModifier)FormatterServices.GetUninitializedObject(typeof(StatementModifier));

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

            clone._type = _type;
            if (null != _condition)
            {
                clone._condition = _condition.Clone() as Expression;
                clone._condition.InitializeParent(clone);
            }
            return(clone);
        }
Exemplo n.º 5
0
 public Statement(StatementModifier modifier)
 {
     this.Modifier = modifier;
 }
Exemplo n.º 6
0
 public RaiseStatement(LexicalInfo li, Expression exception, StatementModifier modifier)
     : base(li)
 {
     this.Exception = exception;
     this.Modifier = modifier;
 }
Exemplo n.º 7
0
 public RaiseStatement(LexicalInfo li, Expression exception, StatementModifier modifier) : base(li, exception)
 {
     this.Modifier = modifier;
 }
Exemplo n.º 8
0
 public RaiseStatement(Expression exception, StatementModifier modifier) : base(exception)
 {
     this.Modifier = modifier;
 }
Exemplo n.º 9
0
 public override bool Replace(Node existing, Node newNode)
 {
     if (base.Replace(existing, newNode))
     {
         return true;
     }
     if (_modifier == existing)
     {
         this.Modifier = (StatementModifier)newNode;
         return true;
     }
     return false;
 }
Exemplo n.º 10
0
 public Statement(StatementModifier modifier)
 {
     this.Modifier = modifier;
 }
Exemplo n.º 11
0
 public Statement(StatementModifier modifier) : base(modifier)
 {
 }
Exemplo n.º 12
0
 public ReturnStatement(Expression expression, StatementModifier modifier)
 {
     this.Expression = expression;
     this.Modifier   = modifier;
 }
Exemplo n.º 13
0
 public GeneratorExpression(Expression expression, Expression iterator, StatementModifier filter)
 {
     this.Expression = expression;
     this.Iterator   = iterator;
     this.Filter     = filter;
 }
Exemplo n.º 14
0
 public ExpressionStatement(LexicalInfo lexicalInfo, Expression expression, StatementModifier modifier)
     : base(lexicalInfo)
 {
     this.Expression = expression;
     this.Modifier = modifier;
 }
Exemplo n.º 15
0
		public ReturnStatement(Expression expression, StatementModifier modifier)
		{
			this.Expression = expression;
			this.Modifier = modifier;
		}
Exemplo n.º 16
0
 public override void OnStatementModifier(StatementModifier sm)
 {
     Write(" ");
     WriteKeyword(sm.Type.ToString().ToLower());
     Write(" ");
     Visit(sm.Condition);
 }
Exemplo n.º 17
0
 public RaiseStatement(Expression exception, StatementModifier modifier)
 {
     this.Exception = exception;
     this.Modifier  = modifier;
 }
Exemplo n.º 18
0
 public RaiseStatement(Expression exception, StatementModifier modifier)
 {
     this.Exception = exception;
     this.Modifier = modifier;
 }
Exemplo n.º 19
0
 public ReturnStatement(Expression expression, StatementModifier modifier) : base(expression)
 {
     this.Modifier = modifier;
 }
Exemplo n.º 20
0
 public GeneratorExpression(Expression expression, Expression iterator, StatementModifier filter)
 {
     this.Expression = expression;
     this.Iterator = iterator;
     this.Filter = filter;
 }
Exemplo n.º 21
0
 public ReturnStatement(LexicalInfo li, Expression expression, StatementModifier modifier) : base(li)
 {
     this.Expression = expression;
     this.Modifier   = modifier;
 }
Exemplo n.º 22
0
		override public object Clone()
		{
		
			StatementModifier clone = new StatementModifier();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			clone._type = _type;
			if (null != _condition)
			{
				clone._condition = _condition.Clone() as Expression;
				clone._condition.InitializeParent(clone);
			}
			return clone;


		}
Exemplo n.º 23
0
 public ExpressionStatement(LexicalInfo lexicalInfo, Expression expression, StatementModifier modifier)
     : base(lexicalInfo)
 {
     this.Expression = expression;
     this.Modifier   = modifier;
 }
Exemplo n.º 24
0
	protected StatementModifier  stmt_modifier() //throws RecognitionException, TokenStreamException
{
		StatementModifier m;
		
		IToken  i = null;
		IToken  u = null;
		IToken  w = null;
		
				m = null;
				Expression e = null;
				IToken t = null;
				StatementModifierType type = StatementModifierType.None;
			
		
		try {      // for error handling
			{
				switch ( LA(1) )
				{
				case IF:
				{
					i = LT(1);
					match(IF);
					if (0==inputState.guessing)
					{
						t = i; type = StatementModifierType.If;
					}
					break;
				}
				case UNLESS:
				{
					u = LT(1);
					match(UNLESS);
					if (0==inputState.guessing)
					{
						t = u; type = StatementModifierType.Unless;
					}
					break;
				}
				case WHILE:
				{
					w = LT(1);
					match(WHILE);
					if (0==inputState.guessing)
					{
						t = w; type = StatementModifierType.While;
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			e=boolean_expression();
			if (0==inputState.guessing)
			{
				
						m = new StatementModifier(ToLexicalInfo(t));
						m.Type = type;
						m.Condition = e;
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "stmt_modifier");
				recover(ex,tokenSet_14_);
			}
			else
			{
				throw ex;
			}
		}
		return m;
	}
Exemplo n.º 25
0
 public GeneratorExpression(Expression expression, Expression iterator, StatementModifier filter) : base(expression, iterator, filter)
 {
 }