//--------------------------------------------------------- // Conversion of the DSL to HTML // // // Highlighting of DSL specifications in HTML (a feature of // the generative programming called 'source-to-source // translation'). // // It reuses the scanning of our tiny DSL and overloads // some non-terminals to convert them to HTML. // // Type: // CodeWorker -translate tinyDSL2HTML.cwp // //--------------------------------------------------------- #include "tinyDSL_scanning.cwp" // Function used by the implicit copy for converting characters // to HTML. function transformText(sText : value) { set sText = composeHTMLLikeString(sText); set sText = sText.replaceString('\r', ""); set sText = sText.replaceString(' ', " "); set sText = sText.replaceString('\n', "
" + endl()); set sText = sText.replaceString('\t', "    "); return sText; } // The implicit copy will use a function to convert characters // before writing them in the output #implicitCopy(transformText) // Overload the head of the grammar to write some HTML text #overload tinyDSL ::= => {@
@} // call the overloaded non-terminal #super::tinyDSL => {@
Generated by CodeWorker v@getVersion()@ from tinyDSL2HTML.cwp. @} ; //-------------- Some lexical tokens appearing in bold ---------------- #overload CLASS ::= =>{@@} #readIdentifier:"class" =>{@@}; #overload AGGREGATE ::= =>{@@} #readIdentifier:"aggregate" =>{@@}; #overload DOUBLE ::= =>{@@} #readIdentifier:"double" =>{@@}; #overload STRING ::= =>{@@} #readIdentifier:"string" =>{@@};