Changeset 29 in text-formbuilder for trunk/lib/Text/FormBuilder/grammar


Ignore:
Timestamp:
11/17/04 10:03:41 (19 years ago)
Author:
peter
Message:

added !section directive

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Text/FormBuilder/grammar

    r28 r29  
    22    my ( 
    33        $context,      # line or group 
    4         @lines,        # master data structure 
     4        @sections,     # master data structure 
     5        $section_head, 
     6        $section_id, 
     7        @lines,        # lines in each section 
    58        $title, 
    69        $author, 
     
    2326form_spec: (list_def | description_def | group_def | line)(s) 
    2427    { 
     28        # grab the last section, if there is any 
     29        if (@lines) { 
     30            push @sections, 
     31                { 
     32                    id   => $section_id, 
     33                    head => $section_head, 
     34                    lines => [ @lines ], 
     35                }; 
     36        } 
     37         
     38        $section_id = $item{identifier}; 
     39        $section_head = $item[3]; 
     40        @lines = (); 
    2541        $return = { 
    2642            title    => $title, 
     
    2945            lists    => \%lists, 
    3046            patterns => \%patterns, 
    31             lines    => \@lines, 
    3247            groups   => \%groups, 
     48            sections => \@sections, 
    3349        } 
    3450    } 
     
    6480 
    6581field_line: <skip:'[ \t]*'> ( field | comment | blank ) "\n" 
    66 line: <skip:'[ \t]*'> ( title | author | pattern_def | heading | group_field | unknown_directive | field | comment | blank ) "\n" 
     82line: <skip:'[ \t]*'> ( title | author | pattern_def | section_head | heading | group_field | unknown_directive | field | comment | blank ) "\n" 
    6783 
    6884title: '!title' /.*/ 
     
    8298 
    8399pattern: /.*/ 
     100 
     101section_head: '!section' identifier /.*/ 
     102    { 
     103        #warn "starting section $item{identifier}\n"; 
     104        #warn "  with heading $item[3]\n" if $item[3]; 
     105         
     106        if (@lines) { 
     107            push @sections, 
     108                { 
     109                    id   => $section_id, 
     110                    head => $section_head, 
     111                    lines => [ @lines ], 
     112                }; 
     113        } 
     114         
     115        $section_id = $item{identifier}; 
     116        $section_head = $item[3]; 
     117        @lines = (); 
     118    } 
    84119 
    85120heading: '!head' /.*/    { push @lines, [ 'head', $item[2] ] } 
Note: See TracChangeset for help on using the changeset viewer.