Changeset 77 in text-formbuilder for trunk/lib/Text/FormBuilder
- Timestamp:
- 03/25/05 13:20:40 (20 years ago)
- 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 1 6 { 2 7 #$::RD_TRACE = 1; 3 8 my ( 4 $context, # line or group5 9 @sections, # master data structure 6 10 $section_head, 7 11 $section_id, 8 12 @lines, # lines in each section 9 $title,10 $author,11 $description,12 13 %lists, 13 14 %patterns, … … 24 25 $cols, 25 26 ); 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 } 27 34 } 28 35 29 form_spec: (list_def | description_def | validate_def | group_def | note | line)(s) 36 form_spec: 37 { 38 %formspec = (); # clear the old formspec data 39 } 40 (list_def | description_def | group_def | note | line)(s) 30 41 { 31 42 # grab the last section, if there is any … … 39 50 } 40 51 41 $section_id = $item{identifier};42 $section_head = $item[3];43 @lines = ();44 52 $return = { 45 title => $ title,46 author => $ author,47 description => $ description,53 title => $formspec{title}, 54 author => $formspec{author}, 55 description => $formspec{description}, 48 56 lists => \%lists, 49 57 patterns => \%patterns, … … 60 68 61 69 dynamic_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"; } 65 71 66 72 description_def: '!description' block 67 73 { 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 } 74 77 75 78 group_def: '!group' { $context = 'group' } var_name '{' field_line(s) '}' { $context = 'line' } … … 82 85 note: '!note' block { push @lines, [ 'note', $item{block} ]; } 83 86 84 85 #TODO: allow \ escape for [] {} in these blocks86 87 87 88 # curly-brace delimited block, that can contain properly … … 109 110 title: '!title' /.*/ 110 111 { 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]; 113 114 } 114 115 115 116 author: '!author' /.*/ 116 117 { 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]; 119 120 } 120 121 … … 147 148 group_field: '!field' group_name name label(?) 148 149 { 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"; 150 151 push @lines, [ 'group', { name => $item{name}, label => $item{'label(?)'}[0], group => $item{group_name} } ]; 151 152 } … … 227 228 limit: /\d+/ 228 229 229 label: '|' (simple_multiword | quoted_string){ $item[2] }230 label: '|' string { $item[2] } 230 231 231 232 hint: bracket_block … … 237 238 other: '+' 'other' { 1 } 238 239 239 default: '=' (simple_multiword | quoted_string) { $item[2] } 240 default: '=' string { $item[2] } 241 242 string: simple_multiword | quoted_string 240 243 241 244 # for simple multiword values not involving punctuation … … 249 252 option_list: options | list_var 250 253 251 options: '{' option(s / ,/) '}'254 options: '{' option(s /\s*,\s*/) '}' 252 255 253 256 list_var: /@[A-Z_]+/ { $list_var = $item[1] } 254 257 255 option: (simple_multiword | quoted_string)display_text(?)258 option: string display_text(?) 256 259 { push @options, { $item[1] => $item{'display_text(?)'}[0] } } 257 260
Note: See TracChangeset
for help on using the changeset viewer.