Closed smedilol closed 1 year ago
To add the diagnostic:
In Scanner.GetTokenStartingFrom
, just before main switch
if (currentState.InsidePseudoText)
{
if (!CobolChar.IsAllowedInsidePseudoText(line[startIndex]))
{
[Add diagnostic]
}
}
The method CobolChar.IsAllowedInsidePseudoText
has to be created, see how to factorize with what is allready done for this issue.
Bonus: the property IsPseudoText
in Token
class can be removed, it is not used.
We'll have to exclude '('
and ')'
first because it won't work with https://github.com/TypeCobolTeam/TypeCobol/blob/develop/TypeCobol.Test/Parser/Preprocessor/ReplaceTestFiles/PgmReplaceFunction.cbl 😞
Describe the bug
IBM Compiler check characters allowed in replace clause. See "Chapter 1. Characters" page 3 of IBM PDF "Enterprise COBOL for z/OS 6.3 Language Reference".
Allowed characters are :
So for example we must forbid character
@
in replace like IBM compiler.Out of scope
This issue is only about Partial Cobol word because a few programs in our company are not parsed correctly. Allowed characters in replace directive out of partial cobol word will not be checked in this issue.
To Reproduce
CheckPseudoText1.rdz.cbl:
Expected behavior
Mandatory: check that characters inside a partial cobol word are valid.
Bonus : Same error as IBM compiler. IBM compiler sometimes seems to stop its parsing or try to find the end of the replace clause. We don't need to reproduce this behavior of course. It would be better to detect that the replace clause was intented to finish at a certain point and report that the replace is invalid.
Technical
In
CobolChar
, add a new methodIsAllowedInsidePartialCobolWord(char)
which must return true if char is accepted byIsCobolWordChar
, otherwise check if the character is in following list:Note that
:
will not be accepted for now because we first need to fix #2309 to handle such cases.In
ScannerUtils.CheckForPartialCobolWordPattern
, replace call toCobolChar.IsCobolWordChar
byCobolChar.IsAllowedInsidePartialCobolWord
.Check impact on RegexReplace in ReplaceIterator.
How to test automatically
Standard unit test with Token comparator.