Skip to content

Commit

Permalink
feat: USING and DROP support (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
slavek-kucera authored Feb 24, 2022
1 parent c0393d4 commit f9dfd05
Show file tree
Hide file tree
Showing 66 changed files with 3,295 additions and 653 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ parser_library/test/res/output/tokens/correctness.output
!/.vscode/extensions.json

parser_library/jni/generated/

.npmrc
3 changes: 3 additions & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## ****Unreleased****

#### Added
- USING and DROP support

## [1.0.0](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/0.15.1...1.0.0) (2022-01-31)

#### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"hlasm.continuationHandling": true,
"hlasm.useAutodetection": true
"hlasm.useAutodetection": true,
"workbench.editor.languageDetection": false
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"hlasm.continuationHandling": true,
"hlasm.useAutodetection": true,
"hlasm.serverVariant": "wasm"
"hlasm.serverVariant": "wasm",
"workbench.editor.languageDetection": false
}
1 change: 1 addition & 0 deletions parser_library/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ target_sources(parser_library PRIVATE
location.h
preprocessor_options.h
protocol.cpp
tagged_index.h
workspace_manager.cpp
workspace_manager_impl.h
)
Expand Down
116 changes: 31 additions & 85 deletions parser_library/src/checking/asm_instr_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,90 +145,50 @@ bool xattr::check(const std::vector<const asm_operand*>& to_check,
};

using_instr::using_instr(const std::vector<label_types>& allowed_types, std::string_view name_of_instruction)
: assembler_instruction(allowed_types, name_of_instruction, 2, -1) {};
: assembler_instruction(allowed_types, name_of_instruction, 2, 17) {};

bool using_instr::check(const std::vector<const asm_operand*>& to_check,
const range& stmt_range,
const diagnostic_collector& add_diagnostic) const
{
if (!operands_size_corresponding(to_check, stmt_range, add_diagnostic))
return false;
/*
// check first operand
// TO DO, waiting for the evaluation of relocatable expressions, symbols can be used
if (auto first_operand = get_complex_operand(to_check[0]); first_operand) //first operand must be therefore in the
form of (base, end)

// TODO: at this point the check is more or less redundant to the one performed in the process_USING function
// perform just the minimal validation - counts and forms
// detailed validation perform in the processing routine
if (auto first_operand = get_complex_operand(to_check[0]); first_operand)
{
if (first_operand->operand_identifier != "" ||
is_operand_complex(first_operand->operand_parameters[0].get()) ||
is_operand_complex(first_operand->operand_parameters[1].get())
|| first_operand->operand_parameters.size() != 2)
{
add_diagnostic(diagnostic_op::error_A104_USING_first_format());
return false;
}
if (!is_positive_value(get_simple_operand(first_operand->operand_parameters[0].get())->operand_identifier))
{
add_diagnostic(diagnostic_op::error_A101_USING_base_val());
return false;
}
if (!is_positive_value(get_simple_operand(first_operand->operand_parameters[1].get())->operand_identifier))
{
add_diagnostic(diagnostic_op::error_A102_USING_end_val());
return false;
}
if (std::stoi(get_simple_operand(first_operand->operand_parameters[1].get())->operand_identifier)
<= std::stoi(get_simple_operand(first_operand->operand_parameters[0].get())->operand_identifier))
{
add_diagnostic(diagnostic_op::error_A103_USING_end_exceed());
return false;
}
// first operand must be therefore in the form of (base, end)
if (first_operand->operand_identifier != "" || first_operand->operand_parameters.size() != 2
|| !is_operand_simple(first_operand->operand_parameters[0].get())
|| !is_operand_simple(first_operand->operand_parameters[1].get()))
{
add_diagnostic(diagnostic_op::error_A104_USING_first_format(first_operand->operand_range));
return false;
}
}
else if (auto simple_op = get_simple_operand(to_check[0]); simple_op)//first operand specifies only base
else if (auto simple_op = get_simple_operand(to_check[0]); simple_op) // first operand specifies only base
{
if (!is_positive_value(simple_op->operand_identifier))
{
add_diagnostic(diagnostic_op::error_A101_USING_base_val());
return false;
}
// simple operand is acceptable
}
else
assert(false);
//check other operands
if (to_check.size() == 2) //therefore there can be either address or one base register
{
auto simple_op = get_simple_operand(to_check[1]);
if (simple_op == nullptr)
{
add_diagnostic(diagnostic_op::error_A000_simple_op_expected(name_of_instruction));
return false;
}
// can also be address, maybe TO DO
return true;
if (!is_base_register(simple_op->operand_identifier) || !is_positive_value(simple_op->operand_identifier))
{
add_diagnostic(diagnostic_op::error_I020_format(name_of_instruction, true));
return false;
}
// empty operand
add_diagnostic(diagnostic_op::error_A104_USING_first_format(to_check[0]->operand_range));
return false;
}
else //all other parameters are base registers

for (size_t i = 1; i < to_check.size(); i++)
{
for (size_t i = 1; i < to_check.size(); i++)
{
auto simple_op = get_simple_operand(to_check[i]);
if (simple_op == nullptr)
{
add_diagnostic(diagnostic_op::error_A000_simple_op_expected(name_of_instruction));
return false;
}
if (!is_base_register(simple_op->operand_identifier))
{
add_diagnostic(diagnostic_op::error_A105_USING_base_register_val());
return false;
}
}
}*/
const auto& op = to_check[i];
if (!is_operand_simple(op))
{
add_diagnostic(diagnostic_op::error_A164_USING_mapping_format(op->operand_range));
return false;
}
}

return true;
}

Expand Down Expand Up @@ -916,30 +876,16 @@ drop::drop(const std::vector<label_types>& allowed_types, std::string_view name_
bool drop::check(
const std::vector<const asm_operand*>& to_check, const range&, const diagnostic_collector& add_diagnostic) const
{
// TODO: at this point the check is more or less redundant to the one performed in the process_DROP function
if (has_one_comma(to_check))
return true;
for (const auto& operand : to_check)
{
auto simple = get_simple_operand(operand);
if (simple == nullptr)
if (!is_operand_simple(operand))
{
add_diagnostic(diagnostic_op::error_A141_DROP_op_format(operand->operand_range));
return false;
}
if (!simple->is_default)
{
// base register must be specified
if (is_byte_value(simple->value))
continue;
}
else
{
// label must be specified
if (is_ord_symbol(simple->operand_identifier) || is_var_symbol(simple->operand_identifier))
continue;
}
add_diagnostic(diagnostic_op::error_A141_DROP_op_format(operand->operand_range));
return false;
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion parser_library/src/checking/diagnostic_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <vector>

#include "context/processing_context.h"
#include "context/source_context.h"
#include "diagnostic.h"
#include "protocol.h"

Expand Down
6 changes: 4 additions & 2 deletions parser_library/src/context/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ target_sources(parser_library PRIVATE
macro_param_data.cpp
macro_param_data.h
operation_code.h
processing_context.cpp
processing_context.h
sequence_symbol.cpp
sequence_symbol.h
source_context.cpp
source_context.h
source_snapshot.h
statement_cache.cpp
statement_cache.h
using.cpp
using.h
)

add_subdirectory(ordinary_assembly)
Expand Down
Loading

0 comments on commit f9dfd05

Please sign in to comment.