[TxMt] lang grammar regex and complex language constructs

marios buttner origami at ath.forthnet.gr
Sat May 20 22:23:49 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,

In my attempt to shoehorn together a Lang Grammar for Textpattern from
scratch ( "scopeName = source.txp" , and NOT "text.html.txp" ) I ran
into a couple of problems.
I also took a peek at how it's done in the MT Bundle, but I decided,
it's best to start from scratch.
Note.:I'm not a programmer, just a beginner of TM, usually as I
understood, this should then go into the developer mailing list, but
since I am not a developer, I decided then to post first here.

I'll summarize my observations and obstacles below:

1) grammar Scope consideration

Textpattern's syntax is very similar to Html, there is single tags (self
enclosing ) and container tags.
However, the total code blocks, used in forms and pages can get rather
complex, since in many cases you can have funny nested language
constructs that can not be matched with any of the present grammars
regex constructs.
EXAMPLE.: <li <txp:zem_nth step=1
of=2>class="odd</txp:zem_nth><txp:zem_nth step=1
> ><txp:if_article_list>activea</txp:if_article_list> </txp:zem_nth>
<txp:zem_nth step=1 of=2>"</txp:zem_nth>><txp:permlink><txp:title
/></txp:permlink></li>

(Note.:Note the second bracket after the zem_nth closing tag, the code
sample for Txp form above will parse a perfectly valid XHTML, once the
request is returned from the Server)

You can see the pref snippet that I used to test the above below.:

Sample.:
{	name = 'keyword.control.txp';
			match =
'(["|\s]?<txp:.+\s/>["|\s]?|["|\s]*?<txp:.+>["|\s]*?|["|\s]?</txp:.+>["|\s]?)';
		},
(works, but not with the complex constructs, like mentioned above.)

Problem.: Some of these instances make it difficult to construct the
regular expressions.
Possible Solution.: Could be excluded with negates whenever occurs
(That would be rather hackyish and not elegant)

2) Furthermore the reason, why I opted for a "source txp.scope"  rather
then the other easier and integrable solution and attempt everything
from scratch, is that there is not a real hierarchy between html and txp
forms and pages, so I thought it would be more expandable and extensible
in that way.
Question: Is that so ?
Or am I terribly wrong ?



3)Question: Is the p.list format going to change to a xml format for the
Language grammars. ?

4) I made two variants of a preliminary bundle for the Grammar, would it
make sense to submit those to repository, once they reach an acceptable
stage ?

5) I'm a little perplexed with the Theme Editor, and in particular the
context of Theme names, Theme Scope names and the corresponding scope
selectors in the Language Grammar and prefs.
For Instance, for the above p.list value/pair keyword.control.txp, I did
not have a blank element of keyword control in the list.
I thought at first, that (after reading the manual ) I should have a
blank keyword control element (in the Fonts and colors pane ) and then ,
for my above purpose, I create a keyword.control.txp scope selector,
that I style for the above purpose, but that doesn't appear to seem so.

Is it correct to suspect that the element names themselves are
irrelevant for the inner functioning of the language grammar ?

I hope that this was not too long and thank you in advance for reading
this and possibly have an answer to my questions.
So for I am pretty much amazed with the editor.

regards, marios


- --
marios at CSSDelyrium
requests
http://www.consking.com/contact

  ________________      __         _
 / ___/ __/ __/ _ \___ / /_ ______(_)_ ____ _
/ /___\ \_\ \/ // / -_) / // / __/ / // /  ' \
\___/___/___/____/\__/_/\_, /_/ /_/\_,_/_/_/_/
                       /___/


-----BEGIN PGP SIGNATURE-----
Comment: This might change in the future
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEb5b18tSzPOYuZvQRAiZQAKCwWFXNOAKxOT5tWGfLlbYaIQV/WgCffa8u
esaTuzI4S4IbS7pS1oP/d/c=
=Yz4x
-----END PGP SIGNATURE-----



More information about the textmate mailing list