# Made in CDL3, a language for making compilers. # Function names can include spaces as you can see. # # This program can be made a hundred times simpler in this language, # but I wanted to demonstrate the 'ease' of having inbuilt affix grammars :) # Code looks elaborate in places because there are no iterative loops, # everything has to be done recursively # # Still, CDL3 is obscure rather than esoteric, you can make anything you want in it :) # # # pun only half intended ;) ROOT beer. # Here we define a tree of bottles of beer, recursively through the inbuilt affix grammar. # At the leaves we find a bottle of beer or no beer here ;) BEERS = BEERS and BEERS; a bottle of beer; no beer here. # function for the bottle/bottles. # note that to some extent we can place variables anywhere in the function name FUNCTION dont put an s into TEXT> if >INT equals one: [INT -> 1], ["" -> TEXT]; ["s" -> TEXT]. # binary in a TEXT to INT conversion FUNCTION convert >TEXT to >INT>: [TEXT -> ""]; ([2 * INT -> INT], (is prefix ("0", TEXT, TEXT1), convert TEXT1 to INT; is prefix ("1", TEXT, TEXT1), [INT + 1 -> INT], convert TEXT1 to INT; write ("Oops! This can