Difference between revisions of "Prettyprint to a string"

From Verific Design Automation FAQ
Jump to: navigation, search
(Created page with "'''Q: Why do I prettyprint a Verilog parsetree node to a string?''' Example code: VeriExpression *init_value = param_id -> GetInitialValue(); if (init_value)...")
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Q: Why do I prettyprint a Verilog parsetree node to a string?'''
+
'''Q: How do I prettyprint a parsetree node to a string?'''
  
Example code:
+
Simple APIs:
 +
    char * VeriTreeNode::GetPrettyPrintedString()
 +
    char * VhdlTreeNode::GetPrettyPrintedString()
 +
To avoid memory leak, please free the returned string when done.
 +
 
 +
 
 +
This example code is included here for historical reason:
 
         VeriExpression *init_value = param_id -> GetInitialValue();
 
         VeriExpression *init_value = param_id -> GetInitialValue();
 
         if (init_value) {
 
         if (init_value) {

Latest revision as of 12:40, 1 March 2019

Q: How do I prettyprint a parsetree node to a string?

Simple APIs:

   char * VeriTreeNode::GetPrettyPrintedString()
   char * VhdlTreeNode::GetPrettyPrintedString()

To avoid memory leak, please free the returned string when done.


This example code is included here for historical reason:

       VeriExpression *init_value = param_id -> GetInitialValue();
       if (init_value) {
           ostringstream os;
           init_value->PrettyPrint(os, 0);
           char *to_string = Strings::save(os.str().c_str()) ;
           cout << "*** initial value: " << to_string << " ***\n";
           Strings::free(to_string);
       }