Resolving parse errors detected by Jacl2Jython
The IBM Jacl to Jython Conversion Assistant (Jacl2Jython) does a single pass through the input Jacl script each time it runs, however, the parser tokens are not context sensitive. Regardless of this limitation, most input Jacl scripts can be parsed and converted with no or few manual changes to help the Jacl2Jython parser to continue parsing. However, there might be cases where a particular Jacl token can have different syntactical meanings, but the scanner and parser only handles the most common definition, and this can result in a parse error.
When the Jacl2Jython program encounters a problem parsing the input Jacl script file, it stops with a parse error message that contains the following information:
- the fully qualified name of the problematic script
- the line and column number of where the parse error might be occurring
- the cause of the parse error
- the list of expecting Jacl syntax that should have followed prior to reaching the problematic syntax
For example, parsing the input line of Jacl script:
Results in the following parse error message:set subpaths [split $JavaClasspath :]########################################################### ERROR: Error during parse of input=D:\temp\ParseErrorSample.jacl ... Location: at line=1, column=36 ... Cause: Encountered unexpected token=: ... Was expecting one of: <MATH_OP> <LOGICAL_OP> <DECIMAL> "[list" "[ list" <NAME> <VARIABLE> <STRING> <DEFAULTSTRING "{" "\"{}\"" "\"{ }\"" "\"" "]" "{}" "[" ###########################################################
- The most common parse error is when the Jacl2Jython program cannot distinguish some Jacl syntax as a string element; by default string elements contain no quotations in the Jacl scripting language. The solution is to explicitly add quotations around the Jacl syntax that are difficult to identify as string elements.
In most situations, the Jacl2Jython program is able to detect and handle the default string elements in a Jacl script. However, there are cases where it is difficult for the Jacl2Jython program to make the distinction. Continuing with the above example illustrates this point, the error message specified that line #1 and column #36 is where the parsing problem was encountered:
set subpaths [split $JavaClasspath :] ^The colon character : is the cause of the parse error. To resolve the parse error, add explicit quotations around the colon character:
A colon character is a valid token for the Jacl scripting language as a conditional statement. The Jacl2Jython parser could not identify weather the intended use of the colon character was for a conditional statement or a default string. By adding the quotation around the colon character in the input Jacl script, this helps the Jacl2Jython parser to understand that the intended syntactically meaning of the colon character is a default string.set subpaths [split $JavaClasspath ":"]- Tip: All input Jacl comment lines are written as comment lines in the Jython output script file. If you are having trouble solving a parser problem, add a #?PROBLEM? to comment out the line of Jacl script. Remember, if the line contains an open brace {, then you also need to comment out the matching close brace }. Afterwards, we can detect and further process these problematic lines of script.
Parent topics:
Developing Automation Scripts