public void Visit(ConditionalCompilationComment node)
 {
     if (node != null)
     {
         if (node.Statements != null)
         {
             node.Statements.Accept(this);
         }
     }
 }
示例#2
0
 public override void Visit(ConditionalCompilationComment node)
 {
     if (node != null && node.Statements != null && node.Statements.Count > 0)
     {
         // increment the conditional comment level, recurse (process all the
         // statements), then decrement the level when we are through.
         ++m_conditionalCommentLevel;
         base.Visit(node);
         --m_conditionalCommentLevel;
     }
 }
示例#3
0
        // unnest any child blocks
        private void UnnestBlocks(Block node)
        {
            // walk the list of items backwards -- if we come
            // to any blocks, unnest the block recursively.
            // Remove any empty statements as well.
            // We walk backwards because we could be adding any number of statements
            // and we don't want to have to modify the counter.
            for (int ndx = node.Count - 1; ndx >= 0; --ndx)
            {
                var nestedBlock = node[ndx] as Block;
                if (nestedBlock != null)
                {
                    // unnest recursively
                    UnnestBlocks(nestedBlock);

                    // if the block has a block scope, then we can't really unnest it
                    // without merging lexical scopes
                    if (nestedBlock.BlockScope == null)
                    {
                        // remove the nested block
                        node.RemoveAt(ndx);

                        // then start adding the statements in the nested block to our own.
                        // go backwards so we can just keep using the same index
                        node.InsertRange(ndx, nestedBlock.Children);
                    }
                }
                else if (node[ndx] is EmptyStatement)
                {
                    // remove empty statements (lone semicolons)
                    node.RemoveAt(ndx);
                }
                else if (ndx > 0)
                {
                    // see if the previous node is a conditional-compilation comment, because
                    // we will also combine adjacent those
                    var previousComment = node[ndx - 1] as ConditionalCompilationComment;
                    if (previousComment != null)
                    {
                        ConditionalCompilationComment thisComment = node[ndx] as ConditionalCompilationComment;
                        if (thisComment != null)
                        {
                            // two adjacent conditional comments -- combine them into the first.
                            previousComment.Statements.Append(thisComment.Statements);

                            // and remove the second one (which is now a duplicate)
                            node.RemoveAt(ndx);
                        }
                    }
                }
            }
        }
 public void Visit(ConditionalCompilationComment node)
 {
     if (node != null)
     {
         // recurse the children, but as soon as we get the flag set to true, bail
         foreach (var child in node.Children)
         {
             child.Accept(this);
             if (m_needsParens)
             {
                 break;
             }
         }
     }
 }
示例#5
0
 public void Visit(ConditionalCompilationComment node)
 {
     // invalid! ignore
     IsValid = false;
 }
 public void Visit(ConditionalCompilationComment node)
 {
     // invalid! ignore
     IsValid = false;
 }
 public override void Visit(ConditionalCompilationComment node)
 {
     if (node != null && node.Statements != null && node.Statements.Count > 0)
     {
         // increment the conditional comment level, recurse (process all the
         // statements), then decrement the level when we are through.
         ++m_conditionalCommentLevel;
         base.Visit(node);
         --m_conditionalCommentLevel;
     }
 }
示例#8
0
 public void Visit(ConditionalCompilationComment node)
 {
     // not applicable; terminate
 }
 public void Visit(ConditionalCompilationComment node)
 {
     if (node != null)
     {
         if (node.Statements != null)
         {
             node.Statements.Accept(this);
         }
     }
 }
 public void Visit(ConditionalCompilationComment node)
 {
     if (node != null)
     {
         // recurse the children, but as soon as we get the flag set to true, bail
         foreach (var child in node.Children)
         {
             child.Accept(this);
             if (m_needsParens)
             {
                 break;
             }
         }
     }
 }
示例#11
0
        AstNode ParseStatementLevelConditionalComment(bool fSourceElement)
        {
            Context context = m_currentToken.Clone();
            ConditionalCompilationComment conditionalComment = new ConditionalCompilationComment(context, this);

            GetNextToken();
            while(m_currentToken.Token != JSToken.ConditionalCommentEnd && m_currentToken.Token != JSToken.EndOfFile)
            {
                // if we get ANOTHER start token, it's superfluous and we should ignore it.
                // otherwise parse another statement and keep going
                if (m_currentToken.Token == JSToken.ConditionalCommentStart)
                {
                    GetNextToken();
                }
                else
                {
                    conditionalComment.Append(ParseStatement(fSourceElement));
                }
            }

            GetNextToken();

            // if the conditional comment is empty (for whatever reason), then
            // we don't want to return anything -- we found nothing.
            return conditionalComment.Statements.Count > 0 ? conditionalComment : null;
        }
 public void Visit(ConditionalCompilationComment node)
 {
     // not applicable; terminate
 }