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


Ignore:
Timestamp:
10/21/04 16:55:26 (20 years ago)
Author:
peter
Message:

added dynamic lists (evaled perl code blocks) to !list def command

File:
1 edited

Legend:

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

    r1 r10  
    1212    } 
    1313 
    14 list_def: '!list' list_name '{' option(s /,\s*/) /,?/ '}' 
     14list_def: '!list' list_name (static_list | dynamic_list) 
    1515    { $lists{$item{list_name}} = [ @options ]; @options = () } 
     16 
     17static_list: '{' option(s /,\s*/) /,?/ '}' 
     18 
     19dynamic_list: '&' <perl_codeblock> 
     20    { 
     21        my @results = (eval $item[2]); 
     22        if (ref $results[0] eq 'HASH') { 
     23            @options = @results; 
     24        } else {     
     25            @options = map { { $_ => $_ } } @results; 
     26        } 
     27    } 
    1628 
    1729list_name: /[A-Z_]+/ 
Note: See TracChangeset for help on using the changeset viewer.