Re: Nestable background colors for Lisp code
Paulo Henrique Torrens <[email protected]> Wed, 6 Mar 2013 19:21:39 +0000
| Newsgroups | gmane.comp.gnu.source-highlight.general |
|---|---|
| Message-ID | <[email protected]> |
--===============7798502567229209153== Content-Type: multipart/alternative; boundary="_c8c395dd-8a63-4f8f-a58f-74e807d45160_" --_c8c395dd-8a63-4f8f-a58f-74e807d45160_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Yeah=2C of course. Actually=2C what my actual code uses: /(\()((?ms:=3B.*?[\r\n]|[^()]|(?R))*)(\))/ When it finds this regular expression=2C it gives a background color to it= =2C numerates it (for when it have to repeat it)=2C and nest inside whole g= rammar again=2C but prevents the same regex from matching the whole string = (which would cause an infinite loop). Of course we would need some new keyword or a new syntax for the *.lang fil= es to achieve that=2C but... a simple regular expression is enough. :) If you would consider using the patch on the main repository=2C I could wri= te it. I'm not sure yet about how the new syntax would be=2C any ideas? Another thing that I wouldn't mind writing a patch is interpolating code in= side strings on Ruby=2C PHP=2C Perl=2C etc... but=2C again=2C I'm not sure = on which syntax to use on the *.lang files to mark that. > Date: Wed=2C 6 Mar 2013 10:34:20 +0100 > From: [email protected] > To: [email protected] > Subject: Re: [Help-source-highlight] Nestable background colors for Lisp = code >=20 > On 03/04/2013 03:16 PM=2C Paulo Henrique Torrens wrote: > > Hi=2C > >=20 > > I have quickly made a code highlighter in PHP for a huge project (which > > handles several programming languages=2C including some domain specific > > languages created for the project)=2C but it got too slow for big files > > (as expected=2C since I didn't put much effort)... but I don't have tim= e > > to rewrite it taking care of speed. > >=20 > > So I am intending to migrate to source-highlight=2C which seemed a real= ly > > good alternative=2C but I have a problem: > >=20 > > Here is a screenshot of a Common Lisp code highlighted by my code: > > http://img841.imageshack.us/img841/2706/capturadetela20130303s1.png > >=20 > > This would also be useful for for highlighting regexes' subexpressions. > >=20 > > I know I cannot achieve this result with source-highlight=2C but... are > > you open to some extensions to make such effect? Any suggestion for the > > syntax for the language files to make such a thing? > >=20 > > I could then write the patch=2C if necessary. >=20 > Hi Paulo >=20 > as far as I understand=2C to highlight lisp code to that extent you need > lots of information=3B can you gather that only with lexical analysis and > regular expressions? These are the only mechanisms which > source-highlight is based on... >=20 > cheers > Lorenzo >=20 >=20 > --=20 > Lorenzo Bettini=2C PhD in Computer Science=2C DI=2C Univ. Torino > HOME: http://www.lorenzobettini.it >=20 >=20 > _______________________________________________ > Help-source-highlight mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/help-source-highlight = --_c8c395dd-8a63-4f8f-a58f-74e807d45160_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <html> <head> <style><!-- .hmmessage P { margin:0px=3B padding:0px } body.hmmessage { font-size: 12pt=3B font-family:Calibri } --></style></head> <body class=3D'hmmessage'><div dir=3D'ltr'>Yeah=2C of course.<br>Actually= =2C what my actual code uses:<br><br><br><blockquote><font style=3D"" face= =3D"Courier New">/(\()((?ms:=3B.*?[\r\n]|[^()]|(?R))*)(\))/</font><br><br><= /blockquote><br>When it finds this regular expression=2C it gives a backgro= und color to it=2C numerates it (for when it have to repeat it)=2C and nest= inside whole grammar again=2C but prevents the same regex from matching th= e whole string (which would cause an infinite loop).<br><br>Of course we wo= uld need some new keyword or a new syntax for the *.lang files to achieve t= hat=2C but... a simple regular expression is enough. :)<br><br><br>If you w= ould consider using the patch on the main repository=2C I could write it. I= 'm not sure yet about how the new syntax would be=2C any ideas?<br><br><br>= Another thing that I wouldn't mind writing a patch is interpolating code in= side strings on Ruby=2C PHP=2C Perl=2C etc... but=2C again=2C I'm not sure = on which syntax to use on the *.lang files to mark that.<br><br><br><br><br= ><br><br><br><br><br><blockquote><br></blockquote><br><div><div id=3D"SkyDr= ivePlaceholder"></div>>=3B Date: Wed=2C 6 Mar 2013 10:34:20 +0100<br>>= =3B From: [email protected]<br>>=3B To: [email protected]<= br>>=3B Subject: Re: [Help-source-highlight] Nestable background colors f= or Lisp code<br>>=3B <br>>=3B On 03/04/2013 03:16 PM=2C Paulo Henrique = Torrens wrote:<br>>=3B >=3B Hi=2C<br>>=3B >=3B <br>>=3B >=3B I = have quickly made a code highlighter in PHP for a huge project (which<br>&g= t=3B >=3B handles several programming languages=2C including some domain = specific<br>>=3B >=3B languages created for the project)=2C but it got = too slow for big files<br>>=3B >=3B (as expected=2C since I didn't put = much effort)... but I don't have time<br>>=3B >=3B to rewrite it taking= care of speed.<br>>=3B >=3B <br>>=3B >=3B So I am intending to mig= rate to source-highlight=2C which seemed a really<br>>=3B >=3B good alt= ernative=2C but I have a problem:<br>>=3B >=3B <br>>=3B >=3B Here i= s a screenshot of a Common Lisp code highlighted by my code:<br>>=3B >= =3B http://img841.imageshack.us/img841/2706/capturadetela20130303s1.png<br>= >=3B >=3B <br>>=3B >=3B This would also be useful for for highlight= ing regexes' subexpressions.<br>>=3B >=3B <br>>=3B >=3B I know I ca= nnot achieve this result with source-highlight=2C but... are<br>>=3B >= =3B you open to some extensions to make such effect? Any suggestion for the= <br>>=3B >=3B syntax for the language files to make such a thing?<br>&g= t=3B >=3B <br>>=3B >=3B I could then write the patch=2C if necessary.= <br>>=3B <br>>=3B Hi Paulo<br>>=3B <br>>=3B as far as I understand= =2C to highlight lisp code to that extent you need<br>>=3B lots of inform= ation=3B can you gather that only with lexical analysis and<br>>=3B regul= ar expressions? These are the only mechanisms which<br>>=3B source-highl= ight is based on...<br>>=3B <br>>=3B cheers<br>>=3B Lorenzo<br>>= =3B <br>>=3B <br>>=3B -- <br>>=3B Lorenzo Bettini=2C PhD in Computer = Science=2C DI=2C Univ. Torino<br>>=3B HOME: http://www.lorenzobettini.it<= br>>=3B <br>>=3B <br>>=3B ___________________________________________= ____<br>>=3B Help-source-highlight mailing list<br>>=3B Help-source-hig= [email protected]<br>>=3B https://lists.gnu.org/mailman/listinfo/help-source= -highlight<br></div> </div></body> </html>= --_c8c395dd-8a63-4f8f-a58f-74e807d45160_-- --===============7798502567229209153== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Help-source-highlight mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-source-highlight --===============7798502567229209153==--