Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent accidental amalgamation of graphic token chars in output #2714

Merged
merged 2 commits into from
Dec 21, 2024

Conversation

triska
Copy link
Contributor

@triska triska commented Dec 17, 2024

This addresses #2713. Many thanks to @notoria for reporting this excellent case!

Example:

?- portray_clause(A = @).
A= @ .
   true.

At other positions the now inserted space is unnecessary, as in:

?- portray_clause((head:- @,b)).
head :-
   @ ,
   b.
   true.

The toplevel has a similar issue:

?- C = # ; false.
   C = # |<-- cursor is here; redundant space after #

There may be a way to solve this issue for all cases like this.

This addresses mthom#2713. Many thanks to @notoria for reporting this
excellent case!

Example:

    ?- portray_clause(A = @).
    A= @ .
       true.

At other positions the now inserted space is unnecessary, as in:

    ?- portray_clause((head:- @,b)).
    head :-
       @ ,
       b.
       true.

The toplevel has a similar issue:

    ?- C = # ; false.
       C = # |<-- cursor is here; redundant space after #

There may be a way to solve this issue for all cases like this.
@notoria
Copy link
Contributor

notoria commented Dec 17, 2024

A way to avoid the extra space is to have a state to track the last character. This solves the issue though.

Examples:

    ?- portray_clause(((+) :- a=b,(-))).
    (+) :-
       a=b,
       (-).
       true.

    ?- portray_clause((a :- (b :- c))).
    a :-
       (b:-c).
       true.

This addresses mthom#2715.

Currently, more round brackets than needed are emitted. Ideally, a
better approach to solve the issue here and also in toplevel.pl is
found in the future.
@mthom mthom merged commit b794383 into mthom:master Dec 21, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants