in reply to Re: rough start of an axml compiler
in thread rough start of an axml compiler

is that it fundamentally breaks several of my plugins

Plugins shouldn't change the syntax of the language, just the functionality.

If you follow that principle, the parser is completely independent of the plugins and therefore cannot break them.

If you don't follow that principle, you're in for a world of hurt.

Update: "don't" was missing in last sentence.

Replies are listed 'Best First'.
Re^3: rough start of an axml compiler
by Logicus (Initiate) on Jul 21, 2011 at 20:13 UTC

    Traditionally that is true, but aXML is not traditional!

    Consider this :

    (refas tag="user")/path/to/userfile.xml(/refas) <table> <tr> <td>username : <user>username</user></td> <td>first name : <user>first_name</user></td> <td>surname : <user>sur_name</user></td> </tr> </table>

    The refas (short for refer as) plugin builds a new plugin on the fly called "user", which extracts values from the XML file and substitutes them in the document wherever the tag exists.

    The compiler would split the document up like this :

    print axml(qq@(refas tag="user")/path/to/userfile.xml(/refas)@); print qq@ <table> <tr> <td>username : <user>username</user></td> <td>first name : <user>first_name</user></td> <td>surname : <user>sur_name</user></td> </tr> </table> @;

    Bang! refas doesn't work anymore! The compiler doesn't know what a <user> tag is and ignores it alongside things like <table> and <tr>, and the <refas> tag doesn't have an output other than to modify the parser runtime variables to understand what a <user> tag is.

    The code which would work under a compiler would have to look something like this :

    (refas path="/path/to/userfile.xml") <table> <tr> <td>username : <d>username</d></td> <td>first name : <d>first_name</d></td> <td>surname : <d>sur_name</d></td> </tr> </table> (/refas)

    But that is not necessarily the best way to lay the code out from an design perspective, especially if one of the <user> tags needed to be elsewhere in the document. Also the refas plugin would then also have to take input data to be modified and give an ouput, or you would have to scrap the refas tag and create a plugin called user. Thus the very act of compilation is placing constraints on the code which I designed the parser over successive code iterations to overcome/eliminate.

      It has nothing to do with tradition. It *does* apply to aXML. Nothing you said is even remotely related to what I said.

      I shall add that you have a fundamental misunderstanding as to the purpose of a parser. Parsers don't produce print statements, they assign meaning to tokens.

        Semantics.