blended-modeling / eatxt

Eclipse Public License 2.0
1 stars 1 forks source link

Empty elements are not allowed #19

Closed joerg-holtmann closed 2 years ago

joerg-holtmann commented 2 years ago

Empty elements are not allowed, even if all sub-elements are defined to be optional in the grammar (e.g., empty EAPackage).

Wilson008 commented 2 years ago

Analysis: Because we use a whitespace-aware solution to implement a python-like style in our DSL, however then the indentations became more sensitive and important, i.e. we use indentation (here, i.e. BEGINand END) to identify the hierarchy of code. This is the context of this issue. The reason for this issue is that when we don't give any element to a data instance structure (e.g. EAPackage), it means the line (EAPackage) will have the same (or less) indentation as the next line. But a deeper indentation is needed to be identified as a BEGIN, so it would occur error due to BEGIN being missing. That's what we could see in the problem window.

Wilson008 commented 2 years ago

Solution: Actually, there are two thinking to solve this issue:

  1. when the line (which a data structure starts) has a deeper or same indentation with the next line, we add a BEGIN and END behind the line.
  2. when all the elements are optional in a data structure, then we can simply make the BEGIN and END optional.

Considering the feasibility, I choose the second way to fix the issue. The key code could be seen the method allowEmptyElement in the post-processing plugin.

Wilson008 commented 2 years ago

Results: image