[m-rev.] for review: make parsing tail recursive
Zoltan Somogyi
zs at csse.unimelb.edu.au
Wed May 7 14:41:36 AEST 2008
On 07-May-2008, Paul Bone <pbone at csse.unimelb.edu.au> wrote:
> ( Token = io_error(IO_Error) ->
> io.error_message(IO_Error, IO_ErrorMessage),
> string.append("I/O error: ", IO_ErrorMessage, Message)
> ; Token = junk(Char) ->
> char.to_int(Char, Code),
> string.int_to_base_string(Code, 10, Decimal),
> string.int_to_base_string(Code, 16, Hex),
> string.append_list(["Syntax error: Illegal character 0x", Hex,
> " (", Decimal, ") in input"], Message)
> ; Token = error(ErrorMessage) ->
> string.append("Syntax error: ", ErrorMessage, Message)
> ;
> check_for_bad_token(Tokens, Message, LineNum)
> ^^^^^^^ It's unified here too,
> when LineNum is unified here it probably shouldn't be unified against
> the line number in the first argument.
> ).
>
> Perhaps using a switch over all the function symbols that Token may be can help as well.
Yes, that would be a good idea. The reason why didn't do it originally
is that it would have required duplicating the code for the "everything else"
case, but that has not been a concern since I implemented multi-cons-id
switch arms.
Zoltan.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list