[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cc-mode help - how to support literal strings in C# syntax?
From: |
Andreas Roehler |
Subject: |
Re: cc-mode help - how to support literal strings in C# syntax? |
Date: |
Tue, 29 Dec 2009 11:43:58 +0100 |
User-agent: |
Thunderbird 2.0.0.19 (X11/20081227) |
dino chiesa wrote:
>
> 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?
>
Made a beg-end.el for this kind of parsings.
Would try it with your problem.
Feel free to send me your mode as far its done.
Maybe some larger test-code too.
Should you want to try it yourself, get beg-end.el at
https://code.launchpad.net/s-x-emacs-werkstatt/
Andreas
>
> 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/
>
>
- cc-mode help - how to support literal strings in C# syntax?, dino chiesa, 2009/12/28
- Re: cc-mode help - how to support literal strings in C# syntax?,
Andreas Roehler <=
- Re: first-class support for csharp in cc-mode.el, Alan Mackenzie, 2009/12/30
- Re: first-class support for csharp in cc-mode.el, Stefan Monnier, 2009/12/30
- RE: first-class support for csharp in cc-mode.el, dino chiesa, 2009/12/30
- Re: first-class support for csharp in cc-mode.el, Stefan Monnier, 2009/12/30