com.joanju
Class ProparseLdr

java.lang.Object
  extended by com.joanju.ProparseLdr

public class ProparseLdr
extends java.lang.Object

Primary JNI interface to proparse.dll. Is a "Singleton". Create a reference to this in order to refer to the parser and its API.


Method Summary
 int attrGetI(int handle, int key)
          Returns the integer value of a node attribute.
 java.lang.String attrGetS(int handle, java.lang.String key)
          Returns the string value of a node attribute.
 int attrSet(int handle, int key, int val)
          Sets a node's attribute.
 java.lang.String attrStringGet(int handle, int key)
          Returns the string value of an integer-keyed node attribute.
 int attrStringSet(int handle, int key, java.lang.String val)
          Sets a string attribute on a node.
 int cleanup()
          Not currently used.
 java.lang.String configGet(java.lang.String flag)
          Returns a configuration value.
 int configSet(java.lang.String flag, java.lang.String val)
          Sets a configuration value.
 int copyHandle(int fromHandle, int toHandle)
          Copies a pointer to a node, the result being that toHandle now points to the same node as fromHandle.
 int dictAdd(java.lang.String theText, java.lang.String theType)
          Adds a user string literal to the user node types dictionary.
 int dictDelete(java.lang.String theText)
          Removes a string literal from the user node types dictionary.
 java.lang.String diff(java.lang.String file1, java.lang.String file2)
          Trivially finds differences between two files.
 int errorClear()
          Resets Proparse's error status to zero and clears out the warning/error text.
 int errorGetIsCurrent()
          Use this function to find out if the current error status is current.
 int errorGetStatus()
          Get the parser's error status.
 java.lang.String errorGetText()
          If there is an error condition in Proparse, then this returns the error message.
 java.lang.String[] getFilenameArray()
          Deprecated. May,2006. The new "filename-list" node attribute is used when the tree is loaded into JPNode, and the filename array is stored in the ProgramRootNode object.
 int getHandle()
          Get a node handle.
 java.lang.String getIndexFilename(int index)
          Deprecated. See the new "filename-list" node attribute in Proparse.
static ProparseLdr getInstance()
          This class is a "singleton"
 int getNodeColumn(int handle)
          Get the column position of a node's original text.
 int getNodeFileIndex(int handle)
          Get the file index for a given node.
 java.lang.String getNodeFilename(int handle)
          If the node represents an actual source code token, then this function returns the name of the source file where the token was found.
 int getNodeLine(int handle)
          If the node represents an actual source code token, then this function returns the line number within the source file where the token was found.
 java.lang.String getNodeText(int handle)
          Returns the original source code for the given node's token.
 java.lang.String getNodeType(int handle)
          Returns the type of the given node's token.
 int getNodeTypeI(int handle)
          Returns the integer type of the given node's token.
 java.lang.String getTokenTypeName(int tokenTypeNumber)
          Returns the token type name of the given token type number.
 int getTokenTypeNumber(java.lang.String tokenTypeName)
          Returns the token type number of the given token type name.
 java.lang.String getVersion()
          Returns the version of proparse.dll.
 int hiddenAddToFront(int theHandle, java.lang.String newType, java.lang.String newText)
          Creates a new hidden token with type newType and text newText, and makes this token the first hidden token of theHandle.
 int hiddenDelete(int theHandle)
          Deletes the current hidden token of theHandle.
 int hiddenGetBefore(int handle)
          Sets the current hidden token to be the hidden token that comes before the node referred to by the input handle.
 int hiddenGetColumn()
          This function returns the column position within the source file where the current hidden token was found.
 java.lang.String hiddenGetFilename()
          Returns the name of the source file where the current hidden token came from.
 int hiddenGetFirst(int handle)
          Sets the current hidden token to be the first hidden token that comes before the node referred to by the input handle.
 int hiddenGetLine()
          Returns the line number within the source file where the current hidden token came from.
 int hiddenGetNext()
          Finds the next hidden token after the current hidden token, then sets the current hidden token to be that newly found one.
 int hiddenGetPrevious()
          Finds the hidden token previous to the current hidden token, then sets the current hidden token to be that newly found one.
 java.lang.String hiddenGetText()
          Returns the text of the current hidden token.
 java.lang.String hiddenGetType()
          Returns the type of the current hidden token, for example "WS" for whitespace, or "COMMENT".
 int hiddenInsertAfter(java.lang.String newType, java.lang.String newText)
          Creates a new hidden token of the given type and text and inserts it after the current hidden token.
 int hiddenSetText(java.lang.String newText)
          Sets the text of the current hidden token to newText.
 int hiddenSetType(java.lang.String newType)
          Sets the type of the current hidden token to newType.
 int init()
          Not currently used.
 int isSameNode(int handle1, int handle2)
          Compares the node for handle1 with the node for handle2, and returns 1 if the handles refer to the same node or returns 0 if they don't.
 int isValidNode(int handle)
          Checks the node for theHandle, and returns true if the handle refers to a valid node or returns false if the node isn't valid.
 java.lang.String iwdiff(java.lang.String file1, java.lang.String file2)
          Used by testrun2.p to check that the output from compile with preprocess is the same as the output from the parser.
static java.lang.String loadUsing(java.lang.String fullpath)
          Try to load proparse.dll using a fully qualified path/filename.
 int nodeCreate(int intoHandle, java.lang.String newType, java.lang.String newText)
          Creates a new node of type newType, with text newText, and places the handle of this new node into the intoHandle.
 int nodeCreateI(int intoHandle, int newType, java.lang.String newText)
          Creates a new node of integer type newType (which does not have to be a valid node type), with text newText, and places the handle of this new node into the intoHandle.
 java.lang.String nodeFirstChild(int ofHandle, int intoHandle)
          A handle to the first child of ofHandle is stored in intoHandle.
 int nodeFirstChildI(int ofHandle, int intoHandle)
          A handle to the first child of ofHandle is stored in intoHandle.
 java.lang.String nodeNextSibling(int ofHandle, int intoHandle)
          A handle to the next sibling of ofHandle is stored in intoHandle.
 int nodeNextSiblingI(int ofHandle, int intoHandle)
          A handle to the next sibling of ofHandle is stored in intoHandle.
 java.lang.String nodeParent(int ofHandle, int intoHandle)
          A handle to the parent of ofHandle is stored in intoHandle.
 java.lang.String nodePrevSibling(int ofHandle, int intoHandle)
          A handle to the previous sibling of ofHandle is stored in intoHandle.
 java.lang.String nodeStateHead(int ofHandle, int intoHandle)
          A handle to the statement head node of ofHandle is stored in intoHandle.
 java.lang.String nodeTop(int handle)
          Stores a reference to the topmost node in the node handle intoHandle.
 int parse(java.lang.String filename)
          Parses the program file specified by filename.
 int parseCreate(java.lang.String parseType, java.lang.String fileName)
          Causes Proparse to scan filename and create a scanner result set.
 int parseDelete(int parseNum)
          Deletes the parse number parseNum created by parserParseCreate.
 int parseGetTop(int parseNum, int nodeHandle)
          Finds the top (first) node from parse (or scan) result parseNum and causes handle intoHandle to refer to that node.
 int queryClear(java.lang.String queryName)
          Clears the named query.
 int queryCreate(int theNode, java.lang.String theQueryName, java.lang.String theType)
          
    Creates a named query.
 int queryGetResult(java.lang.String theQueryName, int resultNum, int intoHandle)
          Sets the handle intoHandle to point to the node referred to by result number resultNum in the query queryName.
 int releaseHandle(int theHandle)
          Releases a node handle for re-use.
 int schemaAddDb(java.lang.String name)
          Adds a name to Proparse's list of database names.
 int schemaAddTable(java.lang.String name)
          Adds a table name to the last added database name.
 int schemaAliasCreate(java.lang.String aliasname, java.lang.String dbname)
          If your program requires a database alias to exist before it will compile, then you must use this function to tell Proparse about your database alias before that program can be parsed.
 int schemaAliasDelete(java.lang.String aliasname)
          Use this function to delete an alias that you created with parserSchemaAliasCreate.
 int schemaClear()
          Use this function if you want to clear the old schema names out of Proparse and load a new list of schema names into Proparse.
 int schemaOldLoad()
          Not used.
 int setNodeFirstChild(int parentHandle, int childHandle)
          Sets the childHandle node to be the first child node of the parentHandle, displacing the former first child node.
 int setNodeNextSibling(int ofHandle, int sibHandle)
          Sets the sibHandle node to be the next sibling node of the ofHandle, displacing the former next sibling node.
 int setNodeText(int theNode, java.lang.String theText)
          Sets the ofHandle node's text in the tree to the newText.
 int setNodeType(int theNode, java.lang.String theType)
          Sets the node's type in the tree to theType.
 int setNodeTypeI(int theNode, int theType)
          Sets the node's type.
 int writeNode(int theNode, java.lang.String filename)
          Given an input node handle, parserWriteNode writes the text from that node and all of its child nodes, out to the text file filename.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ProparseLdr getInstance()
This class is a "singleton"


loadUsing

public static java.lang.String loadUsing(java.lang.String fullpath)
Try to load proparse.dll using a fully qualified path/filename. This method checks for exceptions, and returns a simple error string if the load failed.


getFilenameArray

public java.lang.String[] getFilenameArray()
Deprecated. May,2006. The new "filename-list" node attribute is used when the tree is loaded into JPNode, and the filename array is stored in the ProgramRootNode object.

Because the filenames are not actually stored, but an integer index is, it is common to need an array representation of the filenames. Important note: Sometimes Proparse will stick a blank "" entry into this list.

See Also:
ParseUnit.getFileIndex()

attrGetI

public int attrGetI(int handle,
                    int key)
Returns the integer value of a node attribute.

Parameters:
handle -
key - The integer representation of the attribute key.
Returns:
zero if the node does not have that attribute

attrGetS

public java.lang.String attrGetS(int handle,
                                 java.lang.String key)
Returns the string value of a node attribute.

Returns:
An empty string "" if the node does not have that attribute.

attrSet

public int attrSet(int handle,
                   int key,
                   int val)
Sets a node's attribute.

Parameters:
handle - The node's handle.
key - The attribute key.
val - The attribute value.
Returns:
positive int on success

attrStringGet

public java.lang.String attrStringGet(int handle,
                                      int key)
Returns the string value of an integer-keyed node attribute. This function doesn't use the same internal table as the parserAttrGet and parserAttrGetI functions, and there is no cross reference between the two tables.

Returns:
Returns an empty string "" if the node does not have that attribute.
See Also:
parserAttrStringSet

attrStringSet

public int attrStringSet(int handle,
                         int key,
                         java.lang.String val)
Sets a string attribute on a node. This function doesn't use the same internal table as the parserAttrSet function, and there is no cross reference between the two tables.

Returns:
Positive integer on success.
See Also:
parserAttrStringGet

cleanup

public int cleanup()
Not currently used.


configGet

public java.lang.String configGet(java.lang.String flag)
Returns a configuration value. If an invalid configuration flag parameter is used, then an empty string "" is returned and a Proparse error condition is raised.


configSet

public int configSet(java.lang.String flag,
                     java.lang.String val)
Sets a configuration value.

Returns:
A positive integer on success.

copyHandle

public int copyHandle(int fromHandle,
                      int toHandle)
Copies a pointer to a node, the result being that toHandle now points to the same node as fromHandle.

Returns:
A positive integer on success.

dictAdd

public int dictAdd(java.lang.String theText,
                   java.lang.String theType)
Adds a user string literal to the user node types dictionary. For example, parserDictAdd("define_const", "DEFINE") would add "define_const" as a string literal to be treated the same as "def" or "DEFINE".

Parameters:
theText - The string literal to add.
theType - Must be a valid Proparse node type.
Returns:
A positive integer on success.

dictDelete

public int dictDelete(java.lang.String theText)
Removes a string literal from the user node types dictionary.

Parameters:
theText - The string literal to remove.
Returns:
1 even if theText did not exist as an entry in the user node types dictionary.

diff

public java.lang.String diff(java.lang.String file1,
                             java.lang.String file2)
Trivially finds differences between two files. Used by Joanju for testing the scanner.

Returns:
An empty string "" if no differences were found.

errorClear

public int errorClear()
Resets Proparse's error status to zero and clears out the warning/error text.

Returns:
1.

errorGetIsCurrent

public int errorGetIsCurrent()
Use this function to find out if the current error status is current. If subsequent API function calls have been made since the call which raised the error status, then this function returns 0.

Returns:
1 if true, 0 if false.

errorGetStatus

public int errorGetStatus()
Get the parser's error status. If an API function call raises a warning or an error status, that warning or error status remains in effect until parserErrorClear is called.

Returns:
Returns zero if there is no error or warning. Returns -1 if there has been a warning. Returns -2 if there has been an error.

errorGetText

public java.lang.String errorGetText()
If there is an error condition in Proparse, then this returns the error message. Use this function to get the text of warnings as well as errors. (i.e. Use this function whether the error status is -1 or -2.) If an API function call raises a warning or an error status, that warning or error message remains available until parserErrorClear is called.

Returns:
An empty string "" if there is no current error condition.

getHandle

public int getHandle()
Get a node handle. To use node handles, define an int variable and use parserGetHandle to set its value. That variable can now be used in places where the parser's API requires a node handle. If there is a free node pointer (one that has been released by parserReleaseHandle), then the DLL will reuse it, rather than create a new pointer.

Returns:
An integer reference to a pointer to a node.

getIndexFilename

public java.lang.String getIndexFilename(int index)
Deprecated. See the new "filename-list" node attribute in Proparse.

Get the file name for a given file index. Not commonly used. Normally, you would want to just use getNodeFilename. File name indexes, rather than the entire filename, are stored in the syntax tree in Proparse. You can use this index number for efficient external storage of the syntax tree. Raises a warning condition if an invalid index was accessed. Use the warning condition (errorGetStatus) if iterating through index numbers to get all filenames. Do not check for a blank filename return - there is no guarantee that there will not be a blank entry in the filename list.

Parameters:
index - The file index
Returns:
The file name, as stored within Proparse. Raises warning condition if the index number is invalid.
See Also:
getNodeFileIndex(int), getNodeFilename(int)

getNodeColumn

public int getNodeColumn(int handle)
Get the column position of a node's original text. If the node represents an actual source code token, then this function returns the column position within the source file where the token was found. A tab character counts as a single column.

Returns:
Integer column position, starts at 1.

getNodeFileIndex

public int getNodeFileIndex(int handle)
Get the file index for a given node. Not commonly used. Normally, you would want to just use getNodeFilename. File name indexes, rather than the entire filename, are stored in the syntax tree in Proparse. You can use this index number for efficient external storage of the syntax tree.

Parameters:
handle - The node handle
Returns:
The integer index to the file's name
See Also:
getNodeFilename(int)

getNodeFilename

public java.lang.String getNodeFilename(int handle)
If the node represents an actual source code token, then this function returns the name of the source file where the token was found.


getNodeLine

public int getNodeLine(int handle)
If the node represents an actual source code token, then this function returns the line number within the source file where the token was found.


getNodeText

public java.lang.String getNodeText(int handle)
Returns the original source code for the given node's token. For example, if the node type is "SUBSTRING", the original source code that the node's token is related to may have been "substr".


getNodeType

public java.lang.String getNodeType(int handle)
Returns the type of the given node's token. For example, if the original source code token was "substr", the node type is "SUBSTRING".


getNodeTypeI

public int getNodeTypeI(int handle)
Returns the integer type of the given node's token. For example, if the original source code token was "substr", the node type would be "SUBSTRING" and the integer node type might be 766.

See Also:
parserSetNodeTypeI

getTokenTypeName

public java.lang.String getTokenTypeName(int tokenTypeNumber)
Returns the token type name of the given token type number. For example, Proparse's internal representation of token type number 766 may be the SUBSTRING token type (these numbers can change).

Returns:
An empty string "" if the tokenTypeNumber is not valid.
See Also:
parserGetTokenTypeNumber

getTokenTypeNumber

public int getTokenTypeNumber(java.lang.String tokenTypeName)
Returns the token type number of the given token type name. For example, Proparse's internal representation of the SUBSTRING token type may be token type number 766 (these numbers can change). Differs from the parserGetNodeTypeI function in that a specific node does not need to be supplied.

See Also:
parserGetTokenTypeName

getVersion

public java.lang.String getVersion()
Returns the version of proparse.dll.


hiddenAddToFront

public int hiddenAddToFront(int theHandle,
                            java.lang.String newType,
                            java.lang.String newText)
Creates a new hidden token with type newType and text newText, and makes this token the first hidden token of theHandle. It also becomes the current hidden token. See also Modifying Hidden Tokens in the User Guide.

Parameters:
theHandle -
newType -
newText -
Returns:
Positive integer on success.

hiddenDelete

public int hiddenDelete(int theHandle)
Deletes the current hidden token of theHandle. If there is a "next" hidden token, it becomes the current hidden token. Otherwise, if there is a "previous" hidden token, it becomes the current hidden token. If this was the last hidden token of theHandle, there is no current hidden token. See also Modifying Hidden Tokens in the User's Guide.

Returns:
Positive integer on success.

hiddenGetBefore

public int hiddenGetBefore(int handle)
Sets the current hidden token to be the hidden token that comes before the node referred to by the input handle.

Returns:
1 if found, 0 if not found, negative number on error.

hiddenGetColumn

public int hiddenGetColumn()
This function returns the column position within the source file where the current hidden token was found. A tab character counts as a single column.


hiddenGetFilename

public java.lang.String hiddenGetFilename()
Returns the name of the source file where the current hidden token came from.


hiddenGetFirst

public int hiddenGetFirst(int handle)
Sets the current hidden token to be the first hidden token that comes before the node referred to by the input handle. See Hidden Tokens in the User's Guide for a description of what "first hidden token" means.

Returns:
1 if found, 0 if not found, negative number on error.

hiddenGetLine

public int hiddenGetLine()
Returns the line number within the source file where the current hidden token came from.


hiddenGetNext

public int hiddenGetNext()
Finds the next hidden token after the current hidden token, then sets the current hidden token to be that newly found one.

Returns:
1 if found, 0 if not found, negative number on error.

hiddenGetPrevious

public int hiddenGetPrevious()
Finds the hidden token previous to the current hidden token, then sets the current hidden token to be that newly found one.

Returns:
1 if found, 0 if not found, negative number on error.

hiddenGetText

public java.lang.String hiddenGetText()
Returns the text of the current hidden token.


hiddenGetType

public java.lang.String hiddenGetType()
Returns the type of the current hidden token, for example "WS" for whitespace, or "COMMENT".


hiddenInsertAfter

public int hiddenInsertAfter(java.lang.String newType,
                             java.lang.String newText)
Creates a new hidden token of the given type and text and inserts it after the current hidden token. The new token then becomes the current hidden token. See also Modifying Hidden Tokens in the User Guide.

Returns:
Positive integer on success, negative integer on error.

hiddenSetText

public int hiddenSetText(java.lang.String newText)
Sets the text of the current hidden token to newText. See also Modifying Hidden Tokens.

Returns:
Positive integer on success, negative integer on error.

hiddenSetType

public int hiddenSetType(java.lang.String newType)
Sets the type of the current hidden token to newType. Valid values are "WS" for whitespace, or "COMMENT". Returns true on success. See also parserHiddenGetType and Modifying Hidden Tokens in the User Guide.

Returns:
Positive integer on success, negative integer on error.

init

public int init()
Not currently used.

Returns:
Always returns 1.

isSameNode

public int isSameNode(int handle1,
                      int handle2)
Compares the node for handle1 with the node for handle2, and returns 1 if the handles refer to the same node or returns 0 if they don't. Returns negative number on error.


isValidNode

public int isValidNode(int handle)
Checks the node for theHandle, and returns true if the handle refers to a valid node or returns false if the node isn't valid.


iwdiff

public java.lang.String iwdiff(java.lang.String file1,
                               java.lang.String file2)
Used by testrun2.p to check that the output from compile with preprocess is the same as the output from the parser. Originally named as "Ignore Whitespace diff", it does less ignoring whitespace now, and does much more to compensate for the way that Progress's preprocessor writes out preprocessed code.

Parameters:
file1 - The COMPILE..PREPROCESS output
file2 - The output from Proparse (usually just from the writenode function)
Returns:
Empty string on success, otherwise a string showing the line numbers from the two files where a difference was found.

nodeCreate

public int nodeCreate(int intoHandle,
                      java.lang.String newType,
                      java.lang.String newText)
Creates a new node of type newType, with text newText, and places the handle of this new node into the intoHandle. See also "Tree Manipulation and Code Refactoring" and its subsection "Creating Nodes" (in the User Guide) for further information, including how to find valid node types for this function.

Returns:
Positive integer on success.

nodeCreateI

public int nodeCreateI(int intoHandle,
                       int newType,
                       java.lang.String newText)
Creates a new node of integer type newType (which does not have to be a valid node type), with text newText, and places the handle of this new node into the intoHandle. See also "Tree Manipulation and Code Refactoring" and its subsection "Creating Nodes" (in the User Guide) for further information, including how to find valid node types for this function.

Returns:
Positive integer on success.

nodeFirstChild

public java.lang.String nodeFirstChild(int ofHandle,
                                       int intoHandle)
A handle to the first child of ofHandle is stored in intoHandle. If there is no first child, intoHandle is not changed. The same handle may be used for both ofHandle and intoHandle, with the effect of moving the handle from one node to the next.

Returns:
Returns "" if ofHandle has no first child, otherwise, the found node's type is returned.

nodeFirstChildI

public int nodeFirstChildI(int ofHandle,
                           int intoHandle)
A handle to the first child of ofHandle is stored in intoHandle. If there is no first child, intoHandle is not changed. The same handle may be used for both ofHandle and intoHandle, with the effect of moving the handle from one node to the next.

Returns:
Returns 0 if ofHandle has no first child, otherwise, the found node's integer node type is returned.

nodeNextSibling

public java.lang.String nodeNextSibling(int ofHandle,
                                        int intoHandle)
A handle to the next sibling of ofHandle is stored in intoHandle. If there is no next sibling, intoHandle is not changed. The same handle may be used for both ofHandle and intoHandle, with the effect of moving the handle from one node to the next.

Returns:
Returns "" if ofHandle has no next sibling, otherwise, the found node's type is returned.

nodeNextSiblingI

public int nodeNextSiblingI(int ofHandle,
                            int intoHandle)
A handle to the next sibling of ofHandle is stored in intoHandle. If there is no next sibling, intoHandle is not changed. The same handle may be used for both ofHandle and intoHandle, with the effect of moving the handle from one node to the next.

Returns:
Returns 0 if ofHandle has no next sibling, otherwise, the found node's type is returned.

nodeParent

public java.lang.String nodeParent(int ofHandle,
                                   int intoHandle)
A handle to the parent of ofHandle is stored in intoHandle. If there is no parent, intoHandle is not changed. The same handle may be used for both ofHandle and intoHandle, with the effect of moving the handle from one node to the next.

Returns:
Returns "" if ofHandle has no parent, otherwise, the found node's type is returned.

nodePrevSibling

public java.lang.String nodePrevSibling(int ofHandle,
                                        int intoHandle)
A handle to the previous sibling of ofHandle is stored in intoHandle. If there is no previous sibling, intoHandle is not changed. The same handle may be used for both ofHandle and intoHandle, with the effect of moving the handle from one node to the next.

Returns:
Returns "" if ofHandle has no previous sibling, otherwise, the found node's type is returned.

nodeStateHead

public java.lang.String nodeStateHead(int ofHandle,
                                      int intoHandle)
A handle to the statement head node of ofHandle is stored in intoHandle. If there is no statement head node, intoHandle is not changed. The same handle may be used for both ofHandle and intoHandle, with the effect of moving the handle from one node to the next.
    A "statement head node" is a node with the attribute "statehead". See "statehead" in the Parameter Values Reference. parserNodeStateHead may be used iteratively to move up/out through nested blocks, all the way up to the outermost block. For example, given the program DO: DISPLAY "Hi!". END. and starting at the QSTRING "Hi!" node, the first call to parserNodeStateHead would find the DISPLAY node. The second call would find the DO node. A third call would not find another statement head - blank would be returned, and intoHandle would not be changed.

Returns:
Returns "" if ofHandle has no statement head node, otherwise, the found node's type is returned.

nodeTop

public java.lang.String nodeTop(int handle)
Stores a reference to the topmost node in the node handle intoHandle. The topmost node is always a special node of type Program_root. Unlike most nodes, the Program_root node does not represent any actual token from your program's source code.

Returns:
Returns "Program_root" on success, or "" on failure (i.e. if there is no syntax tree).

parse

public int parse(java.lang.String filename)
Parses the program file specified by filename. If the parse failed, there will not be any syntax tree available to work with. Your application is responsible for getting and dealing with the text of the error message.

Parameters:
filename -
Returns:
A positive integer on success, a negative integer if the parse failed.

parseCreate

public int parseCreate(java.lang.String parseType,
                       java.lang.String fileName)
Causes Proparse to scan filename and create a scanner result set.

Parameters:
parseType - The only valid value for is "scan"".
fileName - The name of the source file to "scan".
Returns:
An integer "parse number", which is used as a handle to other functions like parserParseGetTop and parserParseDelete.

parseDelete

public int parseDelete(int parseNum)
Deletes the parse number parseNum created by parserParseCreate. Also deletes all queries related to that scan result, as well as all handles to nodes in that scan result.

Returns:
Negative integer only if there was an error, 1 otherwise.

parseGetTop

public int parseGetTop(int parseNum,
                       int nodeHandle)
Finds the top (first) node from parse (or scan) result parseNum and causes handle intoHandle to refer to that node.

Returns:
Positive integer on success, negative integer on error.

queryClear

public int queryClear(java.lang.String queryName)
Clears the named query. Pass an empty string "" to clear all queries.


queryCreate

public int queryCreate(int theNode,
                       java.lang.String theQueryName,
                       java.lang.String theType)

    Creates a named query. Any number of queries can be created, and referred to by name. The query starts at the fromNode node handle, evaluating that node and all of its child nodes. A list of node references is created within Proparse, one node reference for each node that is of the input nodeType. This function returns the number of results (the number of node references that were added to the list). You reference this result list with the function parserQueryGetResult. If a previous query of the same name exists, it is cleared out first.
    You can pass an empty string "" as the node type to build an "unfiltered query". All nodes are added to the result set. This has the effect of flattening the tree down into a one dimensional vector of nodes. Operator nodes are placed in between their operands, so that this feature is especially useful for printing out code.
    In order to make it possible to quickly find the first node of a given line number in a scan result, a built-in function was added, and it is accessed via the existing queries API. For example:
parserQueryCreate(topNode, "myQuery", "first_where_line=" + STRING(myLine)).
...where topNode is the first node in a scan result, and myLine is an integer line number. Queries with option first_where_line= are only sensible and only supported for scanner results.

Parameters:
theNode - The topmost node to start from.
theQueryName - Your unique name for the query.
theType - The type of node to search for, or "" for an "unfiltered" query (all nodes, flattened).
Returns:
The number of results (the number of node references that were added to the list).

queryGetResult

public int queryGetResult(java.lang.String theQueryName,
                          int resultNum,
                          int intoHandle)
Sets the handle intoHandle to point to the node referred to by result number resultNum in the query queryName.

Parameters:
theQueryName - The name of a query created with the function parserQueryCreate.
resultNum - An integer between one and the number of results for that query.
intoHandle - A valid node handle, created with the function parserGetHandle.
Returns:
1 on success, negative integer on failure.

releaseHandle

public int releaseHandle(int theHandle)
Releases a node handle for re-use. See Node Handles / Releasing Node Handles in the User Guide.


schemaAddDb

public int schemaAddDb(java.lang.String name)
Adds a name to Proparse's list of database names.


schemaAddTable

public int schemaAddTable(java.lang.String name)
Adds a table name to the last added database name.


schemaAliasCreate

public int schemaAliasCreate(java.lang.String aliasname,
                             java.lang.String dbname)
If your program requires a database alias to exist before it will compile, then you must use this function to tell Proparse about your database alias before that program can be parsed. If the alias already exists, then it is replaced with the new value.


schemaAliasDelete

public int schemaAliasDelete(java.lang.String aliasname)
Use this function to delete an alias that you created with parserSchemaAliasCreate. To delete all aliases, use an empty string as this function's argument (i.e. parserSchemaAliasDelete("") ).


schemaClear

public int schemaClear()
Use this function if you want to clear the old schema names out of Proparse and load a new list of schema names into Proparse. For example, you might use this after making schema changes or after changing from one working environment to another.


schemaOldLoad

public int schemaOldLoad()
Not used.


setNodeFirstChild

public int setNodeFirstChild(int parentHandle,
                             int childHandle)
Sets the childHandle node to be the first child node of the parentHandle, displacing the former first child node. Returns true on success. Use 0 for childHandle to indicate that there are no children. This function doesn't change the relationships between the child node and its own children, its siblings, or its hidden nodes. See also Tree Manipulation and Code Refactoring subsection Moving Nodes in the User Guide.


setNodeNextSibling

public int setNodeNextSibling(int ofHandle,
                              int sibHandle)
Sets the sibHandle node to be the next sibling node of the ofHandle, displacing the former next sibling node. Use 0 for sibHandle to indicate that there is no next sibling. This function doesn't change the relationships between the sibling node and its own children, its own siblings, or its hidden nodes. See also Tree Manipulation and Code Refactoring subsection Moving Nodes in the User Guide.


setNodeText

public int setNodeText(int theNode,
                       java.lang.String theText)
Sets the ofHandle node's text in the tree to the newText. For example, if the node type is "SUBSTRING", the original source code that the node is related to may have been "substr". Use of this function allows the value in the original source code to be modified (when Proparse's tree is written out), for example to "SUBSTR".


setNodeType

public int setNodeType(int theNode,
                       java.lang.String theType)
Sets the node's type in the tree to theType. For example, if the node type is "FIRST", the node type may be changed to "LAST". See also Tree Manipulation and Code Refactoring in the User Guide.


setNodeTypeI

public int setNodeTypeI(int theNode,
                        int theType)
Sets the node's type.


writeNode

public int writeNode(int theNode,
                     java.lang.String filename)
Given an input node handle, parserWriteNode writes the text from that node and all of its child nodes, out to the text file filename.
    parserWriteNode takes care of ensuring that operators are written out with infix notation rather than the operator prefix notation that you would normally see when walking a tree. (i.e.: displays: 1 + 2 instead of: + 1 2). See Syntax Trees for more information about operator prefix notation from syntax trees.
    Also, parserWriteNode writes code that looks similar to the original source code by displaying the whitespace (hidden token) prior to each node. See Hidden Tokens.
This function is mostly used by Joanju as a very fast function to write out the results of a parse to a text file, which can then be compared to the output of a COMPILE...PREPROCESS. This allows us to test that programs are parsing correctly.
    Additionally, parserWriteNode is a handy way to write out nodes found in ad hoc queries. For example, see examples/query_length.p.



Copyright © 2008 Joanju Software. All Rights Reserved.