Abstract syntax tree builder for Delphi
Pascal PHP
Switch branches/tags
Nothing to show
Clone or download
RomanYankovsky bugfix: unit list in project parser must use case-insensitive compare… (
#265)

* bugfix: unit list in project parser must use case-insensitive compare (#264)

* binary serializer

* deserializer

* bugs fixed

* fixed warnings

also: removed unused unit

* moved to correct place

* unmessing stuff

* project indexer wip

* FPC compatibility

* wip

* support for search paths

* include file support

* extended $IF support

Lexer can now handle $IF statements in form

{$IF CompilerVersion operator value}

* extended $IF support

Lexer can now handle $IF statements in form

{$IF CompilerVersion operator value}

This covers most frequent use-cases of CompilerVersion.

* $IF RTLVersion

Added support for 

{$IF RTLVersion operator value}

* improved include support

* better UTF8 and conditional define handling

* don't $I files when in skipped $IFDEF/$IF

If $INCLUDE/$I is found while in the $IF(N)DEF/$IF part which is being skipped (undefined conditional etc), include is ignored.

This speeds up parsing (especially if include file has to be found in a long search path) and makes the parser more compatible with Delphi which ignores $INCLUDE statements inside skipped blocks.

* handles {$I *.inc}

* added support for 'unit in path' syntax

* output information generated

+ better search path handling
+ OnUnitParsed handler with abort support
+ UseDefinesDefinedByCompiler changed into Options

* some refactoring

* some refactoring

* bug fixes, IncludeFiles[]

* bug fixes

! fixed memory leak in destroy
! fixed include file caching

* implemented NotFoundUnits

+ refactored and simplified FindFile

* simplified code

* added Problems

* does not belong to repo

* wrong unit name was passed to OnUnitParsed

* compiles with Tokyo

* added TProjectIndexer.TParsedUnits.Find

* not needed anymore

* Added support for indexing package files (.dpk)

* Revert "added support for indexing packages (.dpk)"

This reverts commit e32cffd.

* unit list is case insensitive

* Change directory structure
Latest commit 21ac6e3 May 13, 2018

README.md

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;

interface

uses
  Unit2;

function Sum(A, B: Integer): Integer;

implementation

function Sum(A, B: Integer): Integer;
begin
  Result := A + B;
end;

end.

Sample outcome

<UNIT line="1" col="1" name="Unit1">
  <INTERFACE begin_line="3" begin_col="1" end_line="10" end_col="1">
    <USES begin_line="5" begin_col="1" end_line="8" end_col="1">
      <UNIT line="6" col="3" name="Unit2"/>
    </USES>
    <METHOD begin_line="8" begin_col="1" end_line="10" end_col="1" kind="function" name="Sum">
      <PARAMETERS line="8" col="13">
        <PARAMETER line="8" col="14">
          <NAME line="8" col="14" value="A"/>
          <TYPE line="8" col="20" name="Integer"/>
        </PARAMETER>
        <PARAMETER line="8" col="17">
          <NAME line="8" col="17" value="B"/>
          <TYPE line="8" col="20" name="Integer"/>
        </PARAMETER>
      </PARAMETERS>
      <RETURNTYPE line="8" col="30">
        <TYPE line="8" col="30" name="Integer"/>
      </RETURNTYPE>
    </METHOD>
  </INTERFACE>
  <IMPLEMENTATION begin_line="10" begin_col="1" end_line="17" end_col="1">
    <METHOD begin_line="12" begin_col="1" end_line="17" end_col="1" kind="function" name="Sum">
      <PARAMETERS line="12" col="13">
        <PARAMETER line="12" col="14">
          <NAME line="12" col="14" value="A"/>
          <TYPE line="12" col="20" name="Integer"/>
        </PARAMETER>
        <PARAMETER line="12" col="17">
          <NAME line="12" col="17" value="B"/>
          <TYPE line="12" col="20" name="Integer"/>
        </PARAMETER>
      </PARAMETERS>
      <RETURNTYPE line="12" col="30">
        <TYPE line="12" col="30" name="Integer"/>
      </RETURNTYPE>
      <STATEMENTS begin_line="13" begin_col="1" end_line="15" end_col="4">
        <ASSIGN line="14" col="3">
          <LHS line="14" col="3">
            <IDENTIFIER line="14" col="3" name="Result"/>
          </LHS>
          <RHS line="14" col="13">
            <EXPRESSION line="14" col="13">
              <ADD line="14" col="15">
                <IDENTIFIER line="14" col="13" name="A"/>
                <IDENTIFIER line="14" col="17" name="B"/>
              </ADD>
            </EXPRESSION>
          </RHS>
        </ASSIGN>
      </STATEMENTS>
    </METHOD>
  </IMPLEMENTATION>
</UNIT>

Copyright

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

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

See LICENSE for details.