:- module bug.

:- interface.

:- import_module io.

:- pred main(io, io).
:- mode main(di, uo) is det.

%--------------------------------------------------------------------%

:- implementation.

:- import_module list, assoc_list, pair, maybe, string, int.

:- type tokens == assoc_list(int, token).

:- type token
    --->    (',')
    ;	    symbol(string)
    ;	    eof.

main(!IO) :-
    write_string("Hello, world!\n", !IO).

:- type value
    --->    value(int, value0).

:- type value0
    --->    value_sym(string).

:- type parse_res(T)
    --->    ok(T)
    ;	    error.

:- pred parse_enum0(int, assoc_list(string, maybe(value)), parse_res(value), tokens, tokens).
:- mode parse_enum0(in, in, out, in, out) is det.

parse_enum0(L, Vs0, Res, !Ts) :-
    ( if next(_L2-symbol(Sym), !Ts) then
	( if next(_L3-(','), !Ts) then
	    Vs = [Sym-no|Vs0],
	    parse_enum0(L, Vs, Res, !Ts)
	else
	    Res = error
	)
    else
	Res = error
    ).

:- pred next(pair(int, token), tokens, tokens).
:- mode next(out, in, out) is det.

next(L-T, [L-T|Ts], Ts).
next(0-eof, [], []).

