Skip to content

Commit

Permalink
fix: Structured macro variables were not forwarded correctly when a d…
Browse files Browse the repository at this point in the history
…ot separator was used in the macro operand
  • Loading branch information
slavek-kucera committed May 27, 2022
1 parent 790e128 commit dcb5aeb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Parsing of numeric nominal values must be case insensitive
- The language server may crash when a complex expression is used as a variable symbol index
- References to CA variables in strings are not reported
- Structured macro variables were not forwarded correctly when a dot separator was used in the macro operand

## [1.2.0](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/1.1.0...1.2.0) (2022-05-11)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ bool is_keyword(const semantics::concat_chain& chain, context::hlasm_context& hl
&& hlasm_ctx.try_get_symbol_name(chain[0]->access_str()->value).first;
}

bool can_chain_be_forwarded(const semantics::concat_chain& chain)
{
if (chain.size() == 1 && chain.front()->type == semantics::concat_type::VAR) // single variable symbol &VAR
return true;
if (chain.size() == 2 && chain.front()->type == semantics::concat_type::VAR
&& chain.back()->type == semantics::concat_type::DOT) // single variable symbol with dot &VAR.
return true;
return false;
}

std::vector<context::macro_arg> macro_processor::get_operand_args(const resolved_statement& statement) const
{
std::vector<context::macro_arg> args;
Expand All @@ -249,7 +259,7 @@ std::vector<context::macro_arg> macro_processor::get_operand_args(const resolved
{
get_keyword_arg(statement, tmp_chain, args, keyword_params, tmp->operand_range);
}
else if (tmp_chain.size() == 1 && tmp_chain.front()->type == semantics::concat_type::VAR) // single varsym
else if (can_chain_be_forwarded(tmp_chain)) // single varsym
{
context::macro_data_ptr data = string_to_macrodata(
semantics::var_sym_conc::evaluate(tmp_chain.front()->access_var()->symbol->evaluate(eval_ctx)));
Expand Down
26 changes: 26 additions & 0 deletions parser_library/test/parsing/string_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,29 @@ TEST(parser, preserve_structured_parameter)
EXPECT_TRUE(a.diags().empty());
EXPECT_EQ(get_var_value<C_t>(a.hlasm_ctx(), "PAR"), "A");
}

TEST(parser, preserve_structured_parameter_2)
{
std::string input = R"(
GBLC &PAR
MACRO
MAC2
GBLC &PAR
&PAR SETC '&SYSLIST(1,1)'
MEND
MACRO
MAC &P1
MAC2 &P1.
MEND
MAC (A,O'-9')
)";
analyzer a(input);
a.analyze();
a.collect_diags();

EXPECT_TRUE(a.diags().empty());
EXPECT_EQ(get_var_value<C_t>(a.hlasm_ctx(), "PAR"), "A");
}

0 comments on commit dcb5aeb

Please sign in to comment.