PROREND Name
PROREND
Author
Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770
craigm@lheamail.gsfc.nasa.gov Purpose
Render a PRODIS abstract syntax tree into IDL Language Text
Calling Sequence
PROREND, TREE, TEXT, [ /INIT ] Description
PROREND converts an abstract syntax tree as returned by PRODIS,
into a human-readable form, written in the IDL programming
language. The abstract syntax tree format is a set of linked data
structures, and is derived from the raw data on disk. The human
readable form is returned as an array of strings that can be
printed to the console or a file.
The abstract syntax tree is generated by PRODIS, an external
procedure in the same library. The standard approach is to use
the following steps:
1. Use PRODIS to convert raw bytes to abstract syntax tree
2. Use PROREND to convert abstract syntax tree to IDL language
The external routine PROTRANS does the end-to-end conversion steps
of both PRODIS and PROREND for you.
At the moment there is relatively little flexibility in how the
IDL code is rendered to text. For example, all reserved keywords
and variables appear in upper-case letters, and array indexing
syntax is expressed with round ()'s instead of square []'s.
Suggestions on how to achieve this are solicited.
PROREND does not free the TREE structure. The user is responsible
to do this using the PROFREE procedure.
Compatibility
-- File Format --
PROREND accepts any tree provided by PRODIS. PRODIS cannot
examine compressed save files. It is able to read and translate
SAVE files produced by IDL 4, and IDL versions 5.0 through 5.5.
The output of PROREND should be compatible with IDL 4 and 5.
This procedure is part of the CMSVLIB SAVE library for IDL by
Craig Markwardt. You must have the full CMSVLIB core package
installed in order for this procedure to function properly.
Inputs
TREE - the abstract syntax tree, as returned by PRODIS. This
structure is unmodified by PROREND.
TEXT - upon output, the IDL code is placed in as an array of
strings in TEXT. By default, any new IDL code will be
*appended* to TEXT. Use the /INIT keyword to overwrite the
existing contents of TEXT.
Keywords
INIT - if set, then overwrite the TEXT array with the new IDL
code. By default (INIT not set), any new IDL code is
*appended* to TEXT.
Example
This example compiles a test function, saves it to a file called
test_pro.sav, and then disassembles the save file into a syntax
tree using PRODIS. Finally, the syntax tree is converted to IDL
text, which is printed to the console.
IDL> .comp
- pro test_pro, x
- x = x + 1
- return
- end
% Compiled module: TEST_PRO.
IDL> save, 'test_pro', /routine, file='test_pro.sav'
IDL> prodis, 'test_pro.sav', prodecl, tree
IDL> prorend, tree, text
IDL> print, text, format='(A)'
PRO TEST_PRO, X
;; Beginning of code
X = X+1 Return
END See Also
PRODIS, PROREND, CMSAVEDIR, CMSVLIB
Modification History
Written, 2000-2002, CM
Documented, 19 Mar 2002, CM
Added PRN_STRCAT, to avoid an internal library function, 22 Mar
2002, CM