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

fix: DOT operator in string concatenation is optional #190

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Attribute expressions ending with dot are not parsed correctly
- Improve evaluation and diagnostics of conditional assembler expressions
- Operands of dynamically generated statements may be incorrectly parsed
- DOT operator in string concatenation is optional

## [0.14.0](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/0.13.0...0.14.0) (2021-08-18)

Expand Down
2 changes: 1 addition & 1 deletion parser_library/src/parsing/grammar/ca_expr_rules.g4
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ ca_string returns [ca_expr_ptr ca_expr]
{
$ca_expr = std::move($ca_string_b.ca_expr);
}
| tmp=ca_string dot ca_string_b
| tmp=ca_string dot? ca_string_b
{
auto r = provider.get_range($tmp.ctx->getStart(), $ca_string_b.ctx->getStop());
$ca_expr = std::make_unique<ca_basic_binary_operator<ca_conc>>(std::move($tmp.ca_expr), std::move($ca_string_b.ca_expr), r);
Expand Down
45 changes: 44 additions & 1 deletion parser_library/test/semantics/concatenation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "gmock/gmock.h"

#include "../common_testing.h"
#include "semantics/concatenation_term.h"

using namespace hlasm_plugin::parser_library::semantics;
Expand Down Expand Up @@ -83,4 +84,46 @@ TEST(concatenation, contains_var_sym)

EXPECT_EQ(var, nullptr);
}
}
}

TEST(concatenation, no_dots)
{
std::string input = R"(
&A SETC ' '
&A SETC '&A'(1,1)'&A'(1,1)
)";
analyzer a(input);
a.analyze();
a.collect_diags();

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

TEST(concatenation, with_dots)
{
std::string input = R"(
&A SETC ' '
&A SETC '&A'(1,1).'&A'(1,1)
)";
analyzer a(input);
a.analyze();
a.collect_diags();

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

TEST(concatenation, no_dots_without_subscript)
{
std::string input = R"(
&A SETC ' '
&A SETC '&A''&A'
)";
analyzer a(input);
a.analyze();
a.collect_diags();

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