PreviousUpNext

15.3.436  src/lib/src/scanf.api

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

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




stipulate
    package f8b =  eight_byte_float;                                    # eight_byte_float              is from   src/lib/std/eight-byte-float.pkg
    package fil =  file__premicrothread;                                # file__premicrothread          is from   src/lib/std/src/posix/file--premicrothread.pkg
    package qs  =  quickstring__premicrothread;                         # quickstring__premicrothread   is from   src/lib/src/quickstring--premicrothread.pkg
herein

    # This api is implemented in:
    #
    #     src/lib/src/scanf.pkg
    #
    api Scanf {
        #
        Printf_Arg
          = QUICKSTRING   qs::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
            :  fil::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 SMLNJ-COPYRIGHT file for details.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext