From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Roehler Newsgroups: gmane.emacs.devel Subject: Re: cc-mode help - how to support literal strings in C# syntax? Date: Tue, 29 Dec 2009 11:43:58 +0100 Message-ID: <4B39DD6E.1070204@online.de> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1262083444 14752 80.91.229.12 (29 Dec 2009 10:44:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 29 Dec 2009 10:44:04 +0000 (UTC) Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org To: dino chiesa Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 29 11:43:56 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NPZYR-0002Bf-Pu for ged-emacs-devel@m.gmane.org; Tue, 29 Dec 2009 11:43:56 +0100 Original-Received: from localhost ([127.0.0.1]:51132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NPZYS-0003hx-1W for ged-emacs-devel@m.gmane.org; Tue, 29 Dec 2009 05:43:56 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NPZYJ-0003fi-Pa for emacs-devel@gnu.org; Tue, 29 Dec 2009 05:43:47 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NPZYE-0003bZ-P4 for emacs-devel@gnu.org; Tue, 29 Dec 2009 05:43:46 -0500 Original-Received: from [199.232.76.173] (port=34307 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NPZYE-0003bJ-Dk for emacs-devel@gnu.org; Tue, 29 Dec 2009 05:43:42 -0500 Original-Received: from moutng.kundenserver.de ([212.227.17.10]:54760) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NPZY8-0001Jm-UY; Tue, 29 Dec 2009 05:43:37 -0500 Original-Received: from [192.168.178.27] (p54BE8D60.dip0.t-ipconnect.de [84.190.141.96]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0M9NCY-1NGFMQ39wM-00CBT3; Tue, 29 Dec 2009 11:43:33 +0100 User-Agent: Thunderbird 2.0.0.19 (X11/20081227) In-Reply-To: X-Provags-ID: V01U2FsdGVkX18v8KwS9lCBLC8Sj0V+i25saEY8cGZpKLk2kD9 LW/6qLvCDPRvZwMjxvIeiX1JJ7glC8E67cTOyNEctQPkn9TWE6 aIkB07b/z7xlBc69PlOMBFYcYJCn1wAudZ+4dprjug= X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:118927 Archived-At: 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? > > dpchiesa@hotmail.com > > _________________________________________________________________ > Hotmail: Trusted email with powerful SPAM protection. > http://clk.atdmt.com/GBL/go/177141665/direct/01/ > >