Skip to content

Commit

Permalink
fix: Forward structured macro parameters correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
slavek-kucera authored Apr 25, 2022
1 parent f9532c5 commit 89d2936
Show file tree
Hide file tree
Showing 21 changed files with 735 additions and 253 deletions.
1 change: 1 addition & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Reaching ACTR limit now only generates warnings
- Parsing of negative numbers in machine expressions
- Empty arrays now behave similarly to other subscripted variables in macro tracer
- Forward structured macro parameters correctly

## [1.1.0](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/1.0.0...1.1.0) (2022-03-29)

Expand Down
86 changes: 43 additions & 43 deletions clients/vscode-hlasmplugin/proc_grps_schema
Original file line number Diff line number Diff line change
Expand Up @@ -48,50 +48,50 @@
"asm_options": {
"type": "object",
"description": "List of assembler options",
"properties": {
"OPTABLE": {
"type": "string",
"description": "Specifies the instruction set to use.",
"enum": [
"UNI",
"DOS",
"370",
"XA",
"ESA",
"ZOP",
"ZS1",
"YOP",
"ZS2",
"Z9",
"ZS3",
"Z10",
"ZS4",
"Z11",
"ZS5",
"Z12",
"ZS6",
"Z13",
"ZS7",
"Z14",
"ZS8",
"Z15",
"ZS9"
]
},
"SYSPARM": {
"type": "string",
"description": "Specifies the character string the assembler assigns to the &SYSPARM system variable symbol.",
"maxLength": 255
},
"PROFILE": {
"type": "string",
"description": "Profile Member to be copied into the source program."
},
"SYSTEM_ID": {
"type": "string",
"description": "Provides the value for the SYSTEM_ID system variable. Defaults to 'z/OS 02.04.00' when omitted."
"properties": {
"OPTABLE": {
"type": "string",
"description": "Specifies the instruction set to use.",
"enum": [
"UNI",
"DOS",
"370",
"XA",
"ESA",
"ZOP",
"ZS1",
"YOP",
"ZS2",
"Z9",
"ZS3",
"Z10",
"ZS4",
"Z11",
"ZS5",
"Z12",
"ZS6",
"Z13",
"ZS7",
"Z14",
"ZS8",
"Z15",
"ZS9"
]
},
"SYSPARM": {
"type": "string",
"description": "Specifies the character string the assembler assigns to the &SYSPARM system variable symbol.",
"maxLength": 255
},
"PROFILE": {
"type": "string",
"description": "Profile Member to be copied into the source program."
},
"SYSTEM_ID": {
"type": "string",
"description": "Provides the value for the SYSTEM_ID system variable. Defaults to 'z/OS 02.04.00' when omitted."
}
}
}
},
"preprocessor": {
"description": "Defines optional preprocessor pass for open code.",
Expand Down
1 change: 0 additions & 1 deletion parser_library/src/debugging/set_symbol_variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ std::string set_symbol_variable::get_string_array_value() const
array_value.append(get_string_value(static_cast<int>(key)));
array_value.append(",");
}

array_value.back() = ')';

return array_value;
Expand Down
12 changes: 11 additions & 1 deletion parser_library/src/parsing/error_strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,19 @@ enum tokens
// copied from antlr4::DefaultErrorStrategy.
class error_strategy final : public antlr4::DefaultErrorStrategy
{
bool m_error_reported = false;
void reset(antlr4::Parser* recognizer) override
{
m_error_reported = false;
antlr4::DefaultErrorStrategy::reset(recognizer);
}
void reportError(antlr4::Parser* recognizer, const antlr4::RecognitionException& e) override
{
if (inErrorRecoveryMode(recognizer))
if (m_error_reported && inErrorRecoveryMode(recognizer))
{
return; // don't report spurious errors
}
m_error_reported = true;

// recovery strategy
antlr4::misc::IntervalSet endTokens;
Expand Down Expand Up @@ -69,6 +76,9 @@ class error_strategy final : public antlr4::DefaultErrorStrategy
antlr4::Token* singleTokenDeletion(antlr4::Parser*) override { return nullptr; }

bool singleTokenInsertion(antlr4::Parser*) override { return false; }

public:
bool error_reported() const { return m_error_reported; }
};

} // namespace hlasm_plugin::parser_library::parsing
Expand Down
26 changes: 10 additions & 16 deletions parser_library/src/parsing/grammar/deferred_operand_rules.g4
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ deferred_entry returns [std::vector<vs_ptr> vs]
|
(
{std::string name;}
AMPERSAND (ORDSYMBOL {name += $ORDSYMBOL->getText();})+
AMPERSAND
ORDSYMBOL {name += $ORDSYMBOL->getText();}
(ORDSYMBOL {name += $ORDSYMBOL->getText();}|NUM {name += $NUM->getText();})*
{
auto r = provider.get_range($AMPERSAND,$ORDSYMBOL);
auto r = provider.get_range($AMPERSAND,_input->LT(-1));
$vs.push_back(std::make_unique<basic_variable_symbol>(hlasm_ctx->ids().add(std::move(name)), std::vector<ca_expr_ptr>(), r));
collector.add_hl_symbol(token_info(r,hl_scopes::var_symbol));
}
Expand All @@ -66,9 +68,14 @@ deferred_entry returns [std::vector<vs_ptr> vs]
{
name += $ORDSYMBOL->getText();
}
|
NUM
{
name += $NUM->getText();
}
)*
{
auto r = provider.get_range($AMPERSAND,$ORDSYMBOL);
auto r = provider.get_range($AMPERSAND,_input->LT(-1));
$vs.push_back(std::make_unique<basic_variable_symbol>(hlasm_ctx->ids().add(std::move(name)), std::vector<ca_expr_ptr>(), r));
collector.add_hl_symbol(token_info(r,hl_scopes::var_symbol));
}
Expand All @@ -81,19 +88,6 @@ deferred_entry returns [std::vector<vs_ptr> vs]
finally
{enable_ca_string();}

def_string_body
: string_ch_v
| IGNORED
| CONTINUATION;

def_string returns [concat_chain chain]
: ap1=APOSTROPHE def_string_body*? ap2=(APOSTROPHE|ATTR)
{
collector.add_hl_symbol(token_info(provider.get_range($ap1,$ap2),hl_scopes::string));
};
finally
{concatenation_point::clear_concat_chain($chain);}

deferred_op_rem returns [remark_list remarks, std::vector<vs_ptr> var_list]
:
(
Expand Down
23 changes: 20 additions & 3 deletions parser_library/src/parsing/grammar/hlasmparser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,32 @@ id_no_dot returns [id_index name = id_storage::empty_id] locals [std::string buf
}
;

remark_ch: DOT|ASTERISK|MINUS|PLUS|LT|GT|COMMA|LPAR|RPAR|SLASH|EQUALS|AMPERSAND|APOSTROPHE|IDENTIFIER|NUM|VERTICAL|ORDSYMBOL|SPACE|ATTR;

remark
: remark_ch*;
: (DOT|ASTERISK|MINUS|PLUS|LT|GT|COMMA|LPAR|RPAR|SLASH|EQUALS|AMPERSAND|APOSTROPHE|IDENTIFIER|NUM|VERTICAL|ORDSYMBOL|SPACE|ATTR)*;

remark_non_empty
: (DOT|ASTERISK|MINUS|PLUS|LT|GT|COMMA|LPAR|RPAR|SLASH|EQUALS|AMPERSAND|APOSTROPHE|IDENTIFIER|NUM|VERTICAL|ORDSYMBOL|SPACE|ATTR)+;

remark_o returns [std::optional<range> value]
: SPACE remark {$value = provider.get_range( $remark.ctx);}
| ;

remark_eol returns [std::optional<range> value]
:
(
SPACE
{
auto s = _input->LT(1);
}
l=(DOT|ASTERISK|MINUS|PLUS|LT|GT|COMMA|LPAR|RPAR|SLASH|EQUALS|AMPERSAND|APOSTROPHE|IDENTIFIER|NUM|VERTICAL|ORDSYMBOL|SPACE|ATTR)*
{$value = provider.get_range(s, $l);}
)?
(
CONTINUATION
|
EOF
)
;



Expand Down
11 changes: 7 additions & 4 deletions parser_library/src/parsing/grammar/label_field_rules.g4
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ common_ch returns [std::string value]

l_ch returns [std::string value]
: common_ch {$value = std::move($common_ch.value);}
| EQUALS {$value = "=";}
| COMMA {$value = ",";}
| LPAR {$value = "(";}
| RPAR {$value = ")";};
Expand All @@ -151,17 +150,21 @@ common_ch_v returns [concat_point_ptr point]
| GT {$point = std::make_unique<char_str_conc>(">", provider.get_range($GT));}
| SLASH {$point = std::make_unique<char_str_conc>("/", provider.get_range($SLASH));}
| EQUALS {$point = std::make_unique<equals_conc>();}
| l=AMPERSAND r=AMPERSAND {$point = std::make_unique<char_str_conc>("&&", provider.get_range($l,$r));}
| VERTICAL {$point = std::make_unique<char_str_conc>("|", provider.get_range($VERTICAL));}
| IDENTIFIER {$point = std::make_unique<char_str_conc>($IDENTIFIER->getText(), provider.get_range($IDENTIFIER));}
| NUM {$point = std::make_unique<char_str_conc>($NUM->getText(), provider.get_range($NUM));}
| ORDSYMBOL {$point = std::make_unique<char_str_conc>($ORDSYMBOL->getText(), provider.get_range($ORDSYMBOL));}
| DOT {$point = std::make_unique<dot_conc>();}
| var_symbol {$point = std::make_unique<var_sym_conc>(std::move($var_symbol.vs));};
|
(
l=AMPERSAND r=AMPERSAND {$point = std::make_unique<char_str_conc>("&&", provider.get_range($l,$r));}
|
var_symbol {$point = std::make_unique<var_sym_conc>(std::move($var_symbol.vs));}
)
;

l_ch_v returns [concat_point_ptr point]
: common_ch_v {$point = std::move($common_ch_v.point);}
| EQUALS {$point = std::make_unique<char_str_conc>("=", provider.get_range($EQUALS));}
| COMMA {$point = std::make_unique<char_str_conc>(",", provider.get_range($COMMA));}
| LPAR {$point = std::make_unique<char_str_conc>("(", provider.get_range($LPAR));}
| RPAR {$point = std::make_unique<char_str_conc>(")", provider.get_range($RPAR));};
Expand Down
Loading

0 comments on commit 89d2936

Please sign in to comment.