From ap@fsys.se Wed Apr 8 08:42:46 2009 From: Andreas Pardeike To: textmate@lists.macromates.com Subject: [TxMt] Recursive parsing? Date: Wed, 08 Apr 2009 10:42:37 +0200 Message-ID: <873919C6-F91C-49E5-8A24-E2C98DFD39F2@fsys.se> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4854996851899757381==" --===============4854996851899757381== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hi, last time I asked, this wasn't possible and I did not follow the latest development. So here's my question again: I have a custom html/php dialect. It contains of regions of code that is either html markup or php code. ... and ... Inside a php region, you can use and inside a markup region, you can use which leads to recursive a structure that is very helpful for programming (at least for me) but harder to colorize, fold or autocomplete correctly. More complex example (outmost default is html markup): echo convert($title); init(); Result: if($someflag) foreach $row ($rows) { }
echo $row;
Can I customize Textmate so its html and php modules identify my regions? /Andreas Pardeike --===============4854996851899757381==-- From mailinglist@textmate.org Wed Apr 8 19:34:24 2009 From: Allan Odgaard To: textmate@lists.macromates.com Subject: [TxMt] Re: Recursive parsing? Date: Wed, 08 Apr 2009 21:34:20 +0200 Message-ID: In-Reply-To: <873919C6-F91C-49E5-8A24-E2C98DFD39F2@fsys.se> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7784186515533970346==" --===============7784186515533970346== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On 8 Apr 2009, at 10:42, Andreas Pardeike wrote: > [...] > Can I customize Textmate so its html and php modules identify my > regions? Yes, look at the =E2=80=98include=E2=80=99 rule key: http://manual.macromates= .com/en/language_grammars#rule_keys --===============7784186515533970346==-- From ap@fsys.se Thu Apr 9 06:48:53 2009 From: Andreas Pardeike To: textmate@lists.macromates.com Subject: [TxMt] Re: Recursive parsing? Date: Thu, 09 Apr 2009 08:48:48 +0200 Message-ID: <408BB431-C6E6-4F6D-8529-857A4DF436E7@fsys.se> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4639021511413669056==" --===============4639021511413669056== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On 8 apr 2009, at 21.34, Allan Odgaard wrote: > On 8 Apr 2009, at 10:42, Andreas Pardeike wrote: > >> Can I customize Textmate so its html and php modules identify my >> regions? > > Yes, look at the =E2=80=98include=E2=80=99 rule key: http://manual.macromat= es.com/en/language_grammars#rule_keys Great. Much improved since I looked last. My grammar def looks like =20 this: { scopeName =3D 'text.html.basic'; fileTypes =3D ( ); foldingStartMarker =3D '<(php|htm)>$'; foldingStopMarker =3D '^\s*'; patterns =3D ( { contentName =3D 'source.php'; begin =3D '`|\s*?\n?|
\s*?\n?'; end =3D '`|\s*|^\s*|'; patterns =3D ( { include =3D 'source.php'; } ); }, ); } Question: I don't get syntax coloring for the two scopes though. Is this possible? /Andreas Pardeike --===============4639021511413669056==-- From ap@fsys.se Thu Apr 9 09:10:04 2009 From: Andreas Pardeike To: textmate@lists.macromates.com Subject: [TxMt] Re: Recursive parsing? Date: Thu, 09 Apr 2009 11:10:00 +0200 Message-ID: In-Reply-To: <408BB431-C6E6-4F6D-8529-857A4DF436E7@fsys.se> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2706166859330945358==" --===============2706166859330945358== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Update, Using { scopeName =3D 'text.html.php'; fileTypes =3D ( ); foldingStartMarker =3D '<(php|htm)>$'; foldingStopMarker =3D '^\s*'; patterns =3D ( { contentName =3D 'source.php.embedded.html'; begin =3D '`|\s*?\n?|\s*?\n?'; end =3D '`|\s*|^\s*|'; patterns =3D ( { include =3D 'source.php'; } ); }, { include =3D 'text.html.basic'; }, ); } I get syntax coloring for the html scope, but not for php. /Andreas On 9 apr 2009, at 08.48, Andreas Pardeike wrote: > On 8 apr 2009, at 21.34, Allan Odgaard wrote: > >> On 8 Apr 2009, at 10:42, Andreas Pardeike wrote: >> >>> Can I customize Textmate so its html and php modules identify my >>> regions? >> >> Yes, look at the =E2=80=98include=E2=80=99 rule key: http://manual.macroma= tes.com/en/language_grammars#rule_keys > > Great. Much improved since I looked last. My grammar def looks like > this: > > { scopeName =3D 'text.html.basic'; > fileTypes =3D ( ); > foldingStartMarker =3D '<(php|htm)>$'; > foldingStopMarker =3D '^\s*'; > patterns =3D ( > { contentName =3D 'source.php'; > begin =3D '`|\s*?\n?|\s*?\n?'; > end =3D '`|\s*|^\s*|'; > patterns =3D ( { include =3D 'source.php'; } ); > }, > ); > } > > Question: I don't get syntax coloring for the two scopes though. Is =20 > this > possible? --===============2706166859330945358==-- From mailinglist@textmate.org Thu Apr 16 09:52:22 2009 From: Allan Odgaard To: textmate@lists.macromates.com Subject: [TxMt] Re: Recursive parsing? Date: Thu, 16 Apr 2009 11:52:18 +0200 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2375355444065124713==" --===============2375355444065124713== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On 9 Apr 2009, at 11:10, Andreas Pardeike wrote: > [...] > { include = 'text.html.basic'; }, > > I get syntax coloring for the html scope, but not for php. Because when you include the HTML grammar, you delegate all further parsing (of tags) to this grammar, i.e. your custom tags are then parsed by the included grammar. Afraid you’ll have to role your own (full) grammar for this custom language (or edit the HTML grammar to skip parsing tags). --===============2375355444065124713==--