The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

PPI::Lexer - The PPI Lexer

SYNOPSIS

  use PPI;
  
  # Create a new Lexer
  my $Lexer = PPI::Lexer->new;
  
  # Build a PPI::Document object from a Token stream
  my $Tokenizer = PPI::Tokenizer->load( 'My/Module.pm' );
  my $Document = $Lexer->lex_tokenizer( $Tokenizer );
  
  # Build a PPI::Document object for some raw source
  my $source = File::Slurp->read_file( 'My/Module.pm' );
  $Document = $Lexer->lex_source( $source );
  
  # Build a PPI::Document object for a particular file name
  $Document = $Lexer->lex_file( 'My/Module.pm' );

DESCRIPTION

The is the PPI Lexer. In the larger scheme of things, it's job is to take token streams, in a variety of forms, and "lex" them into nested structures,

Pretty much everything in this module happens behind the scenes at this point. In fact, the only reason you need to instantiate the lexer is so that it doesn't need to use any global variables to hold state data during the lexing process.

All methods do a one-shot "lex this and give me a PPI::Document object".

METHODS

new

The new constructor creates a new PPI::Lexer object. The object itself is merely used to hold various buffers and state data during the lexing process, and holds no significant data between -E<GT>lex_xxxxx calls.

Returns a new PPI::Lexer object.

lex_file $filename

The lex_file method takes a filename as argument. It then loads the file, creates a PPI::Tokenizer for the content and lexes the token stream produced by the tokenizer. Basically, a sort of all-in-one method for getting a PPI::Document object from a file name.

Returns a PPI::Document object, or undef on error.

lex_source $string

The lex_source method takes a normal scalar string as argument. It creates a PPI::Tokenizer object for the string, and then lexes the resulting token stream.

Returns a PPI::Document object, or undef on error.

lex_tokenizer $Tokenizer

The lex_tokenizer takes as argument a PPI::Tokenizer object. It lexes the token stream from the tokenizer into a PPI::Document object.

Returns a PPI::Document object, or undef on error.

TO DO

- Add optional support for some of the more common soure filters

SUPPORT

Bugs should be reported via the CPAN bug tracker at

  http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PPI

For other issues, contact the author

AUTHOR

        Adam Kennedy ( maintainer )
        cpan@ali.as
        http://ali.as/

SEE ALSO

PPI, PPI::Manual

COPYRIGHT

Copyright 2004 Adam Kennedy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 66:

Unknown E content in E<GT>