Perl5 AST

Discussion in 'Perl Misc' started by romerun@gmail.com, Aug 19, 2006.

  1. Guest

    Hi All,

    I have been wondering for a long time if there exists any abstract
    syntax tree parser for Perl5 or any attempt to create it. In the CPAN
    there are some B:: modules that can give some kinds of Perl5 OP tree,
    which loses some important information to do some static checking such
    as type checking via type annotation, reference leaking, unreachable
    code, etc. Any suggest on where should I look ?

    -thanks
    kem
    , Aug 19, 2006
    #1
    1. Advertising

  2. Ben Morrow Guest

    Quoth :
    > Hi All,
    >
    > I have been wondering for a long time if there exists any abstract
    > syntax tree parser for Perl5 or any attempt to create it. In the CPAN
    > there are some B:: modules that can give some kinds of Perl5 OP tree,
    > which loses some important information to do some static checking such
    > as type checking via type annotation, reference leaking, unreachable
    > code, etc. Any suggest on where should I look ?


    You could try looking at PPI, though that's more of a parser than an AST
    builder. perl doesn't really have any intermadiate steps between parsing
    the source and building the OP tree, so all the information that's kept
    is available there; OTOH you may find something useful in the MAD stuff
    that's gone into blead recently as the beginning of a p5-p6 converter.
    IIRC it comes with a lot of caveats, though, like 'this doesn't really
    work yet' and 'perl built with this option is not compatible with perl
    built without'.

    Ben

    --
    "If a book is worth reading when you are six, *
    it is worth reading when you are sixty." [C.S.Lewis]
    Ben Morrow, Aug 19, 2006
    #2
    1. Advertising

  3. Uri Guttman Guest

    >>>>> "r" == romerun <> writes:

    r> I have been wondering for a long time if there exists any abstract
    r> syntax tree parser for Perl5 or any attempt to create it. In the CPAN
    r> there are some B:: modules that can give some kinds of Perl5 OP tree,
    r> which loses some important information to do some static checking such
    r> as type checking via type annotation, reference leaking, unreachable
    r> code, etc. Any suggest on where should I look ?

    perl 6 will be able to do that and partly already. larry wall is working
    on that and also the PPI modules can do a decent text analysis of perl5
    code.

    uri

    --
    Uri Guttman ------ -------- http://www.stemsystems.com
    --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
    Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
    Uri Guttman, Aug 19, 2006
    #3
  4. >>>>> "romerun" == romerun <> writes:

    romerun> I have been wondering for a long time if there exists any abstract
    romerun> syntax tree parser for Perl5 or any attempt to create it. In the CPAN
    romerun> there are some B:: modules that can give some kinds of Perl5 OP tree,
    romerun> which loses some important information to do some static checking such
    romerun> as type checking via type annotation, reference leaking, unreachable
    romerun> code, etc. Any suggest on where should I look ?

    You *are* aware that it's impossible to lex perl without actually being
    prepared to execute Perl code, right?

    Perl cannot be "statically analyzed".

    .... http://www.perlmonks.org/index.pl?node=44722

    And this is also true for Perl6. As long as / has two meanings (divide and
    regex start, which hasn't changed for perl6), you need to know what state
    you're in when you hit the char to know if it's standalone or the beginning of
    something. And that can affect the entire rest of the program.

    print "Just another Perl hacker,"; # the original

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <> <URL:http://www.stonehenge.com/merlyn/>
    Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
    See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

    --
    Posted via a free Usenet account from http://www.teranews.com
    Randal L. Schwartz, Aug 19, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    18
    Views:
    602
    Michael Wojcik
    Aug 29, 2005
  2. John Andrews

    RegExps: are they full Perl5?

    John Andrews, Dec 2, 2003, in forum: Ruby
    Replies:
    1
    Views:
    100
    Robert Klemme
    Dec 2, 2003
  3. Simon Strandgaard

    [ann] regexp-engine-0.8, perl5 + some perl6

    Simon Strandgaard, Apr 22, 2004, in forum: Ruby
    Replies:
    5
    Views:
    135
    Simon Strandgaard
    Apr 22, 2004
  4. Kenjis Kaan

    using Perl5 MD5 module in Perl4?

    Kenjis Kaan, Aug 2, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    109
    Kenjis Kaan
    Aug 5, 2003
  5. dj
    Replies:
    4
    Views:
    95
Loading...

Share This Page