private IEnumerable <IdentifierPart> GetIdentifierParts(string prefix, LessParser.IdentifierContext idContext)
        {
            if (!string.IsNullOrEmpty(prefix))
            {
                yield return(new ConstantIdentifierPart(prefix));
            }

            var identifier = idContext.Identifier() ?? idContext.IdentifierAfter();

            if (identifier != null)
            {
                yield return(new ConstantIdentifierPart(identifier.GetText()));
            }

            if (idContext.keywordAsIdentifier() != null)
            {
                yield return(new ConstantIdentifierPart(idContext.keywordAsIdentifier().GetText()));
            }

            var variableInterpolation = idContext.variableInterpolation();

            if (variableInterpolation != null)
            {
                yield return(new InterpolatedVariableIdentifierPart(variableInterpolation.identifierVariableName().GetText()));
            }

            foreach (var partContext in idContext.identifierPart())
            {
                if (partContext.IdentifierAfter() != null)
                {
                    yield return(new ConstantIdentifierPart(partContext.IdentifierAfter().GetText()));
                }

                if (partContext.identifierVariableName() != null)
                {
                    yield return(new InterpolatedVariableIdentifierPart(partContext.identifierVariableName().GetText()));
                }
            }
        }
Exemplo n.º 2
0
 public virtual LessNode VisitIdentifier(LessParser.IdentifierContext context)
 {
     throw new System.NotImplementedException();
 }
 public override LessNode VisitIdentifier(LessParser.IdentifierContext context)
 {
     return(new Identifier(GetIdentifierParts(null, context)));
 }