public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (AtRule.IsRule(text, stream, "for")) { ParseRule(itemFactory, text, stream); var variable = new VariableName(SassClassifierType.VariableDefinition); if (variable.Parse(itemFactory, text, stream)) { Variable = variable; Children.Add(Variable); } if (IsKeyword(text, stream, "from")) { FromKeyword = Children.AddCurrentAndAdvance(stream, SassClassifierType.Keyword); while (!(IsKeyword(text, stream, "to") || IsKeyword(text, stream, "through"))) { ParseItem fromValue; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out fromValue)) { FromExpressionValues.Add(fromValue); Children.Add(fromValue); } } } bool isToKeyword = IsKeyword(text, stream, "to"); bool isThroughKeyword = !isToKeyword && IsKeyword(text, stream, "through"); if (isToKeyword || isThroughKeyword) { if (isToKeyword) { ToKeyword = Children.AddCurrentAndAdvance(stream, SassClassifierType.Keyword); } if (isThroughKeyword) { ThroughKeyword = Children.AddCurrentAndAdvance(stream, SassClassifierType.Keyword); } while (!IsRangeTerminator(stream.Current.Type)) { ParseItem rangeValue; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out rangeValue)) { RangeExpressionValues.Add(rangeValue); Children.Add(rangeValue); } } } ParseBody(itemFactory, text, stream); } return(Children.Count > 0); }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if ((IsConditionalDirective(text, stream) || IsConditionalContinuationDirective(text, stream))) { ParseRule(itemFactory, text, stream); while (!IsConditionTerminator(stream.Current.Type)) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) { Children.Add(item); ConditionStatements.Add(item); } else { Children.AddCurrentAndAdvance(stream); } } ParseBody(itemFactory, text, stream); while (IsConditionalContinuationDirective(text, stream)) { var subsequentConditional = itemFactory.CreateSpecific<ConditionalControlDirective>(this, text, stream); if (!subsequentConditional.Parse(itemFactory, text, stream)) break; ElseStatements.Add(subsequentConditional); Children.Add(subsequentConditional); } } return Children.Count > 0; }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (stream.Current.Type == TokenType.Identifier && IsModifier(text.GetText(stream.Current.Start, stream.Current.Length))) Modifier = Children.AddCurrentAndAdvance(stream); ParseItem mediaType; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out mediaType)) { MediaType = mediaType; Children.Add(mediaType); } while (!IsTerminator(text, stream)) { var expression = itemFactory.CreateSpecific<MediaQueryExpression>(this, text, stream); if (expression.Parse(itemFactory, text, stream)) { _Expressions.Add(expression); Children.Add(expression); } else { Children.AddCurrentAndAdvance(stream); } } if (stream.Current.Type == TokenType.Comma) Comma = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation); return Children.Count > 0; }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (stream.Current.Type == TokenType.Identifier && text.CompareOrdinal(stream.Current.Start, "and")) { Combinator = Children.AddCurrentAndAdvance(stream, SassClassifierType.Keyword); } if (stream.Current.Type == TokenType.OpenFunctionBrace) { OpenBrace = Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace); } ParseItem feature; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out feature)) { Feature = feature; Children.Add(feature); } if (stream.Current.Type == TokenType.Colon) { Colon = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation); } // dump all values while (!IsExpressionTerminator(stream.Current.Type)) { ParseItem value; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out value)) { FeatureValues.Add(value); Children.Add(value); } else { Children.AddCurrentAndAdvance(stream); } } if (stream.Current.Type == TokenType.CloseFunctionBrace) { CloseBrace = Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace); } return(Children.Count > 0); }
protected virtual void ParseBody(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { while (!IsTerminator(stream.Current.Type)) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) Children.Add(item); } }
protected virtual void ParseBody(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { while (!IsTerminator(stream.Current.Type)) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) { Children.Add(item); } } }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (stream.Current.Type == TokenType.Identifier && text.CompareOrdinal(stream.Current.Start, "and")) Combinator = Children.AddCurrentAndAdvance(stream, SassClassifierType.Keyword); if (stream.Current.Type == TokenType.OpenFunctionBrace) OpenBrace = Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace); ParseItem feature; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out feature)) { Feature = feature; Children.Add(feature); } if (stream.Current.Type == TokenType.Colon) Colon = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation); // dump all values while (!IsExpressionTerminator(stream.Current.Type)) { ParseItem value; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out value)) { FeatureValues.Add(value); Children.Add(value); } else { Children.AddCurrentAndAdvance(stream); } } if (stream.Current.Type == TokenType.CloseFunctionBrace) CloseBrace = Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace); return Children.Count > 0; }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) { Value = item; Children.Add(item); } if (stream.Current.Type == TokenType.Comma) Comma = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation); return Children.Count > 0; }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { while (IsValidNameComponent(stream.Current.Type)) { ParseItem fragement; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out fragement)) { Fragments.Add(fragement); Children.Add(fragement); if (fragement is TokenItem) fragement.ClassifierType = SassClassifierType.PropertyName; } } return Children.Count > 0; }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { var name = new VariableName(SassClassifierType.VariableDefinition); if (name.Parse(itemFactory, text, stream)) { Name = name; Children.Add(name); } if (stream.Current.Type == TokenType.Colon) { Colon = Children.AddCurrentAndAdvance(stream); } while (!IsValueTerminator(Mode, stream)) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) { Values.Add(item); Children.Add(item); } } if (stream.Current.Type == TokenType.Bang) { var modifier = new DefaultModifier(); if (modifier.Parse(itemFactory, text, stream)) { Modifier = modifier; Children.Add(modifier); } else { Children.AddCurrentAndAdvance(stream); } } if (stream.Current.Type == TokenType.Semicolon) { Semicolon = Children.AddCurrentAndAdvance(stream); } return(Children.Count > 0); }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) { Value = item; Children.Add(item); } if (stream.Current.Type == TokenType.Comma) { Comma = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation); } return(Children.Count > 0); }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (AtRule.IsRule(text, stream, "while")) { ParseRule(itemFactory, text, stream); while (!IsConditionTerminator(stream.Current.Type)) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) Children.Add(item); } ParseBody(itemFactory, text, stream); } return Children.Count > 0; }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (stream.Current.Type == TokenType.OpenInterpolation) { OpenInterpolation = Children.AddCurrentAndAdvance(stream, SassClassifierType.Interpolation); while (!IsTerminator(stream.Current.Type)) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) Children.Add(item); } if (stream.Current.Type == TokenType.CloseInterpolation) CloseInterpolation = Children.AddCurrentAndAdvance(stream, SassClassifierType.Interpolation); } return Children.Count > 0; }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { while (IsValidNameComponent(stream.Current.Type)) { ParseItem fragement; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out fragement)) { Fragments.Add(fragement); Children.Add(fragement); if (fragement is TokenItem) { fragement.ClassifierType = SassClassifierType.PropertyName; } } } return(Children.Count > 0); }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (AtRule.IsRule(text, stream, "while")) { ParseRule(itemFactory, text, stream); while (!IsConditionTerminator(stream.Current.Type)) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) { Children.Add(item); } } ParseBody(itemFactory, text, stream); } return(Children.Count > 0); }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { var name = new VariableName(SassClassifierType.VariableDefinition); if (name.Parse(itemFactory, text, stream)) { Name = name; Children.Add(name); } if (stream.Current.Type == TokenType.Colon) Colon = Children.AddCurrentAndAdvance(stream); while (!IsValueTerminator(Mode, stream)) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) { Values.Add(item); Children.Add(item); } } if (stream.Current.Type == TokenType.Bang) { var modifier = new DefaultModifier(); if (modifier.Parse(itemFactory, text, stream)) { Modifier = modifier; Children.Add(modifier); } else { Children.AddCurrentAndAdvance(stream); } } if (stream.Current.Type == TokenType.Semicolon) Semicolon = Children.AddCurrentAndAdvance(stream); return Children.Count > 0; }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (stream.Current.Type == TokenType.StartOfFile) { stream.Advance(); while (stream.Current.Type != TokenType.EndOfFile) { int position = stream.Position; ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) { Children.Add(item); } else if (stream.Position == position) { // add current token if and only if we didn't move position at all Children.AddCurrentAndAdvance(stream); } } } return(Children.Count > 0); }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (stream.Current.Type == TokenType.OpenInterpolation) { OpenInterpolation = Children.AddCurrentAndAdvance(stream, SassClassifierType.Interpolation); while (!IsTerminator(stream.Current.Type)) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) { Children.Add(item); } } if (stream.Current.Type == TokenType.CloseInterpolation) { CloseInterpolation = Children.AddCurrentAndAdvance(stream, SassClassifierType.Interpolation); } } return(Children.Count > 0); }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (stream.Current.Type == TokenType.StartOfFile) { stream.Advance(); while (stream.Current.Type != TokenType.EndOfFile) { int position = stream.Position; ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) { Children.Add(item); } else if (stream.Position == position) { // add current token if and only if we didn't move position at all Children.AddCurrentAndAdvance(stream); } } } return Children.Count > 0; }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if ((IsConditionalDirective(text, stream) || IsConditionalContinuationDirective(text, stream))) { ParseRule(itemFactory, text, stream); while (!IsConditionTerminator(stream.Current.Type)) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) { Children.Add(item); ConditionStatements.Add(item); } else { Children.AddCurrentAndAdvance(stream); } } ParseBody(itemFactory, text, stream); while (IsConditionalContinuationDirective(text, stream)) { var subsequentConditional = itemFactory.CreateSpecific <ConditionalControlDirective>(this, text, stream); if (!subsequentConditional.Parse(itemFactory, text, stream)) { break; } ElseStatements.Add(subsequentConditional); Children.Add(subsequentConditional); } } return(Children.Count > 0); }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { if (stream.Current.Type == TokenType.Identifier && IsModifier(text.GetText(stream.Current.Start, stream.Current.Length))) { Modifier = Children.AddCurrentAndAdvance(stream); } ParseItem mediaType; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out mediaType)) { MediaType = mediaType; Children.Add(mediaType); } while (!IsTerminator(text, stream)) { var expression = itemFactory.CreateSpecific <MediaQueryExpression>(this, text, stream); if (expression.Parse(itemFactory, text, stream)) { _Expressions.Add(expression); Children.Add(expression); } else { Children.AddCurrentAndAdvance(stream); } } if (stream.Current.Type == TokenType.Comma) { Comma = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation); } return(Children.Count > 0); }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { //if (IsDeclaration(text, stream)) if (stream.Current.Type == TokenType.Identifier || stream.Current.Type == TokenType.OpenInterpolation) { var name = itemFactory.CreateSpecific <PropertyName>(this, text, stream); if (name.Parse(itemFactory, text, stream)) { Name = name; Children.Add(name); } if (stream.Current.Type == TokenType.Colon) { Colon = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation); } while (!IsValueTerminator(stream.Current.Type)) { ParseItem value; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out value)) { Values.Add(value); Children.Add(value); // bind all unknown values as property values if (value.ClassifierType == SassClassifierType.Default && value is TokenItem) { value.ClassifierType = SassClassifierType.PropertyValue; } } } // nested property block support if (stream.Current.Type == TokenType.OpenCurlyBrace) { var block = itemFactory.CreateSpecific <NestedPropertyBlock>(this, text, stream); if (block.Parse(itemFactory, text, stream)) { Children.Add(block); } } if (stream.Current.Type == TokenType.Bang) { var modifier = new ImportanceModifier(); if (modifier.Parse(itemFactory, text, stream)) { Modifier = modifier; Children.Add(modifier); } } if (stream.Current.Type == TokenType.Semicolon) { Semicolon = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation); } } return(Children.Count > 0); }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { //if (IsDeclaration(text, stream)) if (stream.Current.Type == TokenType.Identifier || stream.Current.Type == TokenType.OpenInterpolation) { var name = itemFactory.CreateSpecific<PropertyName>(this, text, stream); if (name.Parse(itemFactory, text, stream)) { Name = name; Children.Add(name); } if (stream.Current.Type == TokenType.Colon) Colon = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation); while (!IsValueTerminator(stream.Current.Type)) { ParseItem value; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out value)) { Values.Add(value); Children.Add(value); // bind all unknown values as property values if (value.ClassifierType == SassClassifierType.Default && value is TokenItem) value.ClassifierType = SassClassifierType.PropertyValue; } } // nested property block support if (stream.Current.Type == TokenType.OpenCurlyBrace) { var block = itemFactory.CreateSpecific<NestedPropertyBlock>(this, text, stream); if (block.Parse(itemFactory, text, stream)) Children.Add(block); } if (stream.Current.Type == TokenType.Bang) { var modifier = new ImportanceModifier(); if (modifier.Parse(itemFactory, text, stream)) { Modifier = modifier; Children.Add(modifier); } } if (stream.Current.Type == TokenType.Semicolon) Semicolon = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation); } return Children.Count > 0; }