RomanYankovsky / DelphiAST

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

Variant section in a record is not recorded #230

Open JBontes opened 6 years ago

JBontes commented 6 years ago

The following code:

type
  a = record
   b : integer;
   case isEnabled : boolean of
    true : (c: Integer);
    false : (d: word);
  end;

Work in progress
This is quite a complicated fix.

There are two options:
A: reuse the case statement elements from the normal case statement.
This is a bit awkward if you want to process the data, because the syntax and semantics of both case statements are quite different. I would not favor this option.

B: create new building blocks, whilst still following the logic of the normal case statement as much as is appropriate.
This will create quite a few new TSyntaxNodeTypes, but is the cleanest and simplest option. It will not break any existing code, because currently the variant record just plain does not work.

The fix, see: https://github.com/RomanYankovsky/DelphiAST/pull/231/commits/9226c1fffbfc4d8fef1d40dfcf43412cff5240b0