Move #fmt conversion model into ExtFmt.CT namespace

This commit is contained in:
Brian Anderson 2011-04-13 18:59:40 -04:00
parent 44aed626bf
commit aebdef0cd6
2 changed files with 76 additions and 77 deletions

View File

@ -21,35 +21,34 @@ import std.option;
import std.option.none;
import std.option.some;
import std.ExtFmt;
import std.ExtFmt.signedness;
import std.ExtFmt.signed;
import std.ExtFmt.unsigned;
import std.ExtFmt.caseness;
import std.ExtFmt.case_upper;
import std.ExtFmt.case_lower;
import std.ExtFmt.ty;
import std.ExtFmt.ty_bool;
import std.ExtFmt.ty_str;
import std.ExtFmt.ty_char;
import std.ExtFmt.ty_int;
import std.ExtFmt.ty_bits;
import std.ExtFmt.ty_hex;
import std.ExtFmt.flag;
import std.ExtFmt.flag_left_justify;
import std.ExtFmt.flag_left_zero_pad;
import std.ExtFmt.flag_left_space_pad;
import std.ExtFmt.flag_plus_if_positive;
import std.ExtFmt.flag_alternate;
import std.ExtFmt.count;
import std.ExtFmt.count_is;
import std.ExtFmt.count_is_param;
import std.ExtFmt.count_is_next_param;
import std.ExtFmt.count_implied;
import std.ExtFmt.conv;
import std.ExtFmt.piece;
import std.ExtFmt.piece_string;
import std.ExtFmt.piece_conv;
import std.ExtFmt.CT.signedness;
import std.ExtFmt.CT.signed;
import std.ExtFmt.CT.unsigned;
import std.ExtFmt.CT.caseness;
import std.ExtFmt.CT.case_upper;
import std.ExtFmt.CT.case_lower;
import std.ExtFmt.CT.ty;
import std.ExtFmt.CT.ty_bool;
import std.ExtFmt.CT.ty_str;
import std.ExtFmt.CT.ty_char;
import std.ExtFmt.CT.ty_int;
import std.ExtFmt.CT.ty_bits;
import std.ExtFmt.CT.ty_hex;
import std.ExtFmt.CT.flag;
import std.ExtFmt.CT.flag_left_justify;
import std.ExtFmt.CT.flag_left_zero_pad;
import std.ExtFmt.CT.flag_left_space_pad;
import std.ExtFmt.CT.flag_plus_if_positive;
import std.ExtFmt.CT.flag_alternate;
import std.ExtFmt.CT.count;
import std.ExtFmt.CT.count_is;
import std.ExtFmt.CT.count_is_param;
import std.ExtFmt.CT.count_is_next_param;
import std.ExtFmt.CT.count_implied;
import std.ExtFmt.CT.conv;
import std.ExtFmt.CT.piece;
import std.ExtFmt.CT.piece_string;
import std.ExtFmt.CT.piece_conv;
import std.ExtFmt.CT.parse_fmt_string;
export expand_syntax_ext;

View File

@ -1,56 +1,56 @@
import option.none;
import option.some;
tag signedness {
signed;
unsigned;
}
tag caseness {
case_upper;
case_lower;
}
tag ty {
ty_bool;
ty_str;
ty_char;
ty_int(signedness);
ty_bits;
ty_hex(caseness);
// FIXME: More types
}
tag flag {
flag_left_justify;
flag_left_zero_pad;
flag_left_space_pad;
flag_plus_if_positive;
flag_alternate;
}
tag count {
count_is(int);
count_is_param(int);
count_is_next_param;
count_implied;
}
// A formatted conversion from an expression to a string
type conv = rec(option.t[int] param,
vec[flag] flags,
count width,
count precision,
ty ty);
// A fragment of the output sequence
tag piece {
piece_string(str);
piece_conv(conv);
}
// Functions used by the fmt extension at compile time
mod CT {
tag signedness {
signed;
unsigned;
}
tag caseness {
case_upper;
case_lower;
}
tag ty {
ty_bool;
ty_str;
ty_char;
ty_int(signedness);
ty_bits;
ty_hex(caseness);
// FIXME: More types
}
tag flag {
flag_left_justify;
flag_left_zero_pad;
flag_left_space_pad;
flag_plus_if_positive;
flag_alternate;
}
tag count {
count_is(int);
count_is_param(int);
count_is_next_param;
count_implied;
}
// A formatted conversion from an expression to a string
type conv = rec(option.t[int] param,
vec[flag] flags,
count width,
count precision,
ty ty);
// A fragment of the output sequence
tag piece {
piece_string(str);
piece_conv(conv);
}
fn parse_fmt_string(str s) -> vec[piece] {
let vec[piece] pieces = vec();
auto lim = _str.byte_len(s);