The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Parse::Nibbler - Parsing HUGE files a little bit at a time.

SYNOPSIS

        package VerilogGrammar;


        my $reg = \&Parse::Nibbler::Register;

        # SourceText := description(*)
        package SourceText;

        sub Rule
        {
                Description::Rule($_[0]);
        }

        &$reg;  


        # put the rest of your rules here....

        package main;

        my $parser = VerilogGrammar->new('short.v');

        SourceText::Rule($parser);

DESCRIPTION

This module is a simple, generic parser designed from the beginning to parse extremely large files.

The parser only pulls in a section of the file at a time, (the amount pulled in is definable on each parser object.)

The module only has three methods for actual parsing: Eat See EatIfSee

All three methods have the same parameter definition.

The first parameter is a string which is used to create a pattern. The pattern is \G . $object->{prefix_string} . $param1; This pattern is used to perform a m/$pattern/mgc on the file.

The \G will start the pattern matching where it left off after the last regular expression.

The prefix attribute is defaulted to \s* so it will skip all leading whitespace in front of whatever pattern you're looking for.

The remaining parameters can be any quantity, but they return any value that would correspond to $1, $2, $3, due to parenthesis in your pattern. If you don't want to capture anything, don't put parens in your code, and don't pass in extra parameters.

The return value is true if a match is found, false otherwise.

See t/VerilogGrammar for a working example of a grammar.

EXPORT

None.

AUTHOR

# Copyright (c) 2001 Greg London. All rights reserved. # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself.

contact the author via http://www.greglondon.com

SEE ALSO