# HG changeset patch # User Claudio Luck # Date 1536073783 -7200 # Node ID 41d7a6c0e7f3c059aca1e7cbb9a57a8174395664 # Parent 4ac3bb01f0bc0d79b9d08fa5d550019a6bd29ad7 Add a README. diff -r 4ac3bb01f0bc -r 41d7a6c0e7f3 README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Tue Sep 04 17:09:43 2018 +0200 @@ -0,0 +1,144 @@ +## What is YML? + +Well, it's the idea not to need to define a grammar first when you want to use a Domain Specific Language. For that purpose, YML is being translated into XML. Let's make an example. + +Everything which comes close to a C like language, parses without a grammar definition: + +This: + + template< class T > T max(T a, T b); + +Parses to: + + + + +Instead of defining grammars, you test out and play around until the results are matching your needs. If the resulting tree does not fit what you're expecting, change it by patching the grammar with `decl`: + +This: + + module A { + interface B { + attribute long n; + }; + }; + +Parses to: + + + + + + + + + + + + + + + + +This does not look like what we want. So we tell YML that we have a module name after the module, an interface name after the interface and type and name after the attribute: + +This: + + decl module @name; + decl interface @name; + decl attribute @type @name; + + module A { + interface B { + attribute long n; + }; + }; + +Parses to: + + + + + + + + +What can I do with YML? + +With YML you can: + + * use a C-like DSL without writing a grammar first + * generate code out of this DSL using YSLT + * generate code out of UML using YSLT on XMI + * generate code out of any XML based language like SVG using YSLT + * define a wiki like language in just a few lines like YHTML does + * replace bad designed and complicated XML languages with simpler C-like ones + * ... and much more. + +How it works: Replacing angle brackets with some Python + +Just writing down what I wanted to have instead of XML for a sample: + + + + + Goods + + + Price + + + + + Beer + + + 20 + + + + + Wine + + + 30 + + + + +Something like that should be more easy, say, like this: + + list "List of goods" { + head title "Goods", title "Price"; + row value "Beer", value 20; + row value "Wine", value 30; + } + +### Y Languages + +The latter is what I call an Y language – a language specified in YML. How could this be achieved? Well, what's to do? To have the required information, how to build XML from the script above, we need: + + * the information, that “list of goods” is an attribute named `name`, while `Goods` is the text value of a tag + * `title` shout be written out as `columnTitle` + +How to do that? Let's invent a simple definition language for that information: + + decl list(name); + decl title alias columnTitle;