Skip to content

EXTNAME is parsed incorrectly #176

@FraGag

Description

@FraGag

In ILE RPG, keyword EXTNAME is parsed incorrectly when it has the form EXTNAME('MYFILE':*ALL).

Steps to reproduce

  1. git clone https://github.com/IBM/ibmi-company_system.git
  2. git checkout c94ca30387de18f0d28af5f5669849c1773cfd76
  3. so -- This should output nothing.
  4. Apply the following patch:
diff --git a/qrpglesrc/depts.pgm.sqlrpgle b/qrpglesrc/depts.pgm.sqlrpgle
index 37b5f5c..5d16639 100755
--- a/qrpglesrc/depts.pgm.sqlrpgle
+++ b/qrpglesrc/depts.pgm.sqlrpgle
@@ -54,7 +54,7 @@
       *
           Dcl-S Index Int(5);
 
-          Dcl-Ds Department ExtName('DEPARTMENT') Alias Qualified;
+          Dcl-Ds Department ExtName('DEPARTMENT':*ALL) Alias Qualified;
           End-Ds;
 
           
  1. so -- This now outputs:
qrpglesrc/depts.pgm.sqlrpgle:56 - No object found for reference 'DEPARTMENT''

Notice that it's looking for an object named DEPARTMENT', with an extra apostrophe at the end.

Investigation

From a quick search through the code, I believe that the code decoding EXTNAMEs is here:

const value = trimQuotes(keyword[`EXTNAME`]);
return {
lookup: value.split(`:`)[0].toUpperCase(),
line: struct.position ? struct.position.range.line : undefined
};

We can see that it's trimming quotes first, then splitting on semicolons. However, it ought to split on semicolons first, then trim quotes on the first part.

Furthermore, it might be necessary to trim spaces both before and after trimming quotes. (The ILE RPG compiler treats EXTNAME( 'MYFILE ' : *ALL ) the same as EXTNAME('MYFILE':*ALL)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions