diff --git a/libs/natparse/src/main/java/org/amshove/natparse/parsing/ViewParser.java b/libs/natparse/src/main/java/org/amshove/natparse/parsing/ViewParser.java index 0e8e166b0..78f902d3a 100644 --- a/libs/natparse/src/main/java/org/amshove/natparse/parsing/ViewParser.java +++ b/libs/natparse/src/main/java/org/amshove/natparse/parsing/ViewParser.java @@ -15,6 +15,7 @@ class ViewParser extends AbstractParser private final Map declaredVariables; private ViewNode view; + private RedefinitionNode currentRedefine; ViewParser(IModuleProvider moduleProvider, Map declaredVariables) { @@ -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); @@ -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; } } diff --git a/libs/natparse/src/test/java/org/amshove/natparse/parsing/DefineDataParserShould.java b/libs/natparse/src/test/java/org/amshove/natparse/parsing/DefineDataParserShould.java index 7675c19bc..ce3e5dbdb 100644 --- a/libs/natparse/src/test/java/org/amshove/natparse/parsing/DefineDataParserShould.java +++ b/libs/natparse/src/test/java/org/amshove/natparse/parsing/DefineDataParserShould.java @@ -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() {