Changeset 77 in text-formbuilder for trunk/lib/Text/FormBuilder


Ignore:
Timestamp:
03/25/05 13:20:40 (20 years ago)
Author:
peichman
Message:

fixed some typos in the docs
rearranged internals in the grammar, plus a minor bugfix for the skip pattern of inline lists (now allows padding space around the comma)
added new test scripts to the MANIFEST

File:
1 edited

Legend:

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

    r74 r77  
     1# line directives 
     2# block directives 
     3# field lines 
     4# comments 
     5 
    16{ 
    27    #$::RD_TRACE = 1; 
    38    my ( 
    4         $context,      # line or group 
    59        @sections,     # master data structure 
    610        $section_head, 
    711        $section_id, 
    812        @lines,        # lines in each section 
    9         $title, 
    10         $author, 
    11         $description, 
    1213        %lists, 
    1314        %patterns, 
     
    2425        $cols, 
    2526    ); 
    26     $context = 'line'; 
     27    my $context = 'line';       # start in line context by default 
     28    my %formspec; 
     29     
     30    # TODO: helper sub? 
     31    sub alert ($) { 
     32        warn '[' . (split(/::/, (caller(1))[3]))[-1] . '] ' . shift() . "\n"; 
     33    } 
    2734} 
    2835 
    29 form_spec: (list_def | description_def | validate_def | group_def | note | line)(s) 
     36form_spec: 
     37    {  
     38        %formspec = ();  # clear the old formspec data 
     39    } 
     40    (list_def | description_def | group_def | note | line)(s) 
    3041    { 
    3142        # grab the last section, if there is any 
     
    3950        } 
    4051         
    41         $section_id = $item{identifier}; 
    42         $section_head = $item[3]; 
    43         @lines = (); 
    4452        $return = { 
    45             title    => $title, 
    46             author   => $author, 
    47             description => $description, 
     53            title    => $formspec{title}, 
     54            author   => $formspec{author}, 
     55            description => $formspec{description}, 
    4856            lists    => \%lists, 
    4957            patterns => \%patterns, 
     
    6068 
    6169dynamic_list: '&' <perl_codeblock> 
    62     { 
    63         warn "[Text::FormBuilder] Dynamic lists have been removed from the formspec grammar"; 
    64     } 
     70    { warn "[Text::FormBuilder] Dynamic lists have been removed from the formspec grammar"; } 
    6571 
    6672description_def: '!description' block 
    6773    { 
    68         warn "[Text::FormBuilder] Description redefined at input text line $thisline\n" if defined $description; 
    69         $description = $item{block}; 
    70     } 
    71  
    72 validate_def: '!validate' var_name <perl_codeblock> 
    73     { $subs{$item{var_name}} = eval "sub $item[3]" } 
     74        warn "[Text::FormBuilder] Description redefined at input text line $thisline\n" if defined $formspec{description}; 
     75        $formspec{description} = $item{block}; 
     76    } 
    7477 
    7578group_def: '!group' { $context = 'group' } var_name '{' field_line(s) '}' { $context = 'line' } 
     
    8285note: '!note' block  { push @lines, [ 'note', $item{block} ]; } 
    8386 
    84  
    85 #TODO: allow \ escape for [] {} in these blocks 
    8687 
    8788# curly-brace delimited block, that can contain properly 
     
    109110title: '!title' /.*/ 
    110111    { 
    111         warn "[Text::FormBuilder] Title redefined at input text line $thisline\n" if defined $title; 
    112         $title = $item[2]; 
     112        warn "[Text::FormBuilder] Title redefined at input text line $thisline\n" if defined $formspec{title}; 
     113        $formspec{title} = $item[2]; 
    113114    } 
    114115 
    115116author: '!author' /.*/ 
    116117    { 
    117         warn "[Text::FormBuilder] Author redefined at input text line $thisline\n" if defined $author; 
    118         $author = $item[2]; 
     118        warn "[Text::FormBuilder] Author redefined at input text line $thisline\n" if defined $formspec{author}; 
     119        $formspec{author} = $item[2]; 
    119120    } 
    120121 
     
    147148group_field: '!field' group_name name label(?) 
    148149    { 
    149         warn "[Text::FormBuilder] The !field directive has been DEPRECATED (input file line $thisline). Please use the name:GROUP style"; 
     150        warn "WARNING line $thisline: The '!field' directive has been DEPRECATED. Use the 'name:GROUP' style instead.\n"; 
    150151        push @lines, [ 'group', { name => $item{name}, label => $item{'label(?)'}[0], group => $item{group_name} } ]; 
    151152    } 
     
    227228limit: /\d+/ 
    228229 
    229 label: '|' (simple_multiword | quoted_string) { $item[2] } 
     230label: '|' string { $item[2] } 
    230231 
    231232hint: bracket_block 
     
    237238other: '+' 'other' { 1 } 
    238239 
    239 default: '=' (simple_multiword | quoted_string) { $item[2] } 
     240default: '=' string { $item[2] } 
     241 
     242string: simple_multiword | quoted_string 
    240243 
    241244# for simple multiword values not involving punctuation 
     
    249252option_list: options | list_var 
    250253     
    251 options: '{' option(s /,/) '}' 
     254options: '{' option(s /\s*,\s*/) '}' 
    252255 
    253256list_var: /@[A-Z_]+/ { $list_var = $item[1] } 
    254257 
    255 option: (simple_multiword | quoted_string) display_text(?) 
     258option: string display_text(?) 
    256259    { push @options, { $item[1] => $item{'display_text(?)'}[0] } } 
    257260 
Note: See TracChangeset for help on using the changeset viewer.