Edwin Steiner <[EMAIL PROTECTED]> writes:
> The rule could be like:
>
> \\F <printf_format_without_percent> <funny_character_expression>
After-afterthought:
We know: Everything between the \F and the next funny character is the
format specifier. This allows extensions to the printf-specifiers:
(These extension and more could also be used in C<but formatted>.)
rule format_specifier {
('-' | ' ') <fill_character>? <width>? ('.' <precision>)? <conversion>?
|
<fill_character_no_minus>? <width>? ('.' <precision>)? <conversion>?
}
rule fill_character {
'-' | <fill_character_no_minus>
}
rule fill_character_no_minus {
<!before <conversion>> ( <[EMAIL PROTECTED] ]> | <escaped_character> )
}
(Hope I got that right.)
If there is no <conversion> specified, just do the alignment and
filling on the value (which is converted to string before that).
Examples:
$x = 3;
" \F6$x" --> 3
" \F-6$x" --> 3
" \F06$x" --> 000003
" \F*6$x" --> *****3
" \F-*6$x" --> 3*****
" \F\$6$x" --> $$$$$3 (yes, it's ugly)
" \F\-6$x" --> -----3
" \F -6$x" --> -----3 (looks better without the backslash, I think)
" \F--6$x" --> 3-----
"\F*20$()" eq ('*' x 20) (don't want to propose special syntax instead of $())
Another possible extension: If there is a <fill_character> specified,
followed by an 'x' and <width>, interpret it as <fill_character> x
<width> and don't expect the <funny_character_expression>:
"\F*x20" eq ('*' x 20)
...quite irregular though.
-Edwin