4

I use a preprocesser to process some code before my verilog compiler.
All preprocesser words start with the ` character

Example:

`pp_if

unfortunately its possible to define your own preprocessor words. The only thing that is known is that the word starts with `.

How can I highlight any word starting with `?

Qrrbrbirlbel
  • 119,821
Rasmus
  • 219

1 Answers1

3

You can adapt the solution from Listings language definition keyword suffixes and use the keywordsprefix=<prefix> to specify that anything beginning with tick is considered a keyword:

enter image description here

Notes:

  • To obtain the a more reasonable display of leading tick, I added upquote=true which requires the textcomp package. There may be a better way to handle the issue of displaying the `.
  • There are limitations of using keywordsprefix=<prefix> which are noted in Listings language definition keyword suffixes.

Code:

\documentclass{article}
\usepackage{listings}%
\usepackage{xcolor}
\usepackage{textcomp}

\lstset{% backgroundcolor=\color{yellow!20},% basicstyle=\small\ttfamily,% numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt,% keywordstyle=\color{blue}\bfseries, language=Java, keywordsprefix=`, upquote=true, }%

\begin{document} \begin{lstlisting} pp_if pp rr pp_ifmm zz xx `MM PP abc def ghi \end{lstlisting} \end{document}

Peter Grill
  • 223,288