JCF2: Support "otherwise" in a case clause. Issue #34592, patch from BrunoK.

git-svn-id: trunk@59640 -
This commit is contained in:
juha 2018-11-23 17:38:31 +00:00
parent 07abf42286
commit 02ba3da476
3 changed files with 7 additions and 5 deletions

View File

@ -3268,7 +3268,7 @@ end;
procedure TBuildParseTree.RecogniseCaseStmnt;
begin
// CaseStmt -> CASE Expression OF CaseSelector/';'... [ELSE Statement] [';'] END
// CaseStmt -> CASE Expression OF CaseSelector/';'... [ELSE / OTHERWISE Statement] [';'] END
PushNode(nCaseStatement);
Recognise(ttCase);
@ -3279,13 +3279,13 @@ begin
Recognise(ttOf);
while not (fcTokenList.FirstSolidTokenType in [ttElse, ttEnd]) do
while not (fcTokenList.FirstSolidTokenType in [ttElse, ttOtherwise, ttEnd]) do
RecogniseCaseSelector;
if fcTokenList.FirstSolidTokenType = ttElse then
if fcTokenList.FirstSolidTokenType in [ttElse, ttOtherwise] then
begin
PushNode(nElseCase);
Recognise(ttElse);
Recognise(fcTokenList.FirstSolidTokenType);
RecogniseStatementList([ttEnd]);
PopNode;
end;

View File

@ -123,6 +123,7 @@ type
ttOf,
ttOperator,
ttOut,
ttOtherwise,
ttPackage,
ttPacked,
ttProcedure,
@ -617,6 +618,7 @@ begin
AddKeyword('of', wtReservedWord, ttOf);
AddKeyword('operator', wtReservedWord, ttOperator);
AddKeyword('out', wtReservedWordDirective, ttOut);
AddKeyword('otherwise', wtReservedWord, ttOtherwise);
AddKeyword('packed', wtReservedWord, ttPacked);
AddKeyword('procedure', wtReservedWord, ttProcedure);
AddKeyword('program', wtReservedWord, ttProgram);

View File

@ -460,7 +460,7 @@ begin
// don't indent the case label again
if pt.HasParentNode(nCaseLabel, 6) then
Dec(liIndentCount)
else if (pt.TokenType = ttElse) and pt.HasParentNode(nElseCase, 1) then
else if (pt.TokenType in [ttElse, ttOtherwise]) and pt.HasParentNode(nElseCase, 1) then
Dec(liIndentCount);
if not FormattingSettings.Indent.IndentCaseElse then