Index: trunk/Changes
===================================================================
--- trunk/Changes	(revision 63)
+++ trunk/Changes	(revision 64)
@@ -5,4 +5,5 @@
     * BUGFIX: !note and !description blocks can now
       contain "unbalanced" quotes (fixed the gramamr)
+    * removed dynamic lists from the grammar
     
 0.08 - 10 Jan 2005
Index: trunk/MANIFEST
===================================================================
--- trunk/MANIFEST	(revision 63)
+++ trunk/MANIFEST	(revision 64)
@@ -4,4 +4,5 @@
 README
 t/Text-FormBuilder.t
+bin/fb.pl
 lib/Text/FormBuilder.pm
 lib/Text/FormBuilder/Examples.pod
Index: trunk/Makefile.PL
===================================================================
--- trunk/Makefile.PL	(revision 63)
+++ trunk/Makefile.PL	(revision 64)
@@ -5,7 +5,7 @@
     NAME              => 'Text::FormBuilder',
     VERSION_FROM      => 'lib/Text/FormBuilder.pm', # finds $VERSION
-##     EXE_FILES         => [ 'bin/fb.pl' ],
+    EXE_FILES         => [ 'bin/fb.pl' ],
     PREREQ_PM         => { 
-                            CGI::FormBuilder => 3.001,
+                            CGI::FormBuilder => 3.0,
                             Parse::RecDescent => 1.94,
                             Text::Template => 1.44,
Index: trunk/lib/Text/FormBuilder.pm
===================================================================
--- trunk/lib/Text/FormBuilder.pm	(revision 63)
+++ trunk/lib/Text/FormBuilder.pm	(revision 64)
@@ -7,5 +7,5 @@
 use vars qw($VERSION @EXPORT);
 
-$VERSION = '0.09_02';
+$VERSION = '0.09';
 @EXPORT = qw(create_form);
 
@@ -235,7 +235,17 @@
     
     # remove extraneous undefined values
+    # also check for approriate version of CGI::FormBuilder
+    # for some advanced options
+    my $FB_version = CGI::FormBuilder->VERSION;
     for my $field (@{ $self->{form_spec}{fields} }) {
         defined $$field{$_} or delete $$field{$_} foreach keys %{ $field };
-    }
+        
+        unless ($FB_version >= '3.002') {
+            if ($$field{growable}) {
+                warn '[' . (caller(0))[3] . "] growable fields not supported by FB $FB_version (requires 3.002)";
+                delete $$field{growable};
+            }
+        }
+    }    
     
     # remove false $$_{required} params because this messes up things at
@@ -243,14 +253,12 @@
     # based on the existance of a 'required' param, not whether it is
     # true or defined
+    # TODO: check if this is still needed
     $$_{required} or delete $$_{required} foreach @{ $self->{form_spec}{fields} };
-
+    
+    # assign the field names to the sections
     foreach (@{ $self->{form_spec}{sections} }) {
-        #for my $line (grep { $$_[0] eq 'field' } @{ $$_{lines} }) {
         for my $line (@{ $$_{lines} }) {
             if ($$line[0] eq 'field') {
                 $$line[1] = $$line[1]{name};
-##                 $_ eq 'name' or delete $$line[1]{$_} foreach keys %{ $$line[1] };
-##             } elsif ($$line[0] eq 'group') {
-##                 $$line[1] = [ map { $$_{name} } @{ $$line[1]{group} } ];
             }
         }
@@ -353,17 +361,4 @@
     my %module_subs;
     my $d = Data::Dumper->new([ \%options ], [ '*options' ]);
-    
-    use B::Deparse;
-    my $deparse = B::Deparse->new;
-##     
-##     #TODO: need a workaround/better solution since Data::Dumper doesn't like dumping coderefs
-##     foreach (@{ $self->{form_spec}{fields} }) {
-##         if (ref $$_{validate} eq 'CODE') {
-##             my $body = $deparse->coderef2text($$_{validate});
-##             #$d->Seen({ "*_validate_$$_{name}" => $$_{validate} });
-##             #$module_subs{$$_{name}} = "sub _validate_$$_{name} $$_{validate}";
-##         }
-##     }    
-##     my $sub_code = join("\n", each %module_subs);
     
     my $form_options = keys %options > 0 ? $d->Dump : '';
@@ -1058,6 +1053,6 @@
 given). Growable fields have a button that allows the user to add a
 copy of the field input. Currently, this only works for C<text> and
-C<file> fields. Growable fields also require JavaScript to function
-correctly.
+C<file> fields, and you must have L<CGI::FormBuilder> 3.02 or higher.
+Growable fields also require JavaScript to function correctly.
 
     # you can have as many people as you like
@@ -1088,18 +1083,4 @@
     
     month:select@MONTHS
-
-There is another form of the C<!list> directive: the dynamic list:
-
-    !list RANDOM &{ map { rand } (0..5) }
-
-The code inside the C<&{ ... }> is C<eval>ed by C<build>, and the results
-are stuffed into the list. The C<eval>ed code can either return a simple
-list, as the example does, or the fancier C<< ( { value1 => 'Description 1'},
-{ value2 => 'Description 2}, ... ) >> form.
-
-I<B<NOTE:> This feature of the language may go away unless I find a compelling
-reason for it in the next few versions. What I really wanted was lists that
-were filled in at run-time (e.g. from a database), and that can be done easily
-enough with the CGI::FormBuilder object directly.>
 
 If you want to have a single checkbox (e.g. for a field that says ``I want to
@@ -1181,4 +1162,6 @@
 Document the commmand line tool
 
+Document use of the parser as a standalone module
+
 Allow renaming of the submit button; allow renaming and inclusion of a 
 reset button
Index: trunk/lib/Text/FormBuilder/grammar
===================================================================
--- trunk/lib/Text/FormBuilder/grammar	(revision 63)
+++ trunk/lib/Text/FormBuilder/grammar	(revision 64)
@@ -60,17 +60,11 @@
 dynamic_list: '&' <perl_codeblock>
     {
-	my @results = (eval $item[2]);
-	if (ref $results[0] eq 'HASH') {
-	    @options = @results;
-	} else {    
-	    @options = map { { $_ => $_ } } @results;
-	}
+	warn "[Text::FormBuilder] Dynamic lists have been removed from the formspec grammar";
     }
 
 description_def: '!description' block
-    { warn "[Text::FormBuilder] Description redefined at input text line $thisline\n" if defined $description;
-    
-    $description = $item[2];
-    $description =~ s/^{\s*|\s*}$//g;
+    {
+	warn "[Text::FormBuilder] Description redefined at input text line $thisline\n" if defined $description;
+	$description = $item{block};
     }
 
@@ -85,23 +79,29 @@
     }
 
-note: '!note' block
-    {   
-	(my $note = $item[2]) =~ s/^{\s*|\s*}$//g;
-	push @lines, [ 'note', $note ];
-    }
+note: '!note' block  { push @lines, [ 'note', $item{block} ]; }
+
+
+#TODO: allow \ escape for [] {} in these blocks
 
 # curly-brace delimited block, that can contain properly
-# nested curly brackets, along with any other characters
-# return with the '{...}' so that nested blocks get the
-# brackets treated as literals
-block: '{' <skip:''> block_content(s) '}'
-    {
-	'{' . join('', @{ $item[3] }) . '}';
-    }
-
-block_content: /[^\{\}]+?/ | block
-
-
+# nested curly braces, along with any other characters
+# inner blocks return with the '{...}' so that nested
+# blocks get the braces treated as literals
+block: '{' <skip:''> block_content(s) '}' { join('', @{ $item[3] }) }
+inner_block: '{' <skip:''> block_content(s) '}'  { '{' . join('', @{ $item[3] }) . '}' }
+block_content: /[^\{\}]+?/ | inner_block
+
+# square brace delimited block, that can contain properly
+# nested square brackets, along with any other characters
+# inner bracket blocks return with the '[...]' so that nested
+# blocks get the braces treated as literals
+bracket_block: '[' <skip:''> bracket_block_content(s) ']' { join('', @{ $item[3] }) }
+inner_bracket_block: '[' <skip:''> bracket_block_content(s) ']' { '[' . join('', @{ $item[3] }) . ']'; }
+bracket_block_content: /[^\[\]]+?/ | inner_bracket_block
+
+
+# field lines are the subset of lines that are allowed in a !group directive
 field_line: <skip:'[ \t]*'> ( field | comment | blank ) "\n"
+
 line: <skip:'[ \t]*'> ( title | author | pattern_def | section_head | heading | group_field | field_group | unknown_directive | field | comment | blank ) "\n"
 
@@ -159,4 +159,5 @@
 group_type: ':' var_name
 
+# this is the real heart of the thing
 field: name field_size(?) growable(?) label(?) hint(?) type(?) default(?) option_list(?) validate(?)
     {
@@ -217,5 +218,5 @@
 label: '|' (simple_multiword | quoted_string) { $item[2] }
 
-hint: '[' /[^\]]+/ ']'    { $item[2] }
+hint: bracket_block
 
 type: ':' builtin_field
@@ -245,23 +246,12 @@
 value: identifier
 
-display_text: brace_block
-    { (my $text = $item[1]) =~ s/^\[\s*|\s*\]$//g; $text }
-
-# square brace delimited block, that can contain properly
-# nested square braces, along with any other characters
-# return with the '[...]' so that nested blocks get the
-# braces treated as literals
-brace_block: '[' <skip:''> brace_block_content(s) ']'
-    {
-	'[' . join('', @{ $item[3] }) . ']';
-    }
-brace_block_content: /[^\[\]]+?/ | brace_block
-
-
-validate: '//' (optional_pattern | required_pattern)    { $item[2] }
-
-optional_pattern: /[A-Z_]+/ '?'	{ $required = 0; $item[1] }
-
-required_pattern: /[A-Z_]+/ { $required = 1; $item[1] }
+display_text: bracket_block
+
+
+validate: '//' (optional_pattern | required_pattern)
+
+optional_pattern: var_name '?'	{ $required = 0; $item[1] }
+
+required_pattern: var_name { $required = 1; $item[1] }
 
 comment: '#' /.*/
