如果文本被双引号括起来,则不将其识别为关键字

如果文本被双引号括起来,则不将其识别为关键字

我正在尝试为 C# 定义语言格式,但遇到了问题。虽然它在大多数情况下运行良好,但我不希望引号中的文本被描述为关键字。这是我目前的语言定义:

\definecolor{commentcolor}{RGB}{87,166,74}
\lstdefinelanguage{CSharp} {keywords=[1]{abstract, event, new, struct,
                as, explicit, null, switch,
                base, extern, object, this,
                bool, false, operator, throw,
                break, finally, out, true,
                byte, fixed, override, try,
                case, float, params, typeof,
                catch, for, private, uint,
                char, foreach, protected, ulong,
                checked, goto, public, unchecked,
                class, if, readonly, unsafe,
                const, implicit, ref, ushort,
                continue, in, return, using,
                decimal, int, sbyte, virtual,
                default, interface, sealed, volatile,
                delegate, internal, short, void,
                do, is, sizeof, while,
                double, lock, stackalloc,
                else, long, static,
                enum, namespace, string},

                keywordstyle=[1]\color{blue},
                commentstyle=\color{commentcolor},
                morecomment=[l]{//}, morecomment=[s]{/*}{*/},
                showstringspaces=false, showspaces=false,
                showtabs=true, extendedchars=true
                }

以下是一些测试输入:Console.WriteLine("Please enter in a string.");

在这种情况下,我不希望“in”和“string”以蓝色突出显示。

相关内容