PreviousUpNext

15.3.423  src/lib/src/scanf.api

## scanf.api
# C-style conversions from string representations.

# Compiled by:
#     src/lib/std/standard.lib

# This api is implemented by:
#     src/lib/src/scanf.pkg



stipulate
    package f8b =  eight_byte_float;                                    # eight_byte_float      is from   src/lib/std/eight-byte-float.pkg
herein

    api Scanf {

        Printf_Arg
          = QUICKSTRING   quickstring::Quickstring
          | LINT   large_int::Int
          | INT    int::Int
          | LUNT   large_unt::Unt
          | UNT    unt::Unt
          | UNT8   one_byte_unt::Unt
          | BOOL   Bool
          | CHAR   Char
          | STRING String
          | FLOAT  f8b::Float
          | LEFT   ((Int, Printf_Arg))          # Left  justify in field of given width.
          | RIGHT  ((Int, Printf_Arg))          # Right justify in field of given width.
          ;

        exception BAD_FORMAT String;                            #  Bad format string 


                                                                    # number_string     is from   src/lib/std/src/number-string.pkg
        # "fnsscanf" == "scanf over functional streams":
        fnsscanf
            :  (X -> Null_Or( (Char, X) ) )                             # E.g., 'get' function fetching i-th char from input string.
            -> X                                                        # E.g., next 'i' to read from input string.
            -> String                                           # Format string.
            -> Null_Or( (List( Printf_Arg ), X) );                      # List of items extracted from input stream, plus any remaining input stream.

        sscanf
            :  String                                           # Input  string.
            -> String                                           # Format string.
            -> Null_Or( List( Printf_Arg ) );                   # Results.

        sscanf_by
            :  String                                           # Format string.
            -> String                                           # Input  string.
            -> Null_Or( List( Printf_Arg ) );                   # Results.

        fscanf
            :  file::Input_Stream                                       # Stream to read.
            -> String                                           # Format string.
            -> Null_Or( List( Printf_Arg ) );                   # Results.

        scanf                                                   # Above, reading from stdin.
            :  String                                           # Format string.
            -> Null_Or( List( Printf_Arg ) );                   # Results.

    };
end;

## AUTHOR:   John Reppy
##          AT&T Research
##          jhr@research.att.com
##
## COPYRIGHT (c) 1996 by AT&T Research.  See COPYRIGHT file for details.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2012,
## released under Gnu Public Licence version 3.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext