Pegex::Input(3pm)

πŸ“¦
version 0.75 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 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