Module FormatParser

A printf-like format expression parser

A format expression is of the form

"(Specifier|NonSpecifier)*"(,Var)*

where Var can be any string without a comma.

A specifier is in the form

%[flags] [width] [.precision] type

Allowed Flags: - + 0 ' ' #

Width and Precision are either integers or .

Types: c d i o x X e E f s

For explanation on semantics see http://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html

For further informations see the library `Data.Format` of package `printf`. Not all parsable expressions are usable.

Author: Jasper Sikorra (with changes by Michael Hanus)

Version: December 2018

Summary of exported operations:

parse :: String -> Pos -> String -> IO (WM (PR String))   
The function parses and converts a String that is in the format of a C-like printf expression into a Curry Expression that makes use of the Data.Format library.

Exported operations:

parse :: String -> Pos -> String -> IO (WM (PR String))   

The function parses and converts a String that is in the format of a C-like printf expression into a Curry Expression that makes use of the Data.Format library.

Example call:
(parse showfun pos exp)
Parameters:
  • showfun : The operation to be applied to the formatted string result
  • pos : The position of the expression in the original file
  • exp : The expression which should be converted
Returns:
A String in Curry Syntax matching exp using the Data.Format library