Skip to content

Instantly share code, notes, and snippets.

@leptos-null
Last active January 21, 2022 09:19
Show Gist options
  • Save leptos-null/661a26cddc7221b9a3df4569dfeac978 to your computer and use it in GitHub Desktop.
Save leptos-null/661a26cddc7221b9a3df4569dfeac978 to your computer and use it in GitHub Desktop.
LLVM syntax highlighting for nano
## LLVM syntax highlighting for nano by Leptos
## Based off the official nano C/C++ template
syntax ll "\.ll$"
magic "LLVM source"
comment ";"
# all numeral literals
color brightcyan "-?[0-9]*"
# integer identifers
color green "i[0-9][0-9]*"
# Labels.
color brightmagenta "^[[:space:]]*[-a-zA-Z$._][-a-zA-Z$._0-9]+:[[:space:]]*"
color green "\<(ret|void|float|double)\>"
## https://llvm.org/docs/LangRef.html#identifiers
# changed from original regex to support generated values
color magenta "[%@][-a-zA-Z$._0-9]*"
color red "\<(define|declare)\>"
## https://llvm.org/docs/LangRef.html#linkage-types
color red "\<(private|internal|available_externally|linkonce|weak|common|appending|extern_weak|linkonce_odr|weak_odr|external)\>"
## https://llvm.org/docs/LangRef.html#function-attributes
color red "\<(alignstack|allocsize|alwaysinline|builtin|cold|convergent|inaccessiblememonly|inaccessiblemem_or_argmemonly|inlinehint|jumptable|minsize|naked|no-jump-tables)\>"
color red "\<(nobuiltinnoduplicate|noimplicitfloat|noinline|nonlazybind|noredzone|noreturn|norecurse|nounwind|null-pointer-is-valid|optforfuzzing|optnone|optsize|patchable-function)\>"
color red "\<(probe-stack|readnone|readonly|stack-probe-size|no-stack-arg-probe|writeonly|argmemonly|returns_twice|safestack|sanitize_address|sanitize_memory|sanitize_thread|sanitize_hwaddress)\>"
color red "\<(speculative_load_hardening|speculatable|ssp|sspreq|sspstrong|strictfp|thunk|uwtable|nocf_check|shadowcallstack)\>"
## https://llvm.org/docs/LangRef.html#parameter-attributes
color red "\<(zeroext|signext|inreg|byval|inalloca|sret|align|noalias|nocapture|nest|returned|nonnull|dereferenceable|dereferenceable_or_null|swiftself|swifterror)\>"
# Strings. In general you will want your strings and comments to come last,
# because highlighting rules are applied in the order they are read in.
color brightyellow ""([^"]|\\")*"" "<[^[:blank:]=]*>"
# Comments.
color brightblue ";.*"
# Trailing whitespace.
color ,green "[[:space:]]+$"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment