Re: keyword value(s) newline

[email protected] ("Ron D. Smith") Wed, 12 May 2004 11:10:39 -0700
Newsgroups perl.recdescent
Message-ID <[email protected]>
There are six problems that you have.

1) you did not read the section on "skip" very carefully.
2) you do not have balanced delimiters in your parse description
3) the second production in the chunk rule does not eliminate leading newlines
4) You did not look at the trace results that you printed out very carefully, 
if you had you would have noticed that PR::D was not consuming your *entire* 
input description.
5) the item hash does not include the modifiers in the name space.
6) /^SOURCE/ is a subset of /^SOURCEPATH/
7) the path delimiter in windoze (you poor soul...) is '\' not '/'

OK, so that's seven, but I didn't expect the Spanish Inquisition.


By making these changes I was able to completely parse you test case.

On Wednesday, May 12, 2004 [email protected] said:
> Sorry, small typo in my mail - the startrule is actually 
> called "mmpfile" in my script. So the (non-working) script is:
> 
> > -----Original Message-----
> > From: ext [mailto:[email protected]]
>  
> > $parser = Parse::RecDescent->new(q(
> > 
> > mmpfile: chunk(s) /^\Z/
> > 
> > chunk: comment | <skip: /[ \t]*/> assignment | <error>

chunk: comment | assignment | <error>


> > 
> > comment: c_comment | cpp_comment
> > 
> > cpp_comment: m{//([^\n]*)} { 	
> > 	push @::cpp_comment, $1;
> > 	1;
> > }
> > 
> > c_comment: m{/[*](.*?)[*]/}s {
> > 	push @::c_comment, $1;
> > 	1;
> > }
> > 
> > assignment: keyword value(s) /\n/ {

 assignment: keyword <skip: '[ \t]*'>  value(s) /\n/ {

#                        ---^      ^---

> > 	push @::keyword, $item{keyword};
> > 	push @::value, join ' ', @{$item{'value(s)'};

 	push @::value, join ' ', @{$item{'value'}};


> > 	1;
> > }
> > 
> > value: file | type | uid
> > 
> > file: m{[\w\\/.-]+}

 file: m{[\w\\.-]+}


> > 
> > type: /APP/i | /DLL/i
> > 
> > uid: /0x[0-9A-F]+/i
> > 
> > keyword: 
> > 	/^AIF/im |
> > 	/^DOCUMENT/im |
> > 	/^LANG/im |
> > 	/^LIBRARY/im |
> > 	/^RESOURCE/im |


   /^SOURCEPATH/im |


> > 	/^SOURCE/im |
> > 	/^SYSTEMINCLUDE/im |
> > 	/^TARGETPATH/im |
> > 	/^TARGETTYPE/im |
> > 	/^TARGET/im |
> > 	/^UID/im |
> > 	/^USERINCLUDE/im
> > 
> > )) or die 'Bad grammar';
> > $text .= $_ while (<DATA>);
> > defined $parser->mmpfile($text) or die 'bad text';
> > 
> > __DATA__
> > 
> > TARGET		CNetB.dll
> > TARGETTYPE	dll
> > UID			0x10000e5e 0x102F43DB
> > 
> > SOURCEPATH	..\NetBSrc 
> > SOURCE		CNetB.cpp  CNetBSerialBase.cpp 
> > CNetBBluetoothModule.cpp
> > SOURCE		CSnakeActiveWrapper.cpp
> > 
> > USERINCLUDE	..\NetBInc
> > SYSTEMINCLUDE	\Epoc32\include \Epoc32\include\oem
> > 
> > LIBRARY		euser.lib efsrv.lib c32.lib // added on 
> > 01.01.2002
> > LIBRARY		esock.lib bluetooth.lib btdevice.lib 
> > btmanclient.lib
> > LIBRARY		btextnotifiers.lib sdpagent.lib
> > 
> > /*
> > START WINS
> > BASEADDRESS     0x46200000
> > END
> > 
> > #if ( (defined ( WINS ) ) || ( defined (WINSCW) ) )
> > SOURCEPATH      ..\SwImp\src
> > SOURCE          CApiCamSpecsImpSw.cpp
> > #else
> > SOURCEPATH      ..\Mirage1\src
> > SOURCE          CApiCamHandlerImpMirage1.cpp
> > #endif
> > */
> > 
> 
> 
> And the error message is here (for some reason keyword doesn't match):
> 
> |assignment|Trying subrule: [keyword]             |
> |assignment|<<Didn't match subrule: [keyword]>>   |


--
 Intel, Corp.
 5000 W. Chandler Blvd.
 Chandler, AZ 85226

-- 
 Intel, Corp.
 5000 W. Chandler Blvd.
 Chandler, AZ  85226