/*description: { It takes in charge of translating any \CodeWorker\ script to HTML. The source file is highlighted and keywords plus particular symbols of the language are linked to the online-documentation. Note that \samp{this.docURL} designates the URL or the directory where both the CSS and the HTML documentation of \CodeWorker\ are stored. If not populated, it will resolve links from the directory where is the target HTML file. Don't forget to end the URL or directory with a trailing slash. To highlight any script, type:\\ \texttt{CodeWorker \textbf{-translate} CWscript2HTML.cws \textit{} \textit{}}\\ to consider that the documentation and the CSS are in the same directory, and:\\ \texttt{CodeWorker \textbf{-translate} CWscript2HTML.cws \textit{} \textit{} \textbf{-insert} docURL \textit{HTML-doc-URL}}\\ otherwise. } */ #include "CodeWorker_grammar.cwp" #overload #ignore ::= [ ' ' | '\t' | '\r' | '\n' | "/*" => insertText($getOutputLocation() - 2$, ""); ignoreEmbeddedComment => {@@} | "//" => insertText($getOutputLocation() - 2$, ""); [~[['\r']? '\n']]* #explicitCopy ['\r']? '\n' => {@
@} ]*; function transformChar(cChar : value) { if cChar == ' ' return " "; if cChar == '\t' return "    "; if cChar == '\n' return "
" + endl(); if cChar != '\r' return composeHTMLLikeString(cChar); } #implicitCopy(transformChar) #overload translation_unit ::= => {@ @} script => {@
Generated by CodeWorker v@getVersion()@ from CWscript2HTML.cws. @} ; #overload script<"template-based"> ::= #continue [ => {@@} ->['@' | "<%"] => {@@} #continue #ignore [ expression => {@@} ['@' | "%>" | #empty] | [instruction]* => {@@} ['@' | "%>" | #empty] ] => {@@} ]+ => {@@} ; #overload instruction ::= '{' #continue [instruction]* '}' | #readIdentifier:sKeyword => local iLocation = getOutputLocation(); [ instruction => insertText(iLocation, ""); => insertText($iLocation - sKeyword.length()$, ""); | predefined_function_call ';' => insertText(iLocation, ""); => insertText($iLocation - sKeyword.length()$, ""); | predefined_procedure_call ';' => insertText(iLocation, ""); => insertText($iLocation - sKeyword.length()$, ""); | user_function_call ';' ] | => local iLocation = getOutputLocation(); '#' #readIdentifier:sKeyword => insertText(iLocation, ""); => {@@} preprocessor | #check(this != "procedural") => {@@} ['@' | "%>"] #!ignore #continue ->['@' | "<%" | #empty] =>{@@} #ignore [expression ![!'@' !"%>" !#empty]]? ; #overload literal_expression ::= => local iLocation = getOutputLocation(); [ CONSTANT_STRING | '(' #continue expression ')' | '$' => insertText(iLocation, ""); => {@@} #continue #check(!bNumeric) expression => {@@} '$' => {@@} | '~' => insertText(iLocation, ""); => {@@} #continue #check(bNumeric) literal_expression | CONSTANT_CHAR | '!' => insertText(iLocation, ""); => {@@} #continue literal_expression | #readNumeric => insertText(iLocation, ""); => {@@} | #readIdentifier:{"true", "false"} => insertText(iLocation, ""); => {@@} | function_call | variable_expression ['.' #continue method_call]? ] ; #overload function_call ::= #readIdentifier:sFunctionName => local iLocation = getOutputLocation(); [ predefined_function_call => insertText(iLocation, ""); => insertText($iLocation - sFunctionName.length()$, ""); | user_function_call ]; #overload method_call ::= #readIdentifier:sMethodName => local iLocation = getOutputLocation(); [ predefined_method_call:sFunctionName => insertText(iLocation, ""); => insertText($iLocation - sMethodName.length()$, ""); | user_method_call ]; #overload variable_expression : #!ignore ::= => if sIdentifier == "project" || sIdentifier == "this" { insertText($getOutputLocation() - sIdentifier.length()$, ""); @@ } #super::variable_expression ; #overload DEFAULT ::= => {@@} #readIdentifier:"default" => {@@}; #overload CASE ::= => {@@} #readIdentifier:"case" => {@@}; #overload START ::= => {@@} #readIdentifier:"start" => {@@}; #overload CASCADING ::= => {@@} #readIdentifier:"cascading" => {@@}; #overload ELSE ::= => {@@} #readIdentifier:"else" => {@@}; #overload IN ::= => {@@} #readIdentifier:"in" => {@@}; #overload NO_CASE ::= => {@@} #readIdentifier:"no_case" => {@@}; #overload SORTED ::= => {@@} #readIdentifier:"sorted" => {@@}; #overload WHILE ::= => {@@} #readIdentifier:"while" => {@@}; #overload CONSTANT_STRING ::= => local iLocation = getOutputLocation(); #readCString => insertText(iLocation, ""); => {@@} ; #overload CONSTANT_CHAR ::= => local iLocation = getOutputLocation(); '\'' #!ignore #continue ['\\']? #readChar '\'' => insertText(iLocation, ""); => {@@} ; #overload PRULE_SYMBOL ::= => {@@} "::=" => {@@} ; #overload NON_TERMINAL ::= => {@@} #readIdentifier => {@@} ; #overload ALTERNATION ::= => local iLocation = getOutputLocation(); '|' => insertText(iLocation, ""); => {@@} ; #overload TR_BEGIN ::= => local iLocation = getOutputLocation(); '<' => insertText(iLocation, ""); => {@@} ; #overload TR_END ::= => local iLocation = getOutputLocation(); '>' => insertText(iLocation, ""); => {@@} ; #overload BNF_general_directive ::= => local iLocation = getOutputLocation(); '#' #readIdentifier:sKeyword => insertText(iLocation, ""); => {@@} BNF_general_directive ; #overload BNF_general_directive<"overload"> ::= '#' => insertText($getOutputLocation() - 1$, ""); #continue #readIdentifier:"ignore" => {@@} BNF_general_directive<"ignore"> | production_rule; #overload BNF_catch ::= '#' => insertText($getOutputLocation() - 1$, ""); #continue "catch" => {@@} '(' variable_expression ')'; #overload BNF_clause_preprocessing ::= ':' '#' => insertText($getOutputLocation() - 1$, ""); #continue [ '!' #continue #readIdentifier:"ignore" | #readIdentifier:"ignore" ] => {@@}; #overload BNF_literal ::= CONSTANT_STRING [#check(bTokenCondition) ':' #continue variable_expression]? | CONSTANT_CHAR [ ".." #continue CONSTANT_CHAR [#check(bTokenCondition) BNF_token_post_processing]? | [#check(bTokenCondition) ':' #continue variable_expression]? ] | [ '~' => insertText($getOutputLocation() - 1$, ""); => {@@} | '^' => insertText($getOutputLocation() - 1$, ""); => {@@} | '!' => insertText($getOutputLocation() - 1$, ""); => {@@} | "->" => insertText($getOutputLocation() - 10$, ""); => {@@} ] #continue BNF_literal [#check(bTokenCondition) BNF_token_post_processing]? | '[' => insertText($getOutputLocation() - 1$, ""); => {@@} #continue BNF_sequence [ALTERNATION #continue BNF_sequence]* => {@@} ']' [ '?' | '+' | '*' | #readInteger [".." #continue [#readInteger | '*']]? ]? => {@@} [#check(bTokenCondition) BNF_token_post_processing]? | '#' => local iLocation = $getOutputLocation() - 1$; #continue [ '!' #continue #readIdentifier:"ignore" => insertText(iLocation, ""); => {@@} | #readIdentifier:sDirective => insertText(iLocation, ""); => {@@} BNF_directive:bTokenConditionAllowed [ #check(bTokenCondition && bTokenConditionAllowed) BNF_token_post_processing ]? ] | "=>" => insertText($getOutputLocation() - 5$, ""); => {@@} #continue instruction | BNF_clause_call [#check(bTokenCondition) BNF_token_post_processing]? ;