[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cc-mode help - how to support literal strings in C# syntax?
From: |
dino chiesa |
Subject: |
cc-mode help - how to support literal strings in C# syntax? |
Date: |
Mon, 28 Dec 2009 17:51:52 -0800 |
I'm improving the csharp-mode from http://www.emacswiki.org/emacs/CSharpMode .
In case you're not aware, it's derived from cc-mode, something like Java, but
with a few different syntactic quirks.
The existing csharp-mode.el is pretty good.
There were a couple things I fixed:
- #if/else/endif was not being properly recognized,
was indenting and fontifying strangely
- a struct was not being treated as a class - indenting inside the block was
broken.
- class definitions that derived from other classes were not being parsed as a
class.
These are all minor things I was able to resolve by using c-lang-defconst on
various constants: c-typeless-decl-kwds, c-other-block-decl-kwds,
c-cpp-message-directives, c-cpp-expr-directives, c-colon-type-list-kwds,
c-symbol-chars, c-block-prefix-disallowed-chars, and a few others.
There's one think I haven't been able to resolve. In C# syntax, strings can be
specified as they are in C - surrounded by quotes. There's also a special form
of literal string that begins with @, n which all characters in the string are
to be treated as "escaped". In other words
@"\usr\bin" == "\\usr\\bin"
The problem happens when the literal string ends in a slash. Eg @"\usr\bin\"
The cc-mode syntax engine sees that as an unterminated string, the \" is an
escaped double-quote. On the other hand the C# compiler sees it as a string of
9 chars.
Because it isn't parsed correctly, the fontification and indenting is wrong
after a @-prefixed string that ends in a slash.
How can I get the prefixed strings to be treated correctly?
Defining a special c-in-literal seems not to be it. That function uses
parse-partial-sexp , which apparently determines if the point is within a
string or not.
Modifying the syntax table to insert @ as a special prefix is also not it.
Any suggestions?
address@hidden
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141665/direct/01/