Title: Advanced OO and Parsing with Perl Length: 3 days (12 x 90 minute sessions) Presenter: Dr Damian Conway School of Computer Science and Software Engineering, Monash University, Clayton, 3168 AUSTRALIA mailto:damian@conway.org http://www.csse.monash.edu.au/~damian phone: +61-3-9905-5184 fax: +61-3-9905-5146 Target audience: Perl programmers who are familiar with simple regular expressions, the use of modules, and Perl's basic OO mechanism (i.e. blessing hashes into packages). What participants will learn: This tutorial will show you how to build on the basic object-oriented Perl techniques you already know and unlock more of the power of Perl's OO capabilities. The final day will show you how to use a range of standard Perl features and several CPAN modules (in particular, Parse::RecDescent) to decipher and process a variety of complex data and command formats using OO parsers. You will learn: * how to use pseudo-hashes and the standard fields.pm and base.pm modules; * how (and when) to bless arrays and scalars; * three different ways to implement data hiding for Perl objects (including the Tie::SecureHash module); * how Perl implements inheritance and polymorphism (and how you can change the rules of either); * how to simulate scalars, arrays, hashes, and typeglobs using ties; * the features (and traps) of operator overloading in Perl; * two easy ways to build complete classes (semi-)automatically; * how to do design-by-contract programming in OO Perl (using the Class::Contract module); * two ways to do generic programming in Perl; * how to use multiple dispatch (an advanced form of polymorphism ) to implement event-driven class hierarchies for simulation and GUI applications. * how to design and build parsers to process Apache configuration files and log data, * how to process structured expressions (e.g. search engine queries), * how to balance nested brackets and match delimiters without a regular expression, * how to fold, spindle and mutilate the comments in a C program, * how to dissect C++ type declarations with a self-adapting parser, * how to allow embedded Perl code in your own data format or command language, * how convert natural language queries into SQL. * how to pull pesky unmatched

tags from HTML; * how to deal with ambiguous data by parsing it in multiple universes simultaneously; * how to get Parse::RecDescent to write most of your grammar for you; * how to parse modular text (e.g. with source with #includes in it); * how to pre-filter your source code by tricking Perl into (nearly) parsing Perl; * how to debug Parse::RecDescent parsers efficiently and how to improve the efficiency of your Parse::RecDescent grammars; Tutorial outline: Day 1: Advanced OO Perl * Review of Perl OO basics - packages, references, blessing - the three rules * Non-hash-based objects - arrays as objects - scalars as objects * Pseudo-hashes - what they are, how to use them as objects - the fields.pm module - compile-time type checking * Automating class construction and DBC programming - Class::Struct - design-by-contract with Class::Contract * Inheritance and Polymorphism - revision of concepts - how they work in Perl - when and how to use them - @ISA, isa(), can(), SUPER - tricks with inherited constructors and destructors - attribute collisions - inheritance and pseudohashes: the base.pm module Day 2: More Advanced OO Perl * Encapsulation - the pros and cons of data hiding - encapsulation via closures - encapsulation via scalars - encapsulation via the Tie::SecureHash module * Ties - how the mechanism works - reimplementing scalars and hashes * Operator overloading - overview and limitations of mechanism - overloading operations, conversions, and constants - problems with references * Generic programming - Why you don't need it in Perl - How to do it anyway - Examples: generic lists; generic trees * Multiple dispatch - when regular polymorphism isn't enough - Class::Multimethods - method overloading Day 3: OO Parsing * A brief review of parsing - grammars, rules, recursive descent, etc. - top-down vs bottom-up approaches - Text::Balanced, Parse::Yapp, perl-byacc, Parse::RecDescent * Simple parsing - Parsing delimited text, parsing Perl subsets - Parsing Apache log files - optional subrules, list parsing - run-time parser generation * Parsing code - parsing C and C++ - stateful grammars * Parsing natural language - generating SQL queries for natural language input * Miscellaneous advanced features of Text::Balanced - precompiling delimiter extractions - extracting tagged text - extracting Perl variables - extracting mixed components * Miscellaneous extra features of Parse::RecDescent - Named items (the %item array) - Debugging grammars: , , , and - Context information: $thisline, $lastoffset, @itempos, etc. - Extreme prejudice: the directive * Non-deterministic parsing - tracking "goodness-of-match" - the and directives * Automatic grammar generation - autoactions - autostubbing - autotrees - the , , and directives * Generic parsers - the directive - subrule arguments: @arg and %arg * Handling distributed text - processing file inclusions recursively - processing file inclusions by input modification - other uses of input modification * (Nearly) parsing Perl - parsing with Text::Balanced on Occam's Razor - source code filtering * Metagrammars - building a grammar for parsing grammars - beat poetry and postmodern literature Presenter biography: Damian Conway holds a Ph.D. in Computer Science and is a Senior Research Fellow with the School of Computer Science and Software Engineering at Monash University, Melbourne, Australia. He is the author of numerous well-known modules including: Class::Contract, Text::Autoformat, Parse::RecDescent, Text::Balanced, Lingua::EN::Inflect, Class::Multimethods, Switch, Quantum::Superpositions, NEXT, Filter::Simple, Attribute::Handlers, Inline::Files, and Coy (all available from your local CPAN mirror). Damian was the winner of the 1998, 1999, and 2000 Larry Wall Awards for Practical Utility. He is a member of the technical committee for The Perl Conference, a writer for The Perl Journal, author of the book "Object Oriented Perl", and a member of the Perl 6 design team. In 2001 Damian received the first "YAS Perl Development Grant" and spent 18 months working on projects for the betterment of the international Perl community.