Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 956 Categories, Downloaded 50.246.208 Times

Parse::Nibbler 1.10

  Date Added: October 03, 2010  |  Visits: 1.000

Parse::Nibbler

Report Broken Link
Printer Friendly Version


Product Homepage
Download (91 downloads)



Parse::Nibbler is Perl module to parse huge files using grammars written in pure perl. Create a parser object using the ->new method. This method is provided by the Parse::Nibbler module and should not be overridden. The main functionality of the Parse::Nibbler module is the Register subroutine. This subroutine is used to define the rules of your grammar. The Register subroutine takes two parameters: A string and a code reference. The string is the name of the rule (i.e. the name of the subroutine/method) The code reference is a reference to the code to execute for this rule. The Register subroutine will take the code reference, wrap it up in another subroutine that acts as a closure, and then installs that code reference as a subroutine with the name matching the given string. The wrapper code (the closure) is the same for every rule. The wrapper code handles quantifiers, calls the rule, and decides what to do based on the rule passing or failing. A rule is a code reference with a given string name that have been passed to Register. Here is an example of a rule: Register ( Name, sub { my $p = shift; $p->AlternateValues( Jim, Scotty, Spock ); } ); The parser object will always be passed in as the first parameter to your rule. You must pass this into any further rules or any Parse::Nibbler methods. In the above example, the rule, "Name" is Registered. "Name" calls one of the builtin methods, AlternateValues, defined below. Once a rule is Registered, other rules can call it: Register ( MedicalDiagnosis, sub { my $p = shift; $p->AlternateValues("Hes", "Shes"); $p->ValueIs("dead"); $p->ValueIs(","); $p->Name; $p->ValueIs("!"); } ); This code registers a rule called "MedicalDiagnosis". It uses some builtin methods, but it also calls the rule just registered, "Name". Once a user defines a rule, they can use it in other rules by simply calling it as they would call a method. Rules registered with the Parse::Nibbler module can be called with quantifiers. Quantifiers are passed into the Rule when you call it in your grammar by passing in a string that matches the format described here. Quantifiers allow you to specify the quantity of rules present. Quantifiers also allow you to specify whether multiple rules have separators. Quantifiers are specified using the following string format: {quantifier} This indicates that there are zero or one Name rules expected: $p->Name({?}); This indicates that there are zero or more Name rules expected: $p->Name({*}); This indicates that there are one or more Name rules expected: $p->Name({+}); This indicates that there are exactly three Name rules expected: $p->Name({3}); This indicates there are 1 to 3 Name rules expected: $p->Name({1:3}); This indicates there are at least 2 Name rules expected: $p->Name({2:); Separators are specified using the following string format: /separator/ This indicates 1 or more Name rules, each separated by a comma: $p->Name({1:}/,/); It is the job of the Register function to make sure this additional functionality is provided transparently and automagically to you. If you call a rule with no quantifier and no separator, the rule will assume the quantifier is 1 and there is no separator. Additional Parse::Nibbler methods are provided to simplify rule definition and to provide smart, automatic error handling, etc. You grammars should only call other rules that you defined, or these methods explained below. (Note: these methods do not take quantifiers) ############### Method: ValueIs ############### Parameters: One parameter, required. A string containing the expected value. Example: $p->ValueIs( stringvalue ); Description: This method will look at the next lexical and determine if its value matches that of the stringvalue given as a parameter. If it does not match, an exception is raised and the rule fails. If the values do match, then the parser stores the lexical, and the rule continues. ####################### Method: AlternateValues ####################### Parameters: A list of string parameters, at least two values. Example: $p-AlternateValues( value1, value2 ); Description: This method behaves like the ValueIs method, except that it will recieve a list of allowed alternate expected values. The first match that succeeds causes the rule to pass and return. If no match occurs, then an exception is raised and the rule aborts. If a match does occur, the parser stores the lexical, and the rule continues. ############## Method: TypeIs ############## Parameters: One parameter, required. A string containing the expected type. Description: This method will look at the next lexical item, and determine if the lexical type matches the type given as a parameter. Valid type values depend on the Lexer that you use, but possible values may include "Identifier" and "Number", etc. Use this in a case where your rule requires an identifier type, for example, but it does not care what the name of the identifier is for the rule. If a match occurs, the parser stores the lexical and the rule continues. If a match does not occur, an exception is raised, and the rule aborts. ###################### Method: AlternateRules ###################### Parameters: A list of string parameters, at least two. Example: $p->AlternateRules( Rule1, Rule2 ); Description: You can describe rule alternation in your rule by calling this method. The method takes a list of strings whose string values match the names of the valid alternate rule names. In the above example, the McCoy rule is either a declaration of profession or a medical diagnosis. These are two rules that are defined in the same package. The AlternateRules method allows you to define multiple rules that may be valid at the same point in the text. If a rule in the parameter list succeeds, the AlternateRule method succeeds, and returns immediately. If no rule succeeds, an exception is thrown, and the rule aborts. This rule expects either a "DeclareProfession" rule or a "MedicalDiagnosis" rule to be present. Register ( McCoy, sub { my $p = shift; $p->AlternateRules( DeclareProfession, MedicalDiagnosis ); } ); You can specify quantifiers as part of the alternate rule strings. $p->AlternateRules( DeclareProfession({+}), MedicalDiagnosis ); The above example indicates that you can have one or more DeclareProfession rules OR ALTERNATELY you can have exactly one MedicalDiagnosis rule. EXPORT Register, used to register the rules in your grammar..

Requirements: No special requirements
Platforms: Linux
Keyword: Alternaterules Alternatevalues Declareprofession Huge Files If A List Of Medicaldiagnosis Name P- Perl Module Rule Rules String Valueis Written In
Users rating: 0/10

License: Freeware Size: 33.79 KB
USER REVIEWS
More Reviews or Write Review


PARSE::NIBBLER RELATED
Development Tools  -  Converting a list of equal length lists into XML 1.0
This module takes a list of equal length lists and converts it into XML. If the first sublist is a list of headings, these are used to form the element names of the rest of the data, or these can be defined in the function call. Root and "row"...
 
Miscellaneous  -  A List of Dictionaries 1.0
ThisĀ  class emulates a list of dictionary objects without the memory and pickle storage overhead which occurs when storing every item in the list as a dictionary.
 
Miscellaneous  -  Transposing a List of Lists 1.0
This script allows you to transpose a list of lists of different lengths.
 
Modules  -  Recent Love - A List of Recent Comments 0.5
Displays a list (typically, in your sidebar) of your visitors' recent comments. By default, shows the latest comment from each of the last five commented-on posts.You control: * how many recent comments to display * how many characters of the post...
20.48 KB  
Miscellaneous  -  Group a list into sequential n-tuples 1.0
Group a list into sequential n-tuples function returns a list of n-tuples from a single "flat" list.
 
Miscellaneous  -  A recursive function to get permutation of a list 1.2
A recursive function to get permutation of a list script allows you to make permutation on a list of objects. The script does not work on repeated items in the list.
 
Business  -  Imieniny 1.1.1(Superkaramba)
Imieniny reads a list of names and the dates on which those saints are commemorated in Poland. The "name-day", i.e. the day on which a saint bearing a persons name is commemorated, is important in Poland, and is celebrated like a birthday. The...
7.17 KB  
Libraries  -  Acme::Hyperindex 0.12
Acme::Hyperindex is a Perl module to look deep into structures using a list of indexes. SYNOPSIS use strict; use Acme::Hyperindex; my @struct = ( { j_psi => [qw( eta_prime phi kaon )] }, { j_psi => [qw( selectron down tau_sneutrino )] },...
4.1 KB  
Database Tools  -  SQL Parsing 1.0
SQL Parsing is a simple class that can parse text files with a list of MySQL query statements to be executed.SQL Parsing splits the file lines, skips comment lines and gathers all consecutive lines until the one ends with semi-colon to get the...
10 KB  
Networking  -  List of references 1.0
Generates a list of links used in a post. This can be used to create a list of references like those in scientific publications. Add [lor] at the end of your post (or wherever you want the list of references) and add a title attribute to all links...
10 KB  
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB  
Libraries  -  wolfSSL 4.0.0
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
3.88 MB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB