This page will provide a few starter hints for using the Proparse libraries.
Follow along in the source code, or else in the 'javadoc' here:
oehive.github.io/proparse-javadoc/
We use an instance of this class:
RefactorSession prsession = RefactorSession.getInstance();
With our instance, we are able to load our project settings :
prsession.loadProject(projectName);
This package contains a number of frequently used classes, such as SymbolScope
and Symbol
. As examples, there is a SymbolScope for every PROCEDURE
, and there is a Symbol for every VARIABLE
.
var f = new java.io.File(fileName); ParseUnit pu = new ParseUnit(f);
Note that if you are using Proparse.Net, java.io.File
is actually provided by the IKVM libraries! Good thing, since it's required as the input parameter for constructing a ParseUnit.
Here is the basic method for building the syntax tree:
parseUnit.treeParser01();
It is builds the syntax tree in two passes. The first pass is the basic parser, the second pass builds the symbol tables.
Now let's get the topmost node in the syntax tree:
pu.getTopNode()
Also of interest is pu.getRootScope()
, because Scopes are where the symbol tables are stored.
This is the base class for nodes in Proparse's syntax tree. Have a look at the javadoc. There are a huge number of methods available in this class, and it also has a few interesting subclasses.
Use the static members of TokenTypes to check on the type of a JPNode. For example:
if (node.getType() == TokenTypes.DEFINE) ...
(TokenTypes inherits all its integer token types from org.prorefactor.treeparserbase.JPTreeParserTokenTypes
, which is not published in the javadoc. Your IDE should pop up the complete list when you type TokenTypes.
into your editor.)