Skip to content

Dylan: add operator escapes and string hex escapes#2250

Merged
jneen merged 5 commits intomainfrom
feature.dylan-errata
Mar 12, 2026
Merged

Dylan: add operator escapes and string hex escapes#2250
jneen merged 5 commits intomainfrom
feature.dylan-errata

Conversation

@jneen
Copy link
Member

@jneen jneen commented Mar 11, 2026

See discussion at #2248, cc @pedro-w

image

@pedro-w
Copy link
Contributor

pedro-w commented Mar 11, 2026

I will check ASAP!

@jneen
Copy link
Member Author

jneen commented Mar 11, 2026

Added an image of the rendered text.

@jneen
Copy link
Member Author

jneen commented Mar 11, 2026

Should inline be covered here as well? It's always a bit hard in a super dynamic-syntax language like dylan to know where to start and stop with keyword highlighting.

@pedro-w
Copy link
Contributor

pedro-w commented Mar 11, 2026

The modifiers between define and method can be any non-reserved word. It's a personal preference but I'd say it's useful to keep them as they are in a contrasting colour rather than matching the formatting of define, even if its not so aesthetically pleasing.

@pedro-w
Copy link
Contributor

pedro-w commented Mar 11, 2026

Looking through dylan's own codebase as it contains some hairy stuff...

https://github.com/dylan-lang/opendylan/blob/85fc782bf2b1390929bdb9fc98f88e5e55d7a742/sources/io/format-condition.dylan#L9-L20

define sideways method print-object (c :: <condition>, s :: <stream>) => ()
  let message = condition-to-string(c);
  if (*print-escape?* | ~message)
    printing-object (c, s)
      if (message)
        format(s, ": %s", message)
      end
    end
  else
    write(s, message)
  end
end method print-object;

Here the ~ is not matched. (it's a "UNARY-OPERATOR" in the DRM, it means "logical not")
Screenshot 2026-03-11 at 20 05 17

@pedro-w
Copy link
Contributor

pedro-w commented Mar 11, 2026

% git diff
diff --git a/lib/rouge/lexers/dylan.rb b/lib/rouge/lexers/dylan.rb
index d019229a..0d0208b6 100644
--- a/lib/rouge/lexers/dylan.rb
+++ b/lib/rouge/lexers/dylan.rb
@@ -71,7 +71,7 @@ module Rouge
         rule %r/#x[0-9a-f]+/i, Literal::Number::Hex
 
         # Operators and punctuation
-        rule %r/::|=>|#[(\[#]|[.][.][.]|[(),.;\[\]{}=?]/, Punctuation
+        rule %r/~|::|=>|#[(\[#]|[.][.][.]|[(),.;\[\]{}=?]/, Punctuation
 
         word_re = %r([\w!&*<>|^\$%@][\w!&*<>|^\$%@=/?~+-]*|[+-])

Maybe? I should leave it to the professionals 😉

@jneen
Copy link
Member Author

jneen commented Mar 11, 2026

I put it in word_re instead, as it seems like it's classified as a word operator, presuming you can also do \~ to refer to it as a symbol.

@jneen jneen added this pull request to the merge queue Mar 12, 2026
Merged via the queue into main with commit 50971f5 Mar 12, 2026
10 checks passed
@jneen jneen deleted the feature.dylan-errata branch March 12, 2026 14:18
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.

2 participants