//---------------------------------------------------------
// 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
// <your-specification.txt> <your-specification.html>
//---------------------------------------------------------
#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(' ', "&nbsp;");
set sText = sText.replaceString('\n', "<br/>" + endl());
set sText = sText.replaceString('\t', "&nbsp;&nbsp;&nbsp;&nbsp;");
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 ::=
=> {@<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<header>
<style>
</style>
</header>
<body>
<kbd>
@}
// call the overloaded non-terminal
#super::tinyDSL
=> {@</kbd>
<hr />
Generated by <a href="http://www.codeworker.org">CodeWorker</a> v@getVersion()@ from <a href="@this.docURL@tinyDSL2HTML.html">tinyDSL2HTML.cwp</a>.
</body>
</html>
@}
;
//-------------- Some lexical tokens appearing in bold ----------------
#overload CLASS ::= =>{@<B>@} #readIdentifier:"class" =>{@</B>@};
#overload AGGREGATE ::= =>{@<B>@} #readIdentifier:"aggregate" =>{@</B>@};
#overload DOUBLE ::= =>{@<B>@} #readIdentifier:"double" =>{@</B>@};
#overload STRING ::= =>{@<B>@} #readIdentifier:"string" =>{@</B>@};

Generated by CodeWorker v3.8.4 from CWscript2HTML.cwp.