Changeset 21 in text-formbuilder for trunk/lib/Text/FormBuilder/grammar
- Timestamp:
- 11/12/04 16:54:23 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Text/FormBuilder/grammar
r16 r21 1 { my ($title, $author, $description, %lists, %patterns, @fields, @headings, $type, @options, $list_var, $size, $rows, $cols); } 1 { 2 my ( 3 $context, # line or group 4 @lines, # master data structure 5 $title, 6 $author, 7 $description, 8 %lists, 9 %patterns, 10 @fields, 11 @group, # current group 12 %groups, # stored groups of fields 13 @headings, 14 $type, 15 @options, 16 $list_var, 17 $size, 18 $rows, 19 $cols, 20 ); 21 $context = 'line'; 22 } 2 23 3 form_spec: (list_def | description_def | line)(s)24 form_spec: (list_def | description_def | group_def | line)(s) 4 25 { 5 26 $return = { … … 11 32 headings => \@headings, 12 33 fields => \@fields, 34 lines => \@lines, 35 groups => \%groups, 13 36 } 14 37 } … … 36 59 } 37 60 38 line: <skip:'[ \t]*'> ( title | author | pattern_def | heading | unknown_directive | field | comment | blank ) "\n" 61 group_def: '!group' { $context = 'group' } var_name '{' field_line(s) '}' { $context = 'line' } 62 { 63 #warn "$item{var_name} group; context $context\n" 64 $groups{$item{var_name}} = [ @group ]; 65 @group = (); 66 } 67 68 field_line: <skip:'[ \t]*'> ( field | comment | blank ) "\n" 69 line: <skip:'[ \t]*'> ( title | author | pattern_def | heading | group_field | unknown_directive | field | comment | blank ) "\n" 39 70 40 71 title: '!title' /.*/ … … 51 82 52 83 heading: '!head' /.*/ 53 { warn "[Text::FormBuilder] Header before field " . scalar(@fields) . " redefined at input text line $thisline\n" if defined $headings[@fields]; 54 $headings[@fields] = $item[2] } 84 { 85 warn "[Text::FormBuilder] Header before field " . scalar(@fields) . " redefined at input text line $thisline\n" if defined $headings[@fields]; 86 $headings[@fields] = $item[2]; 87 push @lines, [ 'head', $item[2] ]; 88 } 89 90 group_field: '!field' group_name name label(?) 91 { #warn "[$thisline] $item{group_name}\n"; 92 push @lines, [ 'group', { name => $item{name}, label => $item{'label(?)'}[0], group => $item{group_name} } ]; 93 } 94 95 group_name: /%[A-Z_]+/ 55 96 56 97 field: name field_size(?) label(?) hint(?) type(?) default(?) option_list(?) validate(?) … … 72 113 $$field{size} = $size if defined $size; 73 114 74 push @fields, $field; 115 #warn "[$thisline] field $item{name}; context $context\n"; 116 if ($context eq 'group') { 117 push @group, $field; 118 } else { 119 push @fields, $field; 120 push @lines, [ 'field', $field ]; 121 } 75 122 76 123 $type = undef; … … 95 142 { $rows = $item[1]; $cols = $item[3] } 96 143 97 label: '|' /[^:\[\{\/]+/i 144 #TODO: zero width labels 145 label: '|' /[^:\[\{\/\n]*/i { $item[2] } 98 146 99 147 hint: '[' /[^\]]+/ ']' { $item[2] }
Note: See TracChangeset
for help on using the changeset viewer.