unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* cc-mode help - how to support literal strings in C# syntax?
@ 2009-12-29  1:51 dino chiesa
  2009-12-29 10:43 ` Andreas Roehler
  0 siblings, 1 reply; 23+ messages in thread
From: dino chiesa @ 2009-12-29  1:51 UTC (permalink / raw)
  To: emacs-devel


 
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? 
 
dpchiesa@hotmail.com
  		 	   		  
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141665/direct/01/



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2010-01-01 16:04 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-29  1:51 cc-mode help - how to support literal strings in C# syntax? dino chiesa
2009-12-29 10:43 ` Andreas Roehler
2009-12-30  4:40   ` dino chiesa
2010-01-01 11:43     ` Andreas Roehler
2010-01-01 16:04     ` Andreas Roehler
2009-12-30  5:01   ` first-class support for csharp in cc-mode.el dino chiesa
2009-12-30  6:17     ` Miles Bader
2009-12-30  7:18       ` dino chiesa
2009-12-30 11:09         ` Miles Bader
2009-12-30 15:00           ` dino chiesa
2009-12-30 15:19     ` Alan Mackenzie
2009-12-30 15:39       ` Stefan Monnier
2009-12-30 16:29         ` dino chiesa
2009-12-30 16:57           ` Stefan Monnier
2009-12-30 21:01           ` Alan Mackenzie
2009-12-30 21:03             ` dino chiesa
2009-12-31  2:44               ` Miles Bader
2009-12-31  2:58                 ` Jason Rumney
2009-12-31  3:08                 ` Deniz Dogan
2009-12-31  3:18                   ` dino chiesa
2009-12-31  3:13                 ` dino chiesa
2009-12-31 11:43           ` Vagn Johansen
2009-12-30 20:19         ` Alan Mackenzie

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).