RomanYankovsky / DelphiAST

Abstract syntax tree builder for Delphi
Mozilla Public License 2.0
271 stars 116 forks source link

Should an empty begin/end block be classified as `ntEmptyStatement` ? #320

Open NickRing opened 2 years ago

NickRing commented 2 years ago

Hi,

Came across a piece of code that is like this:

if <expression> then
begin
end
else
begin
  // statements
end;

Yes, there is nothing in the initial begin/end group. The XML output is below. Since there is a type of ntEmptyStatement (used within Case statement - ntCaseSelector), I am just asking if ntEmptyStatement should be used in this kind of empty statement (not saying it is a bug, not saying it is a feature request... )

Cheers, Nick

      <IF line="5010" col="3">
        <EXPRESSION line="5010" col="6">
          <... snipped ... >
        </EXPRESSION>
        <THEN line="5010" col="65">
          <STATEMENTS begin_line="5011" begin_col="3" end_line="5013" end_col="3"/>
        </THEN>
        <ELSE line="5013" col="3">
          <STATEMENTS begin_line="5014" begin_col="3" end_line="5018" end_col="6">
bogdanpolak commented 2 years ago

@NickRing can you elaborate what kid of problem do you have with existing code, because personally for me this is hard to guess what do you expect. Do you want to have updated XML generator?