Ingy döt Net > Pegex-0.20 > Pegex::Input

Download:
Pegex-0.20.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Source   Latest Release: Pegex-0.21

SYNOPSIS ^

    use Pegex;
    use Pegex::Input;
    my $ast = pegex(Pegex::Input->new(file => 'foo-grammar-file.pgx'))
        ->parse(Pegex::Input->new(string => $foo_input));

DESCRIPTION ^

Pegex::Parser parses input. The input can be a string, a string reference, a file path, or an open file handle. Pegex::Input is an abstraction over any type of input. It provides a uniform inteface to the parser.

It also give the end user total control, when it is needed. In the rare case when you need to have Pegex parse a string that happens to be a filename, you'll need to use a Pegex::Input object.

USAGE ^

You call new() with two arguments, where the first argument is the input type:

    Pegex::Input->new(file => 'file.txt')

The following input types are available:

string

Input is a string.

stringref

Input is a string reference. This may be desirable for really long strings.

file

Input is a file path name to be opened and read.

handle

Input is from a opened file handle, to be read.

syntax highlighting: