[m-rev.] diff: avoid warning in extras/lex

Peter Wang novalazy at gmail.com
Thu Aug 14 13:13:25 AEST 2008


Branches: main

extras/lex/lex.m:
extras/lex/regex.m:
	Don't export concrete insts for abstract types since the compiler now
	warns about that.

diff --git a/extras/lex/lex.m b/extras/lex/lex.m
index dc89a54..d3c398b 100644
--- a/extras/lex/lex.m
+++ b/extras/lex/lex.m
@@ -42,8 +42,6 @@
     ---> (ground - Inst).
 
 :- type lexer(Token, Source).
-:- inst lexer
-    ---> lexer(ground, ignore_pred, read_pred).
 
 :- type lexer_state(Token, Source).
 
@@ -154,7 +152,7 @@
     % of the list of lexemes is returned.
     %
 :- func init(list(lexeme(Tok)), read_pred(Src)) = lexer(Tok, Src).
-:- mode init(in, in(read_pred)) = out(lexer) is det.
+:- mode init(in, in(read_pred)) = out is det.
 
     % Construct a lexer from which we can generate running
     % instances. If we construct a lexer with init/4, we
@@ -166,7 +164,7 @@
     %
 :- func init(list(lexeme(Tok)), read_pred(Src), ignore_pred(Tok)) =
             lexer(Tok, Src).
-:- mode init(in, in(read_pred), in(ignore_pred)) = out(lexer) is det.
+:- mode init(in, in(read_pred), in(ignore_pred)) = out is det.
 
     % Handy read predicates.
     %
@@ -185,7 +183,7 @@
     % lexing.
     %
 :- func start(lexer(Tok, Src), Src) = lexer_state(Tok, Src).
-:- mode start(in(lexer), di) = uo is det.
+:- mode start(in, di) = uo is det.
 
     % Read the next token from the input stream.
     %
@@ -255,6 +253,9 @@
                 lex_buf_read_pred       :: read_pred(Source)
             ).
 
+:- inst lexer
+    --->    lexer(ground, ignore_pred, read_pred).
+
 :- type lexer_instance(Token, Source)
     --->    lexer_instance(
                 init_lexemes            :: list(live_lexeme(Token)),
@@ -319,10 +320,21 @@ init(Lexemes, BufReadPred, IgnorePred) =
 
 %-----------------------------------------------------------------------------%
 
-start(Lexer, Src) = State :-
+start(Lexer0, Src) = State :-
+    Lexer = lexer_inst_cast(Lexer0),
     init_lexer_instance(Lexer, Instance, Buf),
     State = args_lexer_state(Instance, Buf, Src).
 
+:- func lexer_inst_cast(lexer(Tok, Src)::in) = (lexer(Tok, Src)::out(lexer))
+    is det.
+
+:- pragma foreign_proc("C",
+    lexer_inst_cast(Lexer0::in) = (Lexer::out(lexer)),
+    [will_not_call_mercury, promise_pure, thread_safe],
+"
+    Lexer = Lexer0;
+").
+
 %-----------------------------------------------------------------------------%
 
 :- pred init_lexer_instance(lexer(Tok, Src), lexer_instance(Tok, Src), buf).
diff --git a/extras/lex/regex.m b/extras/lex/regex.m
index f3f35fa..3ad0bdb 100644
--- a/extras/lex/regex.m
+++ b/extras/lex/regex.m
@@ -39,7 +39,7 @@
     % The type of (compiled) regular expressions.
     %
 :- type regex.
-:- inst regex == lexer.
+:- inst regex == ground.
 
     % A function for converting a POSIX style regex string to a regex
     % suitable for the string matching operations provided in this


--------------------------------------------------------------------------
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