0

I am using the listings package in order to typeset JVMIS code in LaTeX. Is there a chance to highlight the labels in such code? At the moment I have with the default definition JVMIS

Lab: 
 iconst_2 
 iconst_3 
 iadd

where the keywords (iconst, iadd, etc) are highlighted nicely, but the Lab: is not. The syntax of labels is as usual in assembly "some_string:". Is there a way to tweak the language definition so that labels are highlighted also (preferably in a different colour)?

Thanks a lot!

Update Sorry, a code sample would be

\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{codegreen}{rgb}{0.25,0.5,0.35}    % comments
\definecolor{codepurple}{rgb}{0.5,0,0.35}      % keywords
\lstset{basicstyle=\ttfamily,
    keywordstyle=\color{codepurple},
    stringstyle=\color{codegreen}
   }
\begin{document}
\begin{lstlisting}[language=JVMIS]
Label:
  ldc 3
  iconst_3
  iadd
\end{lstlisting}
\end{document}

This produces

enter image description here

where Label is not highlighted.

urbanc
  • 1
  • Related: https://tex.stackexchange.com/questions/402135/listings-highlight-part-of-a-delimited-word-starting-with-space – Marijn Feb 03 '20 at 12:02
  • From there: you can define a regular expression to highlight patterns of letters followed by :. – Marijn Feb 03 '20 at 12:04

0 Answers0