Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

422 Commits

Repository files navigation

Abstract Syntax Tree Builder for Delphi

With DelphiAST you can take real Delphi code and get an abstract syntax tree. One unit at time and without a symbol table though.

FreePascal and Lazarus compatible.

Sample input

unit Unit1;
interfaceuses
Unit2;
functionSum(A, B: Integer): Integer;
implementationfunctionSum(A, B: Integer): Integer;
begin
Result := A + B;
end;
end.

Sample outcome

<UNITline="1"col="1"name="Unit1">
<INTERFACEbegin_line="3"begin_col="1"end_line="10"end_col="1">
<USESbegin_line="5"begin_col="1"end_line="8"end_col="1">
<UNITline="6"col="3"name="Unit2"/>
</USES>
<METHODbegin_line="8"begin_col="1"end_line="10"end_col="1"kind="function"name="Sum">
<PARAMETERSline="8"col="13">
<PARAMETERline="8"col="14">
<NAMEline="8"col="14"value="A"/>
<TYPEline="8"col="20"name="Integer"/>
</PARAMETER>
<PARAMETERline="8"col="17">
<NAMEline="8"col="17"value="B"/>
<TYPEline="8"col="20"name="Integer"/>
</PARAMETER>
</PARAMETERS>
<RETURNTYPEline="8"col="30">
<TYPEline="8"col="30"name="Integer"/>
</RETURNTYPE>
</METHOD>
</INTERFACE>
<IMPLEMENTATIONbegin_line="10"begin_col="1"end_line="17"end_col="1">
<METHODbegin_line="12"begin_col="1"end_line="17"end_col="1"kind="function"name="Sum">
<PARAMETERSline="12"col="13">
<PARAMETERline="12"col="14">
<NAMEline="12"col="14"value="A"/>
<TYPEline="12"col="20"name="Integer"/>
</PARAMETER>
<PARAMETERline="12"col="17">
<NAMEline="12"col="17"value="B"/>
<TYPEline="12"col="20"name="Integer"/>
</PARAMETER>
</PARAMETERS>
<RETURNTYPEline="12"col="30">
<TYPEline="12"col="30"name="Integer"/>
</RETURNTYPE>
<STATEMENTSbegin_line="13"begin_col="1"end_line="15"end_col="4">
<ASSIGNline="14"col="3">
<LHSline="14"col="3">
<IDENTIFIERline="14"col="3"name="Result"/>
</LHS>
<RHSline="14"col="13">
<EXPRESSIONline="14"col="13">
<ADDline="14"col="15">
<IDENTIFIERline="14"col="13"name="A"/>
<IDENTIFIERline="14"col="17"name="B"/>
</ADD>
</EXPRESSION>
</RHS>
</ASSIGN>
</STATEMENTS>
</METHOD>
</IMPLEMENTATION>
</UNIT>

Copyright

Copyright (c) 2014-2020 Roman Yankovsky (roman@yankovsky.me) et al

DelphiAST is released under the Mozilla Public License, v. 2.0

See LICENSE for details.

About

Abstract syntax tree builder for Delphi

Topics

Resources

Stars

296 stars

Watchers

53 watching

Forks

Releases

Packages

Used by

Contributors

Languages