public static HeaderStatement Parse(Scope scope, KeywordToken headerToken) { var ret = new HeaderStatement(scope); ret.AddToken(headerToken); if (!scope.Code.PeekExact('{')) { return(ret); } ret.AddToken(BracesToken.Parse(scope, null)); return(ret); }
public static ForStatement Parse(Scope scope, KeywordToken forToken) { var ret = new ForStatement(scope); var code = scope.Code; ret.AddToken(forToken); if (!code.ReadExact('(')) { return(ret); } var brackets = new BracketsToken(scope); brackets.AddOpen(code.Span); ret.AddToken(brackets); // Initializer var exp = ExpressionToken.TryParse(scope, _conditionEndTokens); if (exp != null) { brackets.AddToken(exp); } if (!code.ReadExact(';')) { return(ret); } // Condition exp = ExpressionToken.TryParse(scope, _conditionEndTokens); if (exp != null) { brackets.AddToken(exp); } if (!code.ReadExact(';')) { return(ret); } // Increment exp = ExpressionToken.TryParse(scope, _conditionEndTokens); if (exp != null) { brackets.AddToken(exp); } if (!code.ReadExact(')')) { return(ret); } brackets.AddClose(code.Span); // Body var bodyScope = scope.Clone(); bodyScope.BreakOwner = ret; bodyScope.ContinueOwner = ret; if (!code.PeekExact('{')) { return(ret); } var body = BracesToken.Parse(bodyScope, null); ret.AddToken(body); return(ret); }