From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Deniz Dogan Newsgroups: gmane.emacs.help Subject: Re: Own programming language mode - syntax highlighting Date: Tue, 14 Sep 2010 13:15:33 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1284462993 16203 80.91.229.12 (14 Sep 2010 11:16:33 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 14 Sep 2010 11:16:33 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 14 13:16:31 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OvTV1-0006Fy-9i for geh-help-gnu-emacs@m.gmane.org; Tue, 14 Sep 2010 13:16:31 +0200 Original-Received: from localhost ([127.0.0.1]:33016 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvTV0-0002Su-Ie for geh-help-gnu-emacs@m.gmane.org; Tue, 14 Sep 2010 07:16:30 -0400 Original-Received: from [140.186.70.92] (port=53507 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvTUb-0002Sg-6L for help-gnu-emacs@gnu.org; Tue, 14 Sep 2010 07:16:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvTUa-00014L-1m for help-gnu-emacs@gnu.org; Tue, 14 Sep 2010 07:16:05 -0400 Original-Received: from mail-vw0-f41.google.com ([209.85.212.41]:64546) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvTUZ-00014F-Vv for help-gnu-emacs@gnu.org; Tue, 14 Sep 2010 07:16:04 -0400 Original-Received: by vws16 with SMTP id 16so7177967vws.0 for ; Tue, 14 Sep 2010 04:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=/4UtWDJ4PyD8Qe41FMPSuC9hus1qDP12xks18JaEWu8=; b=hSGf160COdA3D4YGD9H9EVKZ8li6bumV+Meg63YtK1LaxkE0mU+WWOugT+4H7+tFi3 dQ5sEweLZAenW7597fDA9Bl6et8Xna/AAwZIhFm810eXRX8x2MzWfH7NZjYrNqDO4gOH P4MeZzosTXQbjgo/LNf3338qQsRwPdVCEoptE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=COIUkSCUNCUILL4+7d/m/lAGs8MlJQuW8YiuD5sn8QbumMAbk8zhj7rfn1nItYJg/O bAgzzwTJEv2M9v2+eUqHGG6zEbsypis313XO+10fMLEkM2e9/LH/fjwC2xwU0jjeVMoL PeIQKN7VFJ9sV6l8a5woRXv3WV1hoe9N/CQvA= Original-Received: by 10.220.50.30 with SMTP id x30mr484111vcf.12.1284462963212; Tue, 14 Sep 2010 04:16:03 -0700 (PDT) Original-Received: by 10.220.202.70 with HTTP; Tue, 14 Sep 2010 04:15:33 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:74958 Archived-At: 2010/9/14 Gary : > Following Xah Lee's excellent tutorial, I have been able to get the > basics done - syntax highlighting, indentation, and so on. What I am > missing is a small part of the syntax highlighting related to variables. > > Declarations work fine - for example > int x = 0 > is correctly highlighted. What I can't work out how to do is to > highlight declared variables in the rest of the code, for example when I > later use x such as > x = x+1 > > Does anyone have any ideas? Ideally I'd like to only highlight those > variables I have really declared, not something that just looks like it > *might* be a variable, so I can see immediately if I've made a mistake > in my coding or typing. > To do this in a sensible way you need a real parser, which can be implemented using e.g. Semantic[1]. Simple regular expressions and such cannot be used for this purpose in a sensible way. 1: http://cedet.sourceforge.net/semantic.shtml -- Deniz Dogan