[m-rev.] for review: make parsing tail recursive
pbone at csse.unimelb.edu.au
Wed May 7 22:16:21 AEST 2008
On 07/05/2008, at 2:41 PM, Zoltan Somogyi wrote:
> 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",
>> " (", 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-
> switch arms.
I thought that before the multi-cons-id switch arms it was still
possible to write:
( Var = fn1
; Var = fn2 ),
and goal would be duplicated by the complier, but the human didn't
need to duplicate goal, and the compiler would correctly understand
the determinism of the entire switch.
So that the multi-cons-id switch arms was an optimization.
Did I misunderstand?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 186 bytes
Desc: This is a digitally signed message part
More information about the reviews