Skip to content

Commit

Permalink
Fix REDEFINE detection for FILLERs in VIEWs (#362)
Browse files Browse the repository at this point in the history
fixes #251
  • Loading branch information
MarkusAmshove authored Sep 10, 2023
1 parent 290d2bc commit 33b9a5f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ViewParser extends AbstractParser<ViewNode>

private final Map<String, VariableNode> declaredVariables;
private ViewNode view;
private RedefinitionNode currentRedefine;

ViewParser(IModuleProvider moduleProvider, Map<String, VariableNode> declaredVariables)
{
Expand Down Expand Up @@ -185,6 +186,12 @@ private GroupNode group(VariableNode variable) throws ParseError
? (RedefinitionNode) variable
: new GroupNode(variable);

var previousRedefine = currentRedefine;
if (variable instanceof RedefinitionNode redefine)
{
currentRedefine = redefine;
}

if (previousToken().kind() == SyntaxKind.LPAREN)
{
addArrayDimensions(group);
Expand All @@ -195,14 +202,15 @@ private GroupNode group(VariableNode variable) throws ParseError
{
if (peek().intValue() <= group.level())
{
currentRedefine = previousRedefine;
break;
}

if (peekKind(1, SyntaxKind.FILLER) && group instanceof RedefinitionNode)
if (peekKind(1, SyntaxKind.FILLER) && currentRedefine != null)
{
if (mightBeFillerBytes(peek(1), peek(2)))
{
parseRedefineFiller((RedefinitionNode) group);
parseRedefineFiller(currentRedefine);
continue;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,21 @@ void parseFillerInRedefines()
assertThat(redefine.fillerBytes()).isEqualTo(90);
}

@Test
void parseFillerInRedefinesInViews()
{
assertParsesWithoutDiagnostics("""
DEFINE DATA LOCAL
1 MYVIEW VIEW OF MYDDM
2 ANARRAY (A61/1:1)
2 REDEFINE ANARRAY
3 INREDEFINE (1:1)
4 #INGRP (A1)
4 FILLER 56X
END-DEFINE
""");
}

@Test
void raiseADiagnosticIfAFillerIsUsedOutsideOfRedefine()
{
Expand Down

0 comments on commit 33b9a5f

Please sign in to comment.