Changeset 64 in text-formbuilder for trunk/lib/Text/FormBuilder
- Timestamp:
- 03/10/05 16:40:27 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Text/FormBuilder/grammar
r63 r64 60 60 dynamic_list: '&' <perl_codeblock> 61 61 { 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"; 68 63 } 69 64 70 65 description_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}; 75 69 } 76 70 … … 85 79 } 86 80 87 note: '!note' block 88 { 89 (my $note = $item[2]) =~ s/^{\s*|\s*}$//g; 90 push @lines, [ 'note', $note ]; 91 } 81 note: '!note' block { push @lines, [ 'note', $item{block} ]; } 82 83 84 #TODO: allow \ escape for [] {} in these blocks 92 85 93 86 # 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 90 block: '{' <skip:''> block_content(s) '}' { join('', @{ $item[3] }) } 91 inner_block: '{' <skip:''> block_content(s) '}' { '{' . join('', @{ $item[3] }) . '}' } 92 block_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 98 bracket_block: '[' <skip:''> bracket_block_content(s) ']' { join('', @{ $item[3] }) } 99 inner_bracket_block: '[' <skip:''> bracket_block_content(s) ']' { '[' . join('', @{ $item[3] }) . ']'; } 100 bracket_block_content: /[^\[\]]+?/ | inner_bracket_block 101 102 103 # field lines are the subset of lines that are allowed in a !group directive 105 104 field_line: <skip:'[ \t]*'> ( field | comment | blank ) "\n" 105 106 106 line: <skip:'[ \t]*'> ( title | author | pattern_def | section_head | heading | group_field | field_group | unknown_directive | field | comment | blank ) "\n" 107 107 … … 159 159 group_type: ':' var_name 160 160 161 # this is the real heart of the thing 161 162 field: name field_size(?) growable(?) label(?) hint(?) type(?) default(?) option_list(?) validate(?) 162 163 { … … 217 218 label: '|' (simple_multiword | quoted_string) { $item[2] } 218 219 219 hint: '[' /[^\]]+/ ']' { $item[2] }220 hint: bracket_block 220 221 221 222 type: ':' builtin_field … … 245 246 value: identifier 246 247 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] } 248 display_text: bracket_block 249 250 251 validate: '//' (optional_pattern | required_pattern) 252 253 optional_pattern: var_name '?' { $required = 0; $item[1] } 254 255 required_pattern: var_name { $required = 1; $item[1] } 266 256 267 257 comment: '#' /.*/
Note: See TracChangeset
for help on using the changeset viewer.