public override Expression Scan(ParseEngine engine) { var start = engine.Pointer; var kw = new ElseKeyword(engine.CurrentLine, engine.CurrentColumn, engine.Query); kw.Body = engine.Advance(Token.Length).ParseStatement(); if (engine.LastStatement == null) { engine.AddError(new YAMPIfRequiredError(engine), kw); } else if (engine.LastStatement.IsKeyword<IfKeyword>()) { engine.LastStatement.GetKeyword<IfKeyword>().Else = kw; } else if (engine.LastStatement.IsKeyword<ElseKeyword>()) { var otherwise = engine.LastStatement.GetKeyword<ElseKeyword>(); if (otherwise.IsElseIf) { otherwise.ElseIf.Else = kw; } else { engine.AddError(new YAMPSingleElseError(engine), kw); } } else { engine.AddError(new YAMPIfRequiredError(engine), kw); } kw.Length = engine.Pointer - start; return kw; }
public override Expression Scan(ParseEngine engine) { var start = engine.Pointer; var kw = new ElseKeyword(engine.CurrentLine, engine.CurrentColumn, engine.Query); kw.Body = engine.Advance(Token.Length).ParseStatement(); if (engine.LastStatement == null) { engine.AddError(new YAMPIfRequiredError(engine), kw); } else if (engine.LastStatement.IsKeyword <IfKeyword>()) { engine.LastStatement.GetKeyword <IfKeyword>().Else = kw; } else if (engine.LastStatement.IsKeyword <ElseKeyword>()) { var otherwise = engine.LastStatement.GetKeyword <ElseKeyword>(); if (otherwise.IsElseIf) { otherwise.ElseIf.Else = kw; } else { engine.AddError(new YAMPSingleElseError(engine), kw); } } else { engine.AddError(new YAMPIfRequiredError(engine), kw); } kw.Length = engine.Pointer - start; return(kw); }