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

Format escape sequences %c and %r are confusing #4087

Open
tothtamas28 opened this issue Mar 8, 2024 · 0 comments
Open

Format escape sequences %c and %r are confusing #4087

tothtamas28 opened this issue Mar 8, 2024 · 0 comments
Labels
quirks Weird K behaviours and features

Comments

@tothtamas28
Copy link
Contributor

There seems to be little reason to use these escape sequences directly, as for a terminal "foo", %i is implicitly %cfoo%r, i.e. coloring is handled automatically.

Preliminaries

One situation in which it can be useful though is to give some color to otherwise uncolored non-terminals.

module COLORS
    syntax Foo ::= "foo" Bar "qux" [symbol(foo), format(%1 %c%2%r %3), colors(green, purple, yellow)]
    syntax Bar ::= "bar" "baz"     [symbol(bar)]
endmodule\

Here, a reasonable, modular behavior would be to either

  1. override all coloring for Bar to purple, or
  2. override the default color for Bar to purple, or
  3. do nothing.

The problem

However, in the above example

echo 'Lblfoo{}(Lblbar{}())' | kprint colors-kompiled /dev/stdin

produces

kprint-color

In cases (1) and (2) bar baz should be purple, and in (3) it should be white.

Possible solutions

  1. Remove the special meaning of these escape sequences. This either requires dropping them from KORE as well, or some extra processing in ModuleToKore (basically replace %{c,r} by {c,r}).
  2. Come up with a more modular semantics for coloring.
@tothtamas28 tothtamas28 added the quirks Weird K behaviours and features label Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
quirks Weird K behaviours and features
Projects
None yet
Development

No branches or pull requests

1 participant