hak0983 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use Tk; use Parse::RecDescent; my $mw = new MainWindow; my $mw2 = $mw->Text()->pack(); my $mw3 = $mw->Button(-text=>"Check brackets", -command => [ \&parser, $mw2 ] )->pack(); MainLoop; sub parser { my $txt = shift; my $grammar = q { startrule: anything print open text close end anything:/([^p]*)/ print: "print" open: "'" text: /([^']*)/ close: "'" end: ";" }; my $parser = Parse::RecDescent->new($grammar); if ( defined( $parser->startrule( $txt->get( "1.0", "end" )))) { print "NO ERROR\n"; } else { print "Print function error\n"; } }
Also, i am wondering if i can get it so multiple print functions can appear down the text area and if there is an error with a later function, it will be spotted.
Cheers
20050331 Janitored by Corion: Put code in code tags.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parse::Recdescent rule problem
by graff (Chancellor) on Mar 31, 2005 at 04:05 UTC | |
|
Re: Parse::Recdescent rule problem
by ikegami (Patriarch) on Mar 31, 2005 at 08:24 UTC | |
|
Re: Parse::Recdescent rule problem
by thekestrel (Friar) on Mar 30, 2005 at 23:28 UTC |