Hi, Monks, See my below simple script. I got to get the data of the section content and I failed to do it when it comes to the multiple lines which are supposed:
DESCRIPTION = { UK BANK; UN BANK; };
The section content is what between section name and section end.

#! /usr/local/bin/perl -sw BEGIN { close STDERR and open STDERR, '>./STDERR' or die $!; } use Parse::RecDescent; #use strict; #use warnings; $::RD_TRACE = 1; $::RD_HINT = 1; #============================================ # GRAMMAR DEFINITION HERE #============================================ my $grammar = q{ Para: <skip: qr{ (?> \s | /\* .*? \*/ | //[^\n]* )* }sx> List(s) /\Z/ |{ use Data::Dumper 'Dumper'; print "$_->[0]\n" for @{$thisparser->{errors}}; exit; } List: 'SECTION_START' SECTION_NAME SECTION_CONTENT(s?) SECTION_END |<error> SECTION_NAME: /\w+/ {print "section name is $item[1]\n";} |<error> SECTION_CONTENT: # HOW TO DO IT??? /.*/ ...SECTION_END ...!SECTION_START {print "section content is $item[1]\n";} |<error> SECTION_END: 'SECTION_END' {print "section END is $item[1]\n";} |<error> }; #============================================ # MAIN PROGRAM STARTS HERE #============================================ my $parse = new Parse::RecDescent ($grammar); my $text = do { local $/; <DATA> }; $parse->Para($text); __DATA__ /***********************************/ /* comment1 */ /***********************************/ SECTION_START BANK001 /* be there */ DESCRIPTION = "US BANK"; SECTION_END /********************************/ /* comment2*/ /********************************/ SECTION_START BANK002 /* no DESCRIPTION here!!! */ SECTION_END /************************************/ /* comment3 */ /************************************/ SECTION_START BANK003 //mutiple-line DESCRIPTION DESCRIPTION = { UK BANK; UN BANK; }; SECTION_END


In reply to PRD parser problem: How to deal with mutiple lines by Hanken

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.