Permalink
Browse files

Update structured message printing to handle errors in token lists

When using structured message printing, output non-recognized tokens as-is. Also, intercept and ignore partial lists of tokens and tokens that are variables.
  • Loading branch information...
1 parent a78cc39 commit 271910c048f0e482bfae30ea6a88a24737f5bfea @pmoura pmoura committed Oct 6, 2012
Showing with 16 additions and 1 deletion.
  1. +4 −0 RELEASE_NOTES.md
  2. +12 −1 core/core.pl
View
@@ -31,6 +31,10 @@ RELEASE NOTES
Logtalk compiler and runtime
----------------------------
+* IMPROVED: When using structured message printing, output non-recognized
+tokens as-is. Also, intercept and ignore partial lists of tokens and tokens
+that are variables.
+
* IMPROVED: Optimized the implementation of the `expand_goal/2` built-in
method by avoiding repeated lookups of the declaration of the user-defined
`goal_expansion/2` method.
View
@@ -4518,18 +4518,29 @@
).
+% if the list of tokens unifies with (-), assume it's a variable and ignore it
+
+'$lgt_print_message_tokens'((-), _, _, _).
+
'$lgt_print_message_tokens'([], _, _, _).
'$lgt_print_message_tokens'([Token| Tokens], Stream, Prefix, ExCtx) :-
( '$lgt_logtalk.print_message_token'(Stream, Token, ExCtx) ->
% token printing intercepted by user-defined code
true
; % no user-defined token printing; use Logtalk default
- '$lgt_print_message_token'(Token, Tokens, Stream, Prefix)
+ '$lgt_print_message_token'(Token, Tokens, Stream, Prefix) ->
+ true
+ ; % unsupported token
+ writeq(Stream, Token)
),
'$lgt_print_message_tokens'(Tokens, Stream, Prefix, ExCtx).
+% if a token unifies with (-), assume it's a variable and ignore it
+
+'$lgt_print_message_token'((-), _, _, _).
+
'$lgt_print_message_token'(at_same_line, _, _, _).
'$lgt_print_message_token'(nl, Tokens, Stream, Prefix) :-

0 comments on commit 271910c

Please sign in to comment.