Pegex::Input(3pm)
π Pegex::Input β the Pegex Parser Input Abstraction π
okay bestie, so this is Pegex::Input, a little module from the User Contributed Perl Documentation fam. think of it as the β¨vibe translatorβ¨ between whatever messy thing you're feeding your parser and the parser itself. she's giving input abstraction, she's giving uniform interface, she's giving main character energy for real π
π SYNOPSIS π
use Pegex;
use Pegex::Input;
my $ast = pegex($foo_grammar)->parse(Pegex::Input->new(string => $foo_input));
like. look at her. one line and your parser is fed. iconic. π
π¦ DESCRIPTION π¦
so Pegex::Parser is the one doing the actual parsing, right? but the input it parses? that can be so many things, bestie:
- a plain ol' string
- a reference to a string
- a file path
- an open file handle
and that's a lot of different shapes for one parser to deal with π so Pegex::Input steps in as an abstraction over any type of input. she hands the parser one clean, uniform interface so nobody has to think about it. no cap. π
π§ USAGE π§
you call new() with two arguments, and the first one tells her what kind of input this is:
Pegex::Input->new(file => 'file.txt')
and here are all the input types you can pass, fr fr:
stringβ the input is a string. classic. simple. slay. β¨stringrefβ the input is a string reference. lowkey this one's for when your string is really, really long and you don't wanna be copying it around. she gets it. π«Άfileβ the input is a file path name that gets opened and read. πhandleβ the input comes from an already opened file handle, just sitting there waiting to be read. π
π AUTHOR π
Ingy dΓΆt Net <ingy@cpan.org>
(absolute legend, we love her π)
πΈ COPYRIGHT AND LICENSE πΈ
Copyright 2010-2020. Ingy dΓΆt Net.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <http://www.perl.com/perl/misc/Artistic.html>
and that's the whole page, bestie!! this one came from perl v5.36.0, dated 2022-11-19, filed under Pegex::Input(3pm) β go forth and feed your parser whatever you want, she's got you π
β¨ππ¦
π¦ where this page comes from
- debian bookworm: libpegex-perl 0.75-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libpegex-perl 0.75-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libpegex-perl 0.75-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libpegex-perl 0.75-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libpegex-perl 0.75-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms