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

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

Serving Software Downloads in 976 Categories, Downloaded 29.547.647 Times

Parse::Nibbler 1.10

  Date Added: October 03, 2010  |  Visits: 639

Parse::Nibbler

Report Broken Link
Printer Friendly Version


Product Homepage
Download (73 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.
 
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  
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.
 
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  
Games  -  Christmas Gift Mania - A list of Gifts to Discover and Match them Free Game 1.1
Christmas Gift Mania - A list of Gifts to Discover and Match them Free Game It's a perfect game for the whole family!!! Seasons come and go. Christmas is the best time to spend with you family. We Wish You A Very Happy...
15.7 MB  
Web Authoring  -  vhooz Build 1027
vhooz is a software that verifies if a list of domain names are available or not. It's a good tool if you want verify many domain names. What's new in this version: * Internal bugs fixed * new version of internal (cc)TLDs manager * You can see...
2.5 MB  
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
Programming  -  FLEX-db Digital Asset Manager 3.0.9
FLEX-db - an enterprise Digital Asset Manager (DAM). It ingests and links metadata with files, creates thumbnails, and processes files using business rules. FLEX-db has a JSP client, Java app server for file input and output and an EJB metadata...
21.57 MB  
Programming  -  Libicom 0.9.0
The libicom library is a character based dynamicly linked library for Linux. It is used to remotely control the Icom IC-R8500 wide band receiver via an RS232 link. All call and return parameters to the control functions are character string based....
20.48 KB  
Programming  -  dotdesktop 0.3
Dotdesktop library provides ability to parse desktop entry file and access the information in a convenient way. Desktop entry file format is defined by freedesktop.org, it is used to describe information about an application such as the name and...
327.68 KB  
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  -  libyasl 0.2
Libyasl is a C++ class library to easily realize TCP/UDP/Multicast clientsand servers in IPv4 and IPv6 environments under GNU/Linux systems.
143.36 KB  
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  
Libraries  -  App::SimpleScan::Substitution::Line 2.02
App::SimpleScan::Substitution::Line is a line with optional fixed variable values. SYNOPSIS my $line = App::SimpleScan::Substitution::Line->new(" this "); # Use only this value when substituting " ". $line->fix(substituite =>...
54.27 KB