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


Ignore:
Timestamp:
03/10/05 16:40:27 (19 years ago)
Author:
peichman
Message:

fixed grammar so that outer {} and [] are no longer included in the (bracket_)block values
using bracket_block instead of hardcoded pattern for matching hints in formspec
removed dynamic lists from the grammar
some general code cleanup and tidying, in FormBuilder.pm and grammar
added fb.pl to the MANIFEST
bumped back FB version requirement to 3.0 (Makefile.PL)
test for FB3.02 for using growable fields; warn and ignore if verison isn't high enough

File:
1 edited

Legend:

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

    r63 r64  
    6060dynamic_list: '&' <perl_codeblock> 
    6161    { 
    62         my @results = (eval $item[2]); 
    63         if (ref $results[0] eq 'HASH') { 
    64             @options = @results; 
    65         } else {     
    66             @options = map { { $_ => $_ } } @results; 
    67         } 
     62        warn "[Text::FormBuilder] Dynamic lists have been removed from the formspec grammar"; 
    6863    } 
    6964 
    7065description_def: '!description' block 
    71     { warn "[Text::FormBuilder] Description redefined at input text line $thisline\n" if defined $description; 
    72      
    73     $description = $item[2]; 
    74     $description =~ s/^{\s*|\s*}$//g; 
     66    { 
     67        warn "[Text::FormBuilder] Description redefined at input text line $thisline\n" if defined $description; 
     68        $description = $item{block}; 
    7569    } 
    7670 
     
    8579    } 
    8680 
    87 note: '!note' block 
    88     {    
    89         (my $note = $item[2]) =~ s/^{\s*|\s*}$//g; 
    90         push @lines, [ 'note', $note ]; 
    91     } 
     81note: '!note' block  { push @lines, [ 'note', $item{block} ]; } 
     82 
     83 
     84#TODO: allow \ escape for [] {} in these blocks 
    9285 
    9386# curly-brace delimited block, that can contain properly 
    94 # nested curly brackets, along with any other characters 
    95 # return with the '{...}' so that nested blocks get the 
    96 # brackets treated as literals 
    97 block: '{' <skip:''> block_content(s) '}' 
    98     { 
    99         '{' . join('', @{ $item[3] }) . '}'; 
    100     } 
    101  
    102 block_content: /[^\{\}]+?/ | block 
    103  
    104  
     87# nested curly braces, along with any other characters 
     88# inner blocks return with the '{...}' so that nested 
     89# blocks get the braces treated as literals 
     90block: '{' <skip:''> block_content(s) '}' { join('', @{ $item[3] }) } 
     91inner_block: '{' <skip:''> block_content(s) '}'  { '{' . join('', @{ $item[3] }) . '}' } 
     92block_content: /[^\{\}]+?/ | inner_block 
     93 
     94# square brace delimited block, that can contain properly 
     95# nested square brackets, along with any other characters 
     96# inner bracket blocks return with the '[...]' so that nested 
     97# blocks get the braces treated as literals 
     98bracket_block: '[' <skip:''> bracket_block_content(s) ']' { join('', @{ $item[3] }) } 
     99inner_bracket_block: '[' <skip:''> bracket_block_content(s) ']' { '[' . join('', @{ $item[3] }) . ']'; } 
     100bracket_block_content: /[^\[\]]+?/ | inner_bracket_block 
     101 
     102 
     103# field lines are the subset of lines that are allowed in a !group directive 
    105104field_line: <skip:'[ \t]*'> ( field | comment | blank ) "\n" 
     105 
    106106line: <skip:'[ \t]*'> ( title | author | pattern_def | section_head | heading | group_field | field_group | unknown_directive | field | comment | blank ) "\n" 
    107107 
     
    159159group_type: ':' var_name 
    160160 
     161# this is the real heart of the thing 
    161162field: name field_size(?) growable(?) label(?) hint(?) type(?) default(?) option_list(?) validate(?) 
    162163    { 
     
    217218label: '|' (simple_multiword | quoted_string) { $item[2] } 
    218219 
    219 hint: '[' /[^\]]+/ ']'    { $item[2] } 
     220hint: bracket_block 
    220221 
    221222type: ':' builtin_field 
     
    245246value: identifier 
    246247 
    247 display_text: brace_block 
    248     { (my $text = $item[1]) =~ s/^\[\s*|\s*\]$//g; $text } 
    249  
    250 # square brace delimited block, that can contain properly 
    251 # nested square braces, along with any other characters 
    252 # return with the '[...]' so that nested blocks get the 
    253 # braces treated as literals 
    254 brace_block: '[' <skip:''> brace_block_content(s) ']' 
    255     { 
    256         '[' . join('', @{ $item[3] }) . ']'; 
    257     } 
    258 brace_block_content: /[^\[\]]+?/ | brace_block 
    259  
    260  
    261 validate: '//' (optional_pattern | required_pattern)    { $item[2] } 
    262  
    263 optional_pattern: /[A-Z_]+/ '?' { $required = 0; $item[1] } 
    264  
    265 required_pattern: /[A-Z_]+/ { $required = 1; $item[1] } 
     248display_text: bracket_block 
     249 
     250 
     251validate: '//' (optional_pattern | required_pattern) 
     252 
     253optional_pattern: var_name '?'  { $required = 0; $item[1] } 
     254 
     255required_pattern: var_name { $required = 1; $item[1] } 
    266256 
    267257comment: '#' /.*/ 
Note: See TracChangeset for help on using the changeset viewer.