===
Declaration hints
===

procedure a; cdecl; forward;
procedure a; pascal; forward;
procedure a; stdcall; forward;
procedure a; register; forward;
procedure a; external b;
procedure a; cdecl; external b;
procedure a; external name b;
procedure a; external index b;
procedure a; external b name c;
procedure a; public name b; forward;
procedure a; inline; forward;

var
  a: b; cvar; external c;

type
  a = class
    procedure b; message c;
    procedure b; virtual; abstract;
    procedure b; override;
    procedure b; stdcall;
    property b[i: integer]: c read getb; default;
  end;

---

(root
  (declProc (kProcedure) (identifier) (procAttribute (kCdecl)) (kForward))
  (declProc (kProcedure) (identifier) (procAttribute (kPascal)) (kForward))
  (declProc (kProcedure) (identifier) (procAttribute (kStdcall)) (kForward))
  (declProc (kProcedure) (identifier) (procAttribute (kRegister)) (kForward))
  (declProc (kProcedure) (identifier) (procExternal (kExternal) (identifier)))
  (declProc (kProcedure) (identifier) (procAttribute (kCdecl)) (procExternal (kExternal) (identifier)))
  (declProc (kProcedure) (identifier) (procExternal (kExternal) (kName) (identifier)))
  (declProc (kProcedure) (identifier) (procExternal (kExternal) (kIndex) (identifier)))
  (declProc (kProcedure) (identifier) (procExternal (kExternal) (identifier) (kName) (identifier)))
  (declProc (kProcedure) (identifier) (procAttribute (kPublic) (kName) (identifier)) (kForward))
  (declProc (kProcedure) (identifier) (procAttribute (kInline)) (kForward))
  (declVars (kVar)
    (declVar
      (identifier)
      (type (typeref (identifier)))
      (procAttribute (kCvar))
      (procExternal (kExternal) (identifier))))
  (declTypes (kType)
    (declType (identifier) (kEq)
      (declClass (kClass)
        (declProc (kProcedure) (identifier) (procAttribute (kMessage) (identifier)))
        (declProc (kProcedure) (identifier) (procAttribute (kVirtual)) (procAttribute (kAbstract)))
        (declProc (kProcedure) (identifier) (procAttribute (kOverride)))
        (declProc (kProcedure) (identifier) (procAttribute (kStdcall)))
        (declProp (kProperty)
          (identifier)
          (declPropArgs
            (declArg
              (identifier)
              (type (typeref (identifier)))))
          (type (typeref (identifier)))
          (kRead) (identifier)
          (procAttribute (kDefault)))
        (kEnd)))))


===
FPC-style declaration hints
===

procedure a; [public; alias: b; cdecl]; forward;

---

(root
  (declProc (kProcedure) (identifier)
    (procAttribute (kPublic))
    (procAttribute (kAlias) (identifier))
    (procAttribute (kCdecl))
    (kForward)))


===
Extended RTTI
===

type
  [TMyAttribute]
  TTestClass = class
    [TMyAttribute('Test')]
    property Test: LongInt read fTest;
    [TMyAttribute()]
    [TMyAttribute(1), TMyAttribute(2)]
    procedure a;
  end;

  [TMyAttribute(1234)]
  [TMy('Hello World')]
  TTestEnum = (teOne, teTwo);

  [TMyAttribute(IInterface), TMy(42)]
  TLongInt = type LongInt;

  TMyIntf = interface
    ['eff222cf-7d8d-481f-9fc4-d60e128983ab']
    [TMyAttribute(1234)]
    procedure foo;
  end;

var
  [TMyAttribute]
  a: integer;

[TMyAttribute]
procedure foo;
begin
end;

---

(root
  (declTypes (kType)
    (declType
      (rttiAttributes (identifier))
      (identifier) (kEq) (declClass (kClass)
        (declProp
          (rttiAttributes
            (exprCall (identifier) (exprArgs (literalString))))
          (kProperty)
          (identifier)
          (type (typeref (identifier)))
          (kRead)
          (identifier))
        (declProc
          (rttiAttributes
            (exprCall (identifier))
            (exprCall (identifier) (exprArgs (literalNumber)))
            (exprCall (identifier) (exprArgs (literalNumber))))
          (kProcedure)
          (identifier))
        (kEnd)))
    (declType
      (rttiAttributes
        (exprCall (identifier) (exprArgs (literalNumber)))
        (exprCall (identifier) (exprArgs (literalString))))
      (identifier)
      (kEq)
      (type
        (declEnum
          (declEnumValue (identifier))
          (declEnumValue (identifier)))))
    (declType
      (rttiAttributes
        (exprCall (identifier) (exprArgs (identifier)))
        (exprCall (identifier) (exprArgs (literalNumber))))
      (identifier)
      (kEq)
      (kType)
      (type (typeref (identifier))))
    (declType (identifier) (kEq)
      (declIntf
        (kInterface)
        (guid (literalString))
        (declProc
          (rttiAttributes
            (exprCall (identifier) (exprArgs (literalNumber))))
          (kProcedure)
          (identifier))
        (kEnd))))
  (declVars
    (kVar)
    (declVar
      (rttiAttributes (identifier))
      (identifier)
      (type (typeref (identifier)))))
  (defProc
    (declProc
      (rttiAttributes (identifier))
      (kProcedure)
      (identifier))
    (block
      (kBegin)
      (kEnd))))

