I would like to highlight several keywords with an alphabetic and a numeric part with different color.
My problem is the number of keywords can become huge from r0 to r191 for example. And I have several keywords. Is there a way to escape to write all the possible keywords ?
Is there a way to define left delimiter just for a word and not for a line ?
The sample bellow do exactly what I want but with writing all the keywords (example keywords[2] and keywords[3])...
\documentclass[a4paper, 12pt,english]{article}
\usepackage{color}
\definecolor{gray}{rgb}{0.4,0.4,0.4}
\definecolor{darkgreen}{rgb}{0.0,0.4,0.0}
\definecolor{darkred}{rgb}{0.6,0.0,0.0}
\usepackage{listings}
\lstdefinelanguage{mylanguage}
{keywords=[1]{add,sub,test},
keywords=[2]{r0,r1,r2},
keywords=[3]{p00,p01,p10,p11},
moredelim=[s][\footnotesize\textit]{<}{>},
keywordstyle=[1]\normalsize\color{gray}\bfseries\ttfamily,
keywordstyle=[2]\color{darkgreen},
keywordstyle=[3]\color{darkred}}
\begin{document}
\lstset{numbers=left, numberstyle=\tiny, stepnumber=1, numbersep=5pt,language=mylanguage}
\begin{lstlisting}
p00 add r0 , r1 , r2
\end{lstlisting}
\end{document}
listingssupports assembler, although only specific dialects. It would be useful to see how they define it for themselves; the structure is pretty consistent. I'm going to research where it defines the languages (grepto the rescue!), but two heads are better than one, no? – Sean Allred Feb 26 at 16:00listing's source code (search "Assembler") reveals that they do it the dumb way, too. There is probably a way to script this, but it won't use thelistingspackage itself. Your best bet is some sort of text generating command, perhaps (depending on how\lstdefinelanguageworks). – Sean Allred Feb 26 at 16:04