Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise a diagnostic if FILLER is used outside of REDEFINE #361

Merged
merged 1 commit into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private ScopeNode scope() throws ParseError
checkIndependentVariable(variable);
}

if (peekKind(1, SyntaxKind.FILLER))
if (peekKind(1, SyntaxKind.FILLER) && peekKind(2, SyntaxKind.OPERAND_SKIP))
{
var currentRedefineNode = currentRedefine(variable);
if (currentRedefineNode != null)
Expand All @@ -178,7 +178,7 @@ private ScopeNode scope() throws ParseError
}
else
{
// TODO: Diagnostic: Filler can only be used on redefines
report(ParserErrors.unexpectedToken(peek(1), "FILLER can only be used in redefinitions"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,34 @@ void parseFillerInRedefines()
assertThat(redefine.fillerBytes()).isEqualTo(90);
}

@Test
void raiseADiagnosticIfAFillerIsUsedOutsideOfRedefine()
{
assertDiagnostic("""
DEFINE DATA
LOCAL
1 #GRP
2 FILLER 50X
2 #SUBSTR (A10)
END-DEFINE
""", ParserError.UNEXPECTED_TOKEN);
}

@Test
void notRaiseADiagnosticIfAVariableWithNameFillerIsUsedOutsideOfRedefine()
{
var data = assertParsesWithoutDiagnostics("""
DEFINE DATA
LOCAL
1 #GRP
2 FILLER (A5)
2 #SUBSTR (A10)
END-DEFINE
""");

assertThat(data.findVariable("FILLER")).isNotNull();
}

@Test
void parseSubsequentRedefineFiller()
{
Expand Down