NAME
SYNOPSISuse DFA::Command; $stateMachine = new DFA::Command('Name of first event');
# Or:
#$stateMachine = DFA::Command -> new('Name of first event');
$stateMachine -> load('Name of STT file');
$stateMachine -> dump() if ($YouAreDebugging);
$stateMachine -> process('Name of a event file');
DESCRIPTION
This module reads a state transition table and then reads a data file looking for patterns as defined by regular expressions in the state transition table. When a transition is detected, a sub is called.
This module reads a state transition table and generates a Perl
script which uses the module These 2 modules are installed together. The name
INSTALLATIONYou install perl Makefile.PL make make test make install If you want to install a private copy of perl Makefile.PL LIB=~/perl or perl Makefile.PL LIB=C:/Perl/Site/Lib If, like me, you don't have permission to write man pages into unix system directories, use: make pure_install instead of make install. This option is secreted in the middle of p 414 of the second edition of the dromedary book. FEATURESWhen input is recognised, and an action function is about to be called,
Just after an action function is called, the names of those events expected
next are saved by TEST SCRIPTSThis package contains 3 sets of test files:
Each set of test files contains:
These scripts are all in a subdirectory called test. They are not in a subdirectory called t because the test harness does not provide for scripts to be run which generate scripts to be run. CONFIGURATION OPTIONSchomp. Chomp each input line before processing it. Default: True commentPrefix. Ignore any input lines which start with this character. If trimLeading is false, and a line starts with whitespace followed by this character, that line will still be ignored. Default: '#' ignoreBlankLines. If true, ignore input lines which are blank after any chomping. Default: True trimLeading. If true, trim leading whitespace from each input line before processing it. Default: True trimTrailing. If true, trim trailing whitespace from each input line before processing it. This takes place after any chomping. Default: True WARNINGGo to any lengths whatsoever to avoid '%' characters in your input, since some C compilers butcher such input. Eg: The thrice-cursed Pyramid C++ compiler. FORMAT OF A STATE TRANSITION TABLETypically, there will be several lines for each state. These lines will differ by their event names, and the corresponding regexp which recognises the given event. Each line consists of these fields:
Q & AHow do I skip input text? Use a regexp of '.*' in your state transition table. If my input is 'abcd' and I have 2 regexps, 'abc.*' and 'abcd.*', which regexp fires? Hmmm. Grammatically speaking, that is a question. Seriously tho, the order of evaluation will be the order in which keys are stored in hashes, which is not under user control. In short, you bungled it by using ambiguous regexps. DEREFERENCING GUIDELINES $self -> {$state} -> {$event} -> {'sub'} Name of subroutine
$self -> {$state} -> {$event} -> {'nextState'} Name of state
$self -> {$state} -> {$event} -> {'validEvents'} Event|Event
$self -> {$state} -> {'RE'} [REs]
$self -> {$state} -> {'event'} [Events]
$self -> {'nextEvent'} [Expected events]
$self -> {'state'} Current state
$self -> {'event'} Current event
$self -> {'command'} Current command
$self -> {'RE'} Current RE
$self -> {'original'} Current input line, original
$self -> {'clean'} Current input line, cleaned up
$self -> {'$1'} Current text matching () IN RE
$self -> {'$2'} Current text matching () IN RE
$self -> {'$3'} Current text matching () IN RE
PROCESSING of #if defined()Reference: PC Techniques, Aug/Sep 1993, p 102, Hax 166. Unimplemented. WARNING re Perl bugAs always, be aware that these 2 lines mean the same thing, sometimes:
The problem is the spaces around the ->. Inside double quotes, "...", the first space stops the dereference taking place. Outside double quotes the scanner correctly associates the $self token with the {'thing'} token. I regard this as a bug. ACKNOWLEDGEMENTSThe processing loop at the heart of this module is something I downloaded from comp.land.perl.misc circa 1994. I encourage the author to contact me. You'll know who you are: There were 2 bugs - both harmless - in 1 line of code, in the routine I call load(). Anybody who accepts responsibility for this code will be deemed to be the author. Well done! AUTHOR
LICENCEAustralian copyright © 1997-2002 Ron Savage. All Programs of mine are 'OSI Certified Open Source Software'; you can redistribute them and/or modify them under the terms of The Artistic License, a copy of which is available at: http://www.opensource.org/licenses/index.html |
| Top of page |