public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (AtRule.IsRule(text, stream, "function")) { Rule = AtRule.CreateParsed(itemFactory, text, stream); if (Rule != null) { Children.Add(Rule); } if (stream.Current.Type == TokenType.Function) { Name = Children.AddCurrentAndAdvance(stream, SassClassifierType.UserFunctionDefinition); FunctionName = text.GetText(Name.Start, Name.Length); } if (stream.Current.Type == TokenType.OpenFunctionBrace) { Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace); } while (!IsArgumentTerminator(stream.Current.Type)) { var argument = itemFactory.CreateSpecific <FunctionArgumentDefinition>(this, text, stream); if (argument == null || !argument.Parse(itemFactory, text, stream)) { break; } Arguments.Add(argument); Children.Add(argument); } if (stream.Current.Type == TokenType.CloseFunctionBrace) { Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace); } var body = new UserFunctionBody(); if (body.Parse(itemFactory, text, stream)) { Body = body; Children.Add(body); } } return(Children.Count > 0); }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (AtRule.IsRule(text, stream, "function")) { Rule = AtRule.CreateParsed(itemFactory, text, stream); if (Rule != null) Children.Add(Rule); if (stream.Current.Type == TokenType.Function) { Name = Children.AddCurrentAndAdvance(stream, SassClassifierType.UserFunctionDefinition); FunctionName = text.GetText(Name.Start, Name.Length); } if (stream.Current.Type == TokenType.OpenFunctionBrace) Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace); while (!IsArgumentTerminator(stream.Current.Type)) { var argument = itemFactory.CreateSpecific<FunctionArgumentDefinition>(this, text, stream); if (argument == null || !argument.Parse(itemFactory, text, stream)) break; Arguments.Add(argument); Children.Add(argument); } if (stream.Current.Type == TokenType.CloseFunctionBrace) Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace); var body = new UserFunctionBody(); if (body.Parse(itemFactory, text, stream)) { Body = body; Children.Add(body); } } return Children.Count > 0; }