Adding "fake" parameters to dynamic tags

Hi all,

I'm working on a plug-in that contains a few dynamic tags and one of them needs to access some details of the AST node in the balise_*_dyn() function. At the moment I'm using the "add a new parameter node to the AST before calling calculer_balise_dynamique()" technique I've seen in a few built-in tags. I've written up a short description of this technique at <http://passingcuriosity.com/2009/dynamic-tags-fake-arguments-ast-mangling-in-spip/>. Is there a better way to do this?

Also: while trying to get this to work I looked for the AST documentation that used to be at <http://doc.spip.org/@details-sur-l-AST> but it has been deleted. Has this article moved somewhere else or been deleted? Is it coming back? Is the information available somewhere else? I don't mind using spip_log(print_r($p, TRUE)), but it does get a little bit boring at times. :slight_smile:

Regards,

Thomas Sutton

Web Developer
bouncingorange
graphic + web design

Interesting :
I’ve discovered what you call « AST node » (it’s « abstract syntax tree ») :

I haven’t found your article on doc.spip.org, but an old (unpublished) article explains how does the compiler work :
http://doc.spip.org/ecrire/?exec=articles&id_article=1437

The AST nodes are listed here :
http://trac.rezo.net/trac/spip/browser/spip/ecrire/public/interfaces.php

It seems that your method is the good one.

.Gilles

On Wed, Mar 11, 2009 at 7:39 AM, Thomas Sutton <thomas@bouncingorange.com> wrote:

Hi all,

I’m working on a plug-in that contains a few dynamic tags and one of them needs to access some details of the AST node in the balise_*_dyn() function. At the moment I’m using the « add a new parameter node to the AST before calling calculer_balise_dynamique() » technique I’ve seen in a few built-in tags. I’ve written up a short description of this technique at <http://passingcuriosity.com/2009/dynamic-tags-fake-arguments-ast-mangling-in-spip/>. Is there a better way to do this?

Also: while trying to get this to work I looked for the AST documentation that used to be at <http://doc.spip.org/@details-sur-l-AST> but it has been deleted. Has this article moved somewhere else or been deleted? Is it coming back? Is the information available somewhere else? I don’t mind using spip_log(print_r($p, TRUE)), but it does get a little bit boring at times. :slight_smile:

Regards,

Thomas Sutton

Web Developer
bouncingorange
graphic + web design


spip-en@rezo.net - http://listes.rezo.net/mailman/listinfo/spip-en

Hi Gilles,

On 11/03/2009, at 10:35 PM, Gilles VINCENT wrote:

Interesting :
I've discovered what you call "AST node" (it's "abstract syntax tree") :

I haven't found your article on doc.spip.org, but an old (unpublished) article explains how does the compiler work :
http://doc.spip.org/ecrire/?exec=articles&id_article=1437

I just get "There is no article at this address" with this URL.

The AST nodes are listed here :
http://trac.rezo.net/trac/spip/browser/spip/ecrire/public/interfaces.php

Yeah, I've looked through the code in that file, but it doesn't help much. The are only a few comments and all of the code that creates and modifies these objects is in other files. The way I figured out how to do this was to run

  grep -r calculer_balise_dynamique *

and

  grep -r Texte * | grep new

in /ecrire/.

It seems that your method is the good one.

I think it would be better if there were an "official" way to pass extra arguments into the balise_*_stat() functions. I've created a new ticket on Trac as per Fil's request http://trac.spip.org/trac/spip/ticket/1728 and I've attached a patch to it which modifies calculer_balise_dynamique() to take an optional array of extra "arguments" as I described in the conclusion of my blog post.

On Wed, Mar 11, 2009 at 7:39 AM, Thomas Sutton <thomas@bouncingorange.com> wrote:
Hi all,

I'm working on a plug-in that contains a few dynamic tags and one of them needs to access some details of the AST node in the balise_*_dyn() function. At the moment I'm using the "add a new parameter node to the AST before calling calculer_balise_dynamique()" technique I've seen in a few built-in tags. I've written up a short description of this technique at <http://passingcuriosity.com/2009/dynamic-tags-fake-arguments-ast-mangling-in-spip/&gt;\. Is there a better way to do this?

Also: while trying to get this to work I looked for the AST documentation that used to be at <http://doc.spip.org/@details-sur-l-AST&gt; but it has been deleted. Has this article moved somewhere else or been deleted? Is it coming back? Is the information available somewhere else? I don't mind using spip_log(print_r($p, TRUE)), but it does get a little bit boring at times. :slight_smile:

Regards,

Thomas Sutton

Web Developer
bouncingorange
graphic + web design

Hi,

On Thu, Mar 12, 2009 at 3:24 AM, Thomas Sutton <thomas@bouncingorange.com> wrote:

I haven’t found your article on doc.spip.org, but an old (unpublished) article explains how does the compiler work :
http://doc.spip.org/ecrire/?exec=articles&id_article=1437

I just get « There is no article at this address » with this URL.

It’s because I’m administrator, and so I can see this article even if it hasn’t been published for publication.
I’ve just changed the status of the article so that you can see it.
Of course, it’s incomplete and I’m afraid that you won’t find the information you’re looking for.

The AST nodes are listed here :
http://trac.rezo.net/trac/spip/browser/spip/ecrire/public/interfaces.php

Yeah, I’ve looked through the code in that file, but it doesn’t help much. The are only a few comments and all of the code that creates and modifies these objects is in other files. The way I figured out how to do this was to run

It’s because only a few persons understand what does this part of the core do :wink:

grep -r calculer_balise_dynamique *

and

grep -r Texte * | grep new

in /ecrire/.

It seems that your method is the good one.

I think it would be better if there were an « official » way to pass extra arguments into the balise_*_stat() functions. I’ve created a new ticket on Trac as per Fil’s request http://trac.spip.org/trac/spip/ticket/1728 and I’ve attached a patch to it which modifies calculer_balise_dynamique() to take an optional array of extra « arguments » as I described in the conclusion of my blog post.

good idea.
I have no objection – but for me the core of SPIP is like a magic box ^^ –

.Gilles

On Wed, Mar 11, 2009 at 7:39 AM, Thomas Sutton <thomas@bouncingorange.com> wrote:
Hi all,

I’m working on a plug-in that contains a few dynamic tags and one of them needs to access some details of the AST node in the balise_*_dyn() function. At the moment I’m using the « add a new parameter node to the AST before calling calculer_balise_dynamique() » technique I’ve seen in a few built-in tags. I’ve written up a short description of this technique at <http://passingcuriosity.com/2009/dynamic-tags-fake-arguments-ast-mangling-in-spip/>. Is there a better way to do this?

Also: while trying to get this to work I looked for the AST documentation that used to be at <http://doc.spip.org/@details-sur-l-AST> but it has been deleted. Has this article moved somewhere else or been deleted? Is it coming back? Is the information available somewhere else? I don’t mind using spip_log(print_r($p, TRUE)), but it does get a little bit boring at times. :slight_smile:

Regards,

Thomas Sutton

Web Developer
bouncingorange
graphic + web design

Hi Thomas,

On Wed, Mar 11, 2009 at 7:39 AM, Thomas Sutton
<thomas@bouncingorange.com> wrote:

Also: while trying to get this to work I looked for the AST documentation
that used to be at <http://doc.spip.org/@details-sur-l-AST&gt; but it has been
deleted. Has this article moved somewhere else or been deleted? Is it coming
back? Is the information available somewhere else? I don't mind using

It was deleted from the database, I don't know why.
I have restored a copy that I found in a personnal backup.
It's here : http://doc.spip.org/ecrire/?exec=articles&id_article=5864
Feel free to translate this article :wink:

.Gilles

Hi Gilles,

On 18/03/2009, at 11:36 PM, Gilles VINCENT wrote:

Hi Thomas,

On Wed, Mar 11, 2009 at 7:39 AM, Thomas Sutton
<thomas@bouncingorange.com> wrote:

Also: while trying to get this to work I looked for the AST documentation
that used to be at <http://doc.spip.org/@details-sur-l-AST&gt; but it has been
deleted. Has this article moved somewhere else or been deleted? Is it coming
back? Is the information available somewhere else? I don't mind using

It was deleted from the database, I don't know why.
I have restored a copy that I found in a personnal backup.
It's here : http://doc.spip.org/ecrire/?exec=articles&id_article=5864
Feel free to translate this article :wink:

Thanks for this. I probably should have saved my own copy (and now, I have). I've started to translate this article into English at <http://doc.spip.org/ecrire/?exec=articles&id_article=5865&gt;\. At the moment it is just the documentation of the AST classes. I'll try to finish the translation (which is not too good, it's me and BabelFish with very occasional assistance from Geraldine on French idioms, etc.)

I have not fixed any of the factual errors, but will endeavour to do so as soon as I find time.

Ones I've noticed so far include:

* Some of the "common elements" don't appear to be common. The Critere class, for example, doesn't have the `type`, `apres`, or `avant` fields in spite of the note implying otherwise.
* The `type` field is not the same as the result of get_class(). That function returns the name of the class as defined ("Critere", not "critere") and certainly doesn't return "include" for Inclure. :slight_smile:

In any case, there will be more English and more details (which "other fields", etc.) coming as soon as I get the chance to figure it out and write it down.

Regards,

Thomas Sutton

Web Developer
bouncingorange
graphic + web design