# Define listings language with multiple keyword groups

I wanted to used syntax highlighting for a language unsupported by the listings package. Right now I have it almost working, but not completely. This is the MWE:

\documentclass{article}
\usepackage{listings,color}

% Define colors
\definecolor{codeBlue}{RGB}{0,0,255}
\definecolor{codeGreen}{RGB}{0,128,0}
\definecolor{codePurple}{RGB}{128,0,255}
\definecolor{codeOrange}{RGB}{255,128,128}
\definecolor{codePink}{RGB}{255,0,255}
\definecolor{codeGray}{rgb}{0.5,0.5,0.5}

% Define language style
\lstdefinestyle{apdl-modified}
{
extendedchars=true,
alsoletter={*},
alsoletter={'},
keywordstyle=\color{codeOrange},
keywordstyle=[2]\color{codePurple},
keywordstyle=[3]\color{codeBlue},
keywordstyle=[4]\color{codePink},
otherkeywords={
/solve,
/angle
},
keywords=[2]{
*abbr,
*dim
},
keywords=[3]{
m,
d
},
keywords=[4]{
',
-,
",
\%,
(,
),
,,
.,
:,
;,
?,
^,
~,
+,
<,
=,
>
},
sensitive=false, % keywords are not case-sensitive
morecomment=[l]{!}, % l is for line comment
numberstyle=\tiny\color{codeGray}
}

% Define Language with previously defined style
\lstdefinelanguage{APDL}{style=apdl-modified}

\begin{document}
\begin{lstlisting}[language=APDL]
*dim,m,table,2,1, ,time
m(1,0,1) = 0.0001
m(1,1,1) = 0
m(2,0,1) = time
m(2,1,1) = time*speed

d,p51x, , %m% , , , ,ux,, , , ,

/solve
\end{lstlisting}
\end{document}


Which gives me:

The second and the fourth keywordstyle are not working, and I do not understand why. Anyone an idea?

alsoletter={*} and alsoletter={'} must be in a single definition: alsoletter={*,'}