protected void ParseIf(Parser parser, CodeObject parent) { // Flush any unused objects first, so that they don't interfere with skipping // compiler directives below, or the parsing of any 'else' part. if (parser.HasUnused && _parent is BlockStatement) { ((BlockStatement)_parent).Body.FlushUnused(parser); } ParseKeywordArgumentBody(parser, ref _conditional, false, false); // Parse keyword, argument, and body // Skip over any compiler directives that might occur before an 'else', adding them to the unused list ParseAnnotations(parser, parent, false, true); // Parse optional 'else' or 'else if' child part if (parser.TokenText == Else.ParseToken) { _elsePart = ElseIf.Parse(parser, this); if (_elsePart == null) { _elsePart = Else.Parse(parser, this); } } else { // If there wasn't any 'else', and we skipped any compiler directives, we have to move // them now so they can be manually flushed by the parent Block *after* this statement. if (parser.HasUnused) { parser.MoveUnusedToPostUnused(); } } }
/// <summary> /// Parse an orphaned <see cref="ElseIf"/>. /// </summary> public static ElseIf ParseOrphan(Parser parser, CodeObject parent, ParseFlags flags) { Token token = parser.Token; ElseIf elseIf = Parse(parser, parent); if (elseIf != null) { parser.AttachMessage(elseIf, "Orphaned 'else if' - missing parent 'if'", token); } return(elseIf); }
/// <summary> /// Create an <see cref="If"/>. /// </summary> public If(Expression conditional, ElseIf elseIf) : base(conditional, elseIf) { }
/// <summary> /// Create an <see cref="If"/>. /// </summary> public If(Expression conditional, CodeObject body, ElseIf elseIf) : base(conditional, body, elseIf) { }
protected IfBase(Expression conditional, ElseIf elseIf) : this(conditional, null, elseIf) { }
protected IfBase(Expression conditional, CodeObject body, ElseIf elseIf) : this(conditional, body) { ElsePart = elseIf; }