On Wednesday, Dec 17, 2003 Aaron Dalton said: > I have created a grammar for processing basic rules for a pbem I am > writing. I have also written an object for then processing the resulting > parse tree. What is happening is this: If I simply parse the input and > dump the tree, everything parses fine. The second I even "use" my > processing object module (which happens to be called "Process") the parse > fails.
You should remember the semantics of "use". When you include a use statement in your code, the code is compiled and executed *before* the main code is even finished being compiled. (In other words the use statement has side effects at compile, not just run time.) For example, consider the following: test.pm emacs test.pl use test; if *l;q gpslq;tpyuawt --------- Now what will happen is that you will get the printout *AND* a compile failure! chlx330> emacs test.pm # create pm from above chlx330> emacs test.pl # create pl from above chlx330> /usr/intel/pkgs/perl/5.6.1/bin/perl test.pl hello there I'm executing. syntax error at test.pl line 3, near "if *l" Can't find string terminator "g" anywhere before EOF at test.pl line 3. chlx330> You *must* have executable statements in your use file, not just subroutine declarations, and these are obviously causing side effects. My suggestion is to keep cutting stuff off of your Process module until the problem goes away. When the problem goes away, whatever you cut away is causing the problem, somehow. My bet is that once you see the actual offending code, it will become "clear" what is wrong. Don't worry about the fact that cutting off whole sections of your module screws up the operation, the operation is already screwed up by your description... If you can parse, you are better off, and if you can't parse you have not identified the problem. So: do { cut a self consistent chunk of code off of your Process module; run the code up to the parser; } while (parse fails) Keep doing this until you identify the exact line. > I did a TRACE and what seems to happen is the parser doesn't > ignore the newlines in the 2nd instance. I am totally confused. Below is > the snippet of my code in question. I can include copies of the grammar > andthe TRACE if that would be helpful. Any ideas? Thanks so much for > your help. > > > #START CODE > my $parser = new Parse::RecDescent ($grammar); > my $parsetree = $parser->orderset($bodytxt); > > if (! defined $parsetree) > {die "Grammar parse failed!\n";} > else > { > use YAML; > print &Dump($parsetree), "\n"; > > #if I uncomment the below code, the parse fails > # > #use Process; > #my $process = Process::new(); > #$process->processTree($parsetree); > #print $process->{results}, "\n"; > } > #END CODE > > -- > Aaron Dalton > [EMAIL PROTECTED] > http://aaron.finch.st > -- Intel, Corp. 5000 W. Chandler Blvd. Chandler, AZ 85226 -- Intel, Corp. 5000 W. Chandler Blvd. Chandler, AZ 85226