Skip to content

Commit

Permalink
Recognize *SUBROUTINE system variable
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusAmshove committed May 21, 2024
1 parent 1b8723a commit 8137596
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,11 @@ private void consumeAsteriskOrSystemVariable()
createAndAdd(SyntaxKind.SV_TIME);
return;
}
if (scanner.advanceIfIgnoreCase("SUBROUTINE"))
{
createAndAdd(SyntaxKind.SV_SUBROUTINE);
return;
}
scanner.rollbackCurrentLexeme();
createAndAddCurrentSingleToken(SyntaxKind.ASTERISK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public enum SyntaxKind
APPLIC_NAME(false, true, false),
INIT_ID(false, true, false),
SV_TIME(false, true, false),
SV_SUBROUTINE(false, true, false),
TIMX(false, true, false),
TIMD(false, false, true),
TIMN(false, true, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public class BuiltInFunctionTable
""", ALPHANUMERIC, 0),
modifiableVariable(SyntaxKind.SV_NUMBER, "Get or set the number of record a FIND or HISTOGRAM statement. Uses the innermost statement if no label identifier is passed.", PACKED, 10),
modifiableVariable(SyntaxKind.SV_LENGTH, "This system variable returns the currently used length of a field defined as dynamic variable in terms of code units; for A and B format the size of one code unit is 1 byte and for U format the size of one code unit is 2 bytes (UTF-16). *LENGTH(field) applies to dynamic variables only.", INTEGER, 4),
unmodifiableVariable(SyntaxKind.SV_SUBROUTINE, "Returns the name of the current external subroutine. Content will aways be upper case.", ALPHANUMERIC, 32),
unmodifiableVariable(SyntaxKind.LINEX, """
Returns the line number of the invocation of this variable.
When this variable is used within copycodes, it contains the line numbers of all includes leading to this variable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,10 @@ void lexTime()
assertTokens("*TIME", token(SyntaxKind.SV_TIME, "*TIME"));
}

@Test
void lexSubroutine()
{
assertTokens("*SUBROUTINE", token(SyntaxKind.SV_SUBROUTINE, "*SUBROUTINE"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ void indexExternalSubroutines()
assertCanFindModule("EXTERNAL-SUBROUTINE", "EXTSUB", NaturalFileType.SUBROUTINE);
}

@Test
void indexExternalSubroutinesWithNoDefineDataAndNoSubroutineKeyword()
{
assertCanFindModule("SPECIAL-EXTERNAL", "SUBNODDD", NaturalFileType.SUBROUTINE);
}

@Test
void indexFunctions()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* External Subroutine with no DEFINE DATA and no SUBROUTINE keyword
DEFINE SPECIAL-EXTERNAL
INPUT *PROGRAM *SUBROUTINE
END-SUBROUTINE
END

0 comments on commit 8137596

Please sign in to comment.