When parsing a package header with the following subtype definition:
"SUBTYPE EStatus IS PLS_INTEGER RANGE -999..999;"
i get the error:
ParseException at package <..\packages\las_mod_cicreate.pks>: net.sourceforge.pldoc.parser.ParseException: Encountered "-" at line 57, column 46.
Was expecting one of:
"FALSE" ...
"INTERVAL" ...
"NULL" ...
"TIMESTAMP" ...
"TRUE" ...
<UNSIGNED_NUMERIC_LITERAL> ...
<CHARACTER_LITERAL> ...
<STRING_LITERAL> ...
Last consumed token: "RANGE"
net.sourceforge.pldoc.parser.ParseException: Encountered "-" at line 57, column 46.
Was expecting one of:
"FALSE" ...
"INTERVAL" ...
"NULL" ...
"TIMESTAMP" ...
"TRUE" ...
<UNSIGNED_NUMERIC_LITERAL> ...
<CHARACTER_LITERAL> ...
<STRING_LITERAL> ...
at net.sourceforge.pldoc.parser.PLSQLParser.generateParseException(PLSQLParser.java:31615)
at net.sourceforge.pldoc.parser.PLSQLParser.jj_consume_token(PLSQLParser.java:31462)
at net.sourceforge.pldoc.parser.PLSQLParser.Literal(PLSQLParser.java:14075)
at net.sourceforge.pldoc.parser.PLSQLParser.subtype_definition(PLSQLParser.java:11439)
at net.sourceforge.pldoc.parser.PLSQLParser.declarativeUnit(PLSQLParser.java:2164)
at net.sourceforge.pldoc.parser.PLSQLParser.declarativeSection(PLSQLParser.java:2534)
at net.sourceforge.pldoc.parser.PLSQLParser.packageSpec(PLSQLParser.java:1198)
at net.sourceforge.pldoc.parser.PLSQLParser.input(PLSQLParser.java:628)
at net.sourceforge.pldoc.PLDoc.processPackage(PLDoc.java:489)
at net.sourceforge.pldoc.PLDoc.run(PLDoc.java:190)
at net.sourceforge.pldoc.PLDoc.main(PLDoc.java:124)
Package ..\packages\las_mod_cicreate.pks skipped.
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
I've added a more concise example raising the following error message::
ParseException at package <test.sql>: net.sourceforge.pldoc.parser.ParseException: Encountered "-" at line 8, column 45.
Was expecting one of:
"FALSE" ...
"INTERVAL" ...
"NULL" ...
"TIMESTAMP" ...
"TRUE" ...
<UNSIGNED_NUMERIC_LITERAL> ...
<CHARACTER_LITERAL> ...
<STRING_LITERAL> ...
Last consumed token: "RANGE"
net.sourceforge.pldoc.parser.ParseException: Encountered "-" at line 8, column 45.
Was expecting one of:
"FALSE" ...
"INTERVAL" ...
"NULL" ...
"TIMESTAMP" ...
"TRUE" ...
<UNSIGNED_NUMERIC_LITERAL> ...
<CHARACTER_LITERAL> ...
<STRING_LITERAL> ...
at net.sourceforge.pldoc.parser.PLSQLParser.generateParseException(PLSQLParser.java:31615)
at net.sourceforge.pldoc.parser.PLSQLParser.jj_consume_token(PLSQLParser.java:31462)
at net.sourceforge.pldoc.parser.PLSQLParser.Literal(PLSQLParser.java:14075)
at net.sourceforge.pldoc.parser.PLSQLParser.subtype_definition(PLSQLParser.java:11439)
at net.sourceforge.pldoc.parser.PLSQLParser.declarativeUnit(PLSQLParser.java:2164)
at net.sourceforge.pldoc.parser.PLSQLParser.declarativeSection(PLSQLParser.java:2534)
at net.sourceforge.pldoc.parser.PLSQLParser.packageSpec(PLSQLParser.java:1198)
at net.sourceforge.pldoc.parser.PLSQLParser.input(PLSQLParser.java:628)
at net.sourceforge.pldoc.PLDoc.processPackage(PLDoc.java:489)
at net.sourceforge.pldoc.PLDoc.run(PLDoc.java:190)
at net.sourceforge.pldoc.PLDoc.main(PLDoc.java:124)
Package test.sql skipped.
Simple fix to get this parsing is to alter the parse to expect a unary expression
constraint = <RANGE> startElement = Literal() ".." endElement = Literal() ) // RANGE -1 .. 31
to
constraint = <RANGE> startElement = UnaryExpression() ".." endElement = UnaryExpression() ) // In "RANGE -1 .. 31" -1 is a unary Expression
This allows the SUBTYPE specification to parse: cosmetically it is not very nice as the code currently adds a space between sign and digits, assuming that the sign is an operator (binary plus or minus) rather than a true unary plus or minus.
The problems also occur with TYPE declared with negative precision
CREATE OR REPLACE
PACKAGE pldoc_bug.testcase_range IS
SUBTYPE pldoc_integer IS PLS_INTEGER RANGE -127..+127;
g_var pldoc_integer := -0;
g_var_minus_one pldoc_integer := g_var-1 ;
g_var_plus_one pldoc_integer := g_var+1 ;
g_plus_one pldoc_integer := +1 ;
g_plus_one_plus_one pldoc_integer := +1+1 ;
g_plus_one_minus_one pldoc_integer := +1-1 ;
g_plus_one_minus_minus_one pldoc_integer := +1- -1 ;
g_plus_one_plus_minus_one pldoc_integer := +1+-1 ;
g_plus_one_plus_plus_one pldoc_integer := +1++1 ;
g_plus_one_plus_minus_one pldoc_integer := +1+-1 ;
g_plus_one_minus_plus_one pldoc_integer := +1-+1 ;
g_minus_one pldoc_integer := -1 ;
g_minus_one_plus_one pldoc_integer := -1+1 ;
g_minus_one_minus_one pldoc_integer := -1-1 ;
g_minus_one_minus_minus_one pldoc_integer := -1- -1 ;
g_minus_one_plus_minus_one pldoc_integer := -1+-1 ;
g_minus_one_plus_plus_one pldoc_integer := -1++1 ;
g_minus_one_plus_minus_one pldoc_integer := -1+-1 ;
g_minus_one_minus_plus_one pldoc_integer := -1-+1 ;
g_var_negative_precision number(10,-2) := 200 ;
g_var_ten_to_minus2 number := 10**(-2) ;
END;