[m-dev.] Proposal: parsing module for the library.

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Jan 19 18:15:32 AEDT 2009


On Fri, 16 Jan 2009, Ralph Becket wrote:

...

>     % Parse a float literal matching [-][0-9]+[.][0-9]+([Ee][-][0-9]+)?
> +    % followed by any whitespace.
>     %
> -:- pred float_literal(src::in)
> -        : parser(float) `with_inst` parser.
> +:- pred float_literal(src::in, float::out,
> +        ps::in, ps::out) is semidet.

You should return the float literal as a string rather than a float.
The implicit conversion you are preforming while parsing the float may
not be what the user requires.

>
> -    % Parse an int literal matching [-][0-9]+, not followed by [.][0-9]+.
> +    % Parse an int literal matching [-][0-9]+, not followed by [.][0-9]+
> +    % followed by any whitespace.
>     %
> -:- pred int_literal(src::in)
> -        : parser(int) `with_inst` parser.
> +:- pred int_literal(src::in, int::out,
> +        ps::in, ps::out) is semidet.

You would be better off returning ints as either strings or arbitrary
precision integers, i.e. the integer type, rather than as machine sized
ints.

Julien.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list