示例#1
0
void 
ASTBase::writeNegInfinity(XMLOutputStream& stream) const
{

  stream.startElement("apply");
  stream.startEndElement("minus");
  stream.startEndElement("infinity");
  stream.endElement("apply");
}
示例#2
0
void
ASTBase::writeENotation (  const std::string&    mantissa
                         , const std::string&    exponent
                         , XMLOutputStream& stream ) const
{

  static const string enotation = "e-notation";
  stream.writeAttribute("type", enotation);

  stream << " " << mantissa << " ";
  stream.startEndElement("sep");
  stream << " " << exponent << " ";
}
void
ASTNaryFunctionNode::write(XMLOutputStream& stream) const
{
  int type  = getType();
  unsigned int numChildren = getNumChildren();

  if (numChildren <= 2 && (type == AST_PLUS || type == AST_TIMES))
  {
    writeNodeOfType(stream, type);
  }
  else if (type == AST_UNKNOWN && numChildren == 0)
  {
    // we have an empty apply tag
    stream.startEndElement("apply");
  }
  else
  {

    stream.startElement("apply");
      
    //const char * name = ASTBase::getNameFromType(type);
    		
    ASTBase::writeStartEndElement(stream);
      
      /* write children */
     

    /* HACK TO REPLICATE OLD AST */
    /* for log/root with two or more children assume first is logbase/degree
     * and last is the value operated on
     * 
     * however if the node is read in with a logbase and then more than
     * further children it uses the first as the value operated on
     */
    if (type == AST_FUNCTION_ROOT)
    {
      if (numChildren > 1)
      {
        if (ASTFunctionBase::getChild(0)->getType() != AST_QUALIFIER_DEGREE)
        {
          ASTQualifierNode * logbase = new ASTQualifierNode(AST_QUALIFIER_DEGREE);
          logbase->addChild(ASTFunctionBase::getChild(0)->deepCopy());
          logbase->write(stream);
          delete logbase;
          ASTFunctionBase::getChild(numChildren-1)->write(stream);
        }
        else
        {
          /* if there is only 1 child that is logbase we dont write either */
          ASTFunctionBase::getChild(0)->write(stream);
          ASTFunctionBase::getChild(numChildren-1)->write(stream);
        }
      }
      else
      {
        ASTFunctionBase::getChild(0)->write(stream);
      }
    }
    else
    {
      for (unsigned int i = 0; i < ASTFunctionBase::getNumChildren(); i++)
      {
        ASTFunctionBase::getChild(i)->write(stream);
      }
    }
    stream.endElement("apply");
  }
}