[ANN] ColoredLLCodes: syntax highlighting for `code_llvm` and `code_native`

Hi all,

I’m happy to announce ColoredLLCodes.jl, a syntax highlighter for code_llvm and code_native 100% in Julia.
All you have to do is install and load the package.

This package started from Why are `code_llvm` and `code_native` not displayed in color?. I made a feature request (proposal) in the JuliaLang/julia repository (Issue #36634), and I submitted a PR to port this highlighting feature to InteractiveUtils (PR #36984).
I’m neutral about whether or not the syntax highlighting feature should be in InteractiveUtils, and I think both opinions are reasonable. So, I would be grateful for your opinion on (in) the PR.

FYI, this package is based on a heuristic approach, not the formal grammar of LLVM IR or assembly languages. I’m not sure about the quality of highlighting for LLVM IR, since I prefer @code_native over @code_llvm. Also, I do not have a machine with new instruction sets such as Intel AVX-512, ARM SVE. So if you find a parsing failure, feel free to submit an issue to the ColoredLLCodes repository.

19 Likes

PR #36984 was merged.
You can customize the color scheme on the nightly build as shown below. Note that there is no public API for customization at the moment.

InteractiveUtils.llstyle[:default]     = (false, :normal)
InteractiveUtils.llstyle[:comment]     = (false, 101)
InteractiveUtils.llstyle[:label]       = (false, :normal)
InteractiveUtils.llstyle[:instruction] = ( true, 197)
InteractiveUtils.llstyle[:type]        = (false, 81)
InteractiveUtils.llstyle[:number]      = (false, 141)
InteractiveUtils.llstyle[:bracket]     = (false, :normal)
InteractiveUtils.llstyle[:variable]    = (false, 208)
InteractiveUtils.llstyle[:keyword]     = (false, 197)
InteractiveUtils.llstyle[:funcname]    = (false, 208)
7 Likes