[m-rev.] Re: [m-dev.] '|' as an operator
David Overton
dmo at cs.mu.OZ.AU
Tue Feb 11 15:26:09 AEDT 2003
On Tue, Feb 11, 2003 at 03:09:47PM +1100, David Overton wrote:
> @@ -870,12 +875,18 @@
> :- pred parser__get_token(token, token_context,
> parser__state(Ops, T), parser__state(Ops, T)).
> :- mode parser__get_token(out, out, in, out) is semidet.
> -:- mode parser__get_token(in, in, out, in) is det.
>
> -parser__get_token(Token, Context,
> - parser__state(FileName, OpTable, VarSet, Tokens0, Names),
> - parser__state(FileName, OpTable, VarSet, Tokens, Names)) :-
> - Tokens0 = token_cons(Token, Context, Tokens).
> +parser__get_token(Token, Context, State0, State) :-
> + State0 ^ tokens = token_cons(Token0, Context, Tokens),
> + State = ( State0 ^ tokens := Tokens ),
> + (
> + State ^ in_list_context = no,
> + Token0 = ht_sep
> + ->
> + Token = name("|")
> + ;
> + Token = Token0
> + ).
>
> :- pred parser__unget_token(token, token_context,
> parser__state(Ops, T), parser__state(Ops, T)).
> @@ -883,7 +894,9 @@
> :- mode parser__unget_token(out, out, out, in) is semidet.
>
> parser__unget_token(Token, Context, ParseState0, ParseState) :-
> - parser__get_token(Token, Context, ParseState, ParseState0).
> + ParseState0 ^ tokens = Tokens,
> + ParseState = ( ParseState0 ^ tokens :=
> + token_cons(Token, Context, Tokens) ).
>
> :- pred parser__peek_token(token, parser__state(Ops, T), parser__state(Ops, T)).
> :- mode parser__peek_token(out, in, out) is semidet.
> @@ -896,7 +909,7 @@
> :- mode parser__peek_token(out, out, in, out) is semidet.
>
> parser__peek_token(Token, Context) -->
> - =(parser__state(_, _, _, Tokens, _)),
> + Tokens =^ tokens,
> { Tokens = token_cons(Token, Context, _) }.
>
Forgot about peek_token. Here is a relative diff:
diff -u parser.m parser.m
--- parser.m 11 Feb 2003 03:53:39 -0000
+++ parser.m 11 Feb 2003 04:23:03 -0000
@@ -876,17 +876,25 @@
parser__state(Ops, T), parser__state(Ops, T)).
:- mode parser__get_token(out, out, in, out) is semidet.
-parser__get_token(Token, Context, State0, State) :-
- State0 ^ tokens = token_cons(Token0, Context, Tokens),
- State = ( State0 ^ tokens := Tokens ),
- (
- State ^ in_list_context = no,
+parser__get_token(Token, Context) -->
+ token_cons(Token0, Context, Tokens) =^ tokens,
+ ^tokens := Tokens,
+ check_for_list_context(Token0, Token).
+
+:- pred check_for_list_context(token, token, parser__state(Ops, T),
+ parser__state(Ops, T)).
+:- mode check_for_list_context(in, out, in, out) is det.
+
+check_for_list_context(Token0, Token) -->
+ InListContext =^ in_list_context,
+ {
+ InListContext = no,
Token0 = ht_sep
->
Token = name("|")
;
Token = Token0
- ).
+ }.
:- pred parser__unget_token(token, token_context,
parser__state(Ops, T), parser__state(Ops, T)).
@@ -910,7 +918,8 @@
parser__peek_token(Token, Context) -->
Tokens =^ tokens,
- { Tokens = token_cons(Token, Context, _) }.
+ { Tokens = token_cons(Token0, Context, _) },
+ check_for_list_context(Token0, Token).
%-----------------------------------------------------------------------------%
--
David Overton Uni of Melbourne +61 3 8344 1354
dmo at cs.mu.oz.au Monash Uni (Clayton) +61 3 9905 5779
http://www.cs.mu.oz.au/~dmo Mobile Phone +61 4 0337 4393
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list