From 5a367866349b54b648f41e9ddd9efd4cfe88a649 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 10 Apr 2011 14:09:47 -0400 Subject: Move the extfmt data model into the standard library. --- src/lib/ExtFmt.rs | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/lib/std.rc | 1 + 2 files changed, 48 insertions(+) create mode 100644 src/lib/ExtFmt.rs (limited to 'src/lib') diff --git a/src/lib/ExtFmt.rs b/src/lib/ExtFmt.rs new file mode 100644 index 00000000..15f7ff83 --- /dev/null +++ b/src/lib/ExtFmt.rs @@ -0,0 +1,47 @@ +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); +} diff --git a/src/lib/std.rc b/src/lib/std.rc index b530bd7f..67a41dad 100644 --- a/src/lib/std.rc +++ b/src/lib/std.rc @@ -83,6 +83,7 @@ mod sort; mod sha1; mod ebml; mod UFind; +mod ExtFmt; // Local Variables: // mode: rust; -- cgit v1.2.3