XML Little Languages A guide to writing "programming" languages in XML Copyright 2000 © FastNet Software Ltd Matt Sergeant What is a Little Language? Configuration Files++ Conditionals Loops Variables Simple Language Feature Examples
...]]>

	, 
]]>

...
]]>
Why Use an XML Little Language XML tool support (especially validating tools) Ease of design/development XML provides block structure Easy to train novices in Consistent syntax with other XML vocabularies Why Not to use XML for Languages Verbose XML Editors still weak Some irritating features: entities, CDATA, & General Language Parsing Tokenizing Lexical Analysis Optimisation Execution XML Language Parsing Tokenizing => SAX Parser Events Lexical Analysis => Validation and/or tree building Optimisation => Moving parts of the tree around Execution => tree is our "bytecode" which we execute Parsing (1): Tree Building The tree is your "bytecode" Most likely to be a DOM tree Perl XML::Parser "Tree" style Grove tree You choose! Let your parser do the work Parsing (2): Tree Optimisation Moving tree parts around Maintain a single tree root Persistance Passing bytecode around requires a single root alternatively make it a class Bytecode Execution Language dependant Start at root of tree processing elements in turn Use recursion Conditionals: fail => don't process children Loops: process children N times Perl Implementation Notes local keyword is great for conditionals local also great for lexical variables store bytecode to disk with Storable module