I find myself drawn to the Parsing Expression Grammar formalism for describing domain specific languages, but so far the implementation code I\'ve found has been written in
look at https://github.com/leblancmeneses/NPEG can easily be converted into php. Parse tree is created with anonymous functions.