diff options
| author | Brian Anderson <[email protected]> | 2011-04-10 14:09:47 -0400 |
|---|---|---|
| committer | Brian Anderson <[email protected]> | 2011-04-11 21:51:23 -0400 |
| commit | 5a367866349b54b648f41e9ddd9efd4cfe88a649 (patch) | |
| tree | 703cfc387231e1e0b46721e50dc6f607dacd9c0e /src | |
| parent | rustc: Add a uint hash function (diff) | |
| download | rust-5a367866349b54b648f41e9ddd9efd4cfe88a649.tar.xz rust-5a367866349b54b648f41e9ddd9efd4cfe88a649.zip | |
Move the extfmt data model into the standard library.
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp/front/extfmt.rs | 78 | ||||
| -rw-r--r-- | src/lib/ExtFmt.rs | 47 | ||||
| -rw-r--r-- | src/lib/std.rc | 1 |
3 files changed, 78 insertions, 48 deletions
diff --git a/src/comp/front/extfmt.rs b/src/comp/front/extfmt.rs index 5e4f86af..22c43bc9 100644 --- a/src/comp/front/extfmt.rs +++ b/src/comp/front/extfmt.rs @@ -21,55 +21,37 @@ import std.option; import std.option.none; import std.option.some; -export expand_syntax_ext; - -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 -} +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; -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); -} +export expand_syntax_ext; // TODO: Need to thread parser through here to handle errors correctly fn expand_syntax_ext(vec[@ast.expr] args, 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; |