Exemple #1
0
        /// <summary>The <see cref="TermNode"/> visit implementation</summary>
        /// <param name="termNode">The term AST node</param>
        /// <returns>The modified AST node if modified otherwise the original node</returns>
        public override AstNode VisitTermNode(TermNode termNode)
        {
            // term
            // : unary_operator?
            // [ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* |
            // TIME S* | FREQ S* ]
            // | STRING S* | IDENT S* | URI S* | hexcolor | function
            // ;

            // append for: unary_operator?
            // TODO - Shall we remove the '+' operator here?
            _printerFormatter.Append(termNode.UnaryOperator);
            if (termNode.IsBinary && FunctionNode.IsBinaryOperator(termNode.UnaryOperator))
            {
                _printerFormatter.Append(" ");
            }

            // append for: [ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* | TIME S* | FREQ S* ]
            if (!string.IsNullOrWhiteSpace(termNode.NumberBasedValue))
            {
                _printerFormatter.Append(termNode.NumberBasedValue);
            }
            else if (!string.IsNullOrWhiteSpace(termNode.StringBasedValue))
            {
                // append for: | STRING S* | IDENT S* | URI S*
                _printerFormatter.Append(termNode.StringBasedValue);
            }
            else if (!string.IsNullOrWhiteSpace(termNode.ReplacementTokenBasedValue))
            {
                // TODO: REPLACECSSTOKENONPRINT
                _printerFormatter.Append(termNode.ReplacementTokenBasedValue);
            }
            else if (!string.IsNullOrWhiteSpace(termNode.Hexcolor))
            {
                // append for: hexcolor
                _printerFormatter.Append(termNode.Hexcolor);
            }
            else if (termNode.FunctionNode != null)
            {
                // append for: function
                // Invoke the Function visitor
                termNode.FunctionNode.Accept(this);
            }

            foreach (var comment in termNode.ImportantComments)
            {
                comment.Accept(this);
            }

            return(termNode);
        }