Re: Negative Look-ahead problem

[email protected] (Karl Gaissmaier) Wed, 31 Mar 2004 15:46:04 +0200
Newsgroups perl.recdescent
Message-ID <[email protected]>
Andras Karacsony schrieb:

> Hello Karl!
> 
> No, because the C grammar example doesn't tweak the skip pattern either.
> 
> (I made my program work by 'preprocessing' the target text.
>     
>     $_ = lc ;
>     s/\b(and|or)\b/\U$1/g; 
> 
>     my $tree = $parser->start($_);
> 
> and getting rid of the 'i'
> 
>     reserved_word: 'AND' | 'OR' 
>     WORD:          ...!reserved_word /[a-z0-9]+/
> )
> 

this is really not necessary, I think you should shrink
it down to a working example like:

<<<<<<<<<<<<<<<<< snip >>>>>>>>>>>>>>>>>>>>>>>>>>
#!/usr/local/bin/perl

use strict;
use warnings;
use Parse::RecDescent;
$::RD_TRACE = 1;
use Data::Dumper;

my $grammar = <<'EOG';
<autotree>
RESERVED : 'AND' | 'OR'
IDENTIFIER : ...!RESERVED m/[a-z0-9]+/i
EOG

my $parser = Parse::RecDescent->new($grammar)
     or die "can't create parser,";

my $text = join '', <>;
print Dumper($parser->IDENTIFIER($text));
<<<<<<<<<<<<<<<<< snip >>>>>>>>>>>>>>>>>>>>>>>>>>

and this works very well. I think there is an other
problem hidden in your code.

Best Regards
	Charly

> Andras
> 
> 
>>-----Original Message-----
>>From: Karl Gaissmaier [mailto:[email protected]]
>>Sent: Wednesday, March 31, 2004 4:24 AM
>>To: PerlDiscuss - Perl Newsgroups and mailing lists
>>Subject: Re: Negative Look-ahead problem
>>
>>
>>PerlDiscuss - Perl Newsgroups and mailing lists schrieb:
>>
>>
>>>reserved_word: 'AND' | 'OR' 
>>>WORD:          ...!reserved_word /[a-z0-9]+/i 
>>>
>>>Using the above grammar, rule WORD fails to match any token 
>>
>>that start
>>
>>>with a reserved word (e.g. Andy). That is not what I 
>>
>>expected since in
>>
>>>'demo_Cgrammar.pl', we have:
>>>
>>>IDENTIFIER:     ...!reserved_word /[a-z]\w*/i
>>>
>>>I am I missing something?
>>>
>>>Thanks!
>>>Andras
>>
>>hmm, did to tweak the skip pattern?
>>Regards
>>	Charly
>>
>>-- 
>>Karl Gaissmaier       KIZ/Infrastructure, University of Ulm, Germany
>>Email:[email protected]           Service Group Network
>>Tel.: ++49 731 50-22499
>>
> 
> 
> 


-- 
Karl Gaissmaier       KIZ/Infrastructure, University of Ulm, Germany
Email:[email protected]           Service Group Network
Tel.: ++49 731 50-22499