⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ptnode.cpp

📁 这是一些于C++做的经典例子
💻 CPP
字号:
#include <stdio.h>

#include "PTNode.H"


void
PTNode::Dump() const
{
  Dump_Internal( 0 );
  printf( "\n" );

}


void
PTNode::Dump_Internal( int indent ) const
{
  int c = 0;
  for ( ; c < indent; c += 2 )
    printf( " |" );

  printf( " +-- %s\n", GetName().c_str() );


  NodeList::const_iterator i = GetChildrenBegin();
  NodeList::const_iterator end = GetChildrenEnd();

  indent += 2;

  for ( ; i != end; ++i ) {
    PTNodePtr node = *i;

    // It is okay for some nodes to have NULL pointers in their list of
    // children.  This just means that the optional child is not specified.
    if ( node == NULL )
      continue;

    node->Dump_Internal( indent );
  }

  indent -= 2;
}



// When dumping the parse tree, it is useful to see what the actual constant
// number.  Make sure to add its value to the name string.
string
ConstantNode::GetName() const
{
  char name[64];
  sprintf( name, "Constant %d", m_value );

  return name;
}



string
IdentifierNode::GetName() const
{
  return "Identifier " + m_name;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -