#include "CodeWorker_grammar.cwp"
#overload #ignore ::=
[
' ' | '\t' | '\r' | '\n'
|
"/*"
=> insertText($getOutputLocation() - 2$, "<span class=\"comment\">");
ignoreEmbeddedComment
=> {@</span>@}
|
"//"
=> insertText($getOutputLocation() - 2$, "<span class=\"comment\">");
[~[['\r']? '\n' | #empty]]*
#explicitCopy
[
['\r']? '\n'
=> {
@</span>@
if !this.multilineScript {@<br/>@}
@@endl()@@
}
|
=> {@</span>@}
]
]*
;
function transformChar(cChar : value) {
if cChar == ' ' return (this.multilineScript) ? " " : " ";
if cChar == '\t' return (this.multilineScript) ? " " : " ";
if cChar == '\n' return (this.multilineScript) ? endl() : "<br/>" + endl();
if cChar != '\r' return composeHTMLLikeString(cChar);
}
#implicitCopy(transformChar)
#overload translation_unit ::=
=> if !this.embeddedScript {@<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
@
if this.includeCSS {
@ <style type='text/css'>
<!--
@loadFile(this.includeCSS)@
-->
</style>
@
} else {
@ <link rel="stylesheet" type="text/css" href="@this.docURL@CodeWorker.css" />
@
}
@ </head>
<body class="script">
@}
[!![->'\n'] => insert this.multilineScript = true;]?
=> if this.multilineScript {@<pre>@}
script<this>
=> if this.multilineScript {@</pre>@}
=> if !this.embeddedScript {
@<hr />
<div style="background-color: #eeeedd">Generated by <a href="http://www.codeworker.org/index.html">@
local sPath = getOutputFilename();
sPath = sPath.rsubString(lengthString(sPath.getShortFilename()));
if existFile(sPath + "CodeWorker99x38.png") {
@<img border=0 src="CodeWorker99x38.png"/>@
} else if this.docURL.startString("http://") || existFile(this.docURL + "CodeWorker99x38.png") {
@<img border=0 src="@this.docURL@CodeWorker99x38.png"/>@
} else {
@<img border=0 src="http://www.codeworker.org/CodeWorker99x38.png"/>@
}
@</a> v@getVersion()@ from @
if existFile(sPath + "CWscript2HTML.html") {
@<a href="CWscript2HTML.html">CWscript2HTML.cwp</a>@
} else if this.docURL.startString("http://") || existFile(this.docURL + "CWscript2HTML.html") {
@<a href="@this.docURL@CWscript2HTML.html">CWscript2HTML.cwp</a>@
} else {
@<a href="http://www.codeworker.org/CWscript2HTML.html">CWscript2HTML.cwp</a>@
}
@.</div>
</body>
</html>
@}
;
#overload instruction ::=
'{' #continue [instruction]* '}'
|
#readIdentifier:sKeyword
=> local iLocation = getOutputLocation();
[
instruction<sKeyword>
=> insertText(iLocation, "</A>");
=> insertText($iLocation - sKeyword.length()$, "<A class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#" + sKeyword + "\">");
|
predefined_function_call<sKeyword> ';'
=> insertText(iLocation, "</A>");
=> insertText($iLocation - sKeyword.length()$, "<A class=\"function\" href=\"" + this.docURL + "manual_The_scripting_language.html#" + sKeyword + "\">");
|
predefined_procedure_call<sKeyword> ';'
=> insertText(iLocation, "</A>");
=> insertText($iLocation - sKeyword.length()$, "<A class=\"procedure\" href=\"" + this.docURL + "manual_The_scripting_language.html#" + sKeyword + "\">");
|
module_function_call ';'
|
user_function_call ';'
]
|
preprocessor
|
variable_expression '.' #continue method_call ';'
|
STARTING_TAG
#!ignore
#continue STARTING_ENDING_RAW_TEXT
#ignore
[!preprocessor expression ![!'@' !"%>" !#empty]]?
;
#overload instruction<"try"> ::=
#continue instruction
"catch"
=> insertText($getOutputLocation() - 5$, "<A class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#try\">");
=> {@</A>@}
'(' variable_expression ')' instruction
;
#overload preprocessor ::=
=> local iLocation = getOutputLocation();
'#'
#readIdentifier:sKeyword
=> insertText(iLocation, "<a class=\"directive\" href=\"" + this.docURL + "manual_The_scripting_language.html#_" + sKeyword + "\">");
=> {@</a>@}
preprocessor<sKeyword>
;
#overload literal_expression<bNumeric> ::=
=> local iLocation = getOutputLocation();
[
CONSTANT_STRING
|
'(' #continue expression<bNumeric> ')'
|
'$'
=> insertText(iLocation, "<a class=\"constant\" href=\"" + this.docURL + "manual_The_scripting_language.html#$\">");
=> {@</a>@}
#continue #check(!bNumeric) expression<true>
=> {@<a class="constant" href="@this.docURL@manual_The_scripting_language.html#$">@}
'$'
=> {@</a>@}
|
'~'
=> insertText(iLocation, "<a class=\"constant\" href=\"" + this.docURL + "manual_The_scripting_language.html#numeric_expression\">");
=> {@</a>@}
#continue #check(bNumeric) literal_expression<true>
|
CONSTANT_CHAR
|
'!'
=> insertText(iLocation, "<a class=\"constant\" href=\"" + this.docURL + "manual_The_scripting_language.html#boolean_expression\">");
=> {@</a>@}
#continue literal_expression<bNumeric>
|
#readNumeric
=> insertText(iLocation, "<span class=\"numeric\">");
=> {@</span>@}
|
#readIdentifier:{"true", "false"}
=> insertText(iLocation, "<a class=\"constant\" href=\"" + this.docURL + "manual_The_scripting_language.html#boolean_literals\">");
=> {@</a>@}
|
function_call
|
variable_expression ['.' #continue method_call]?
]
;
#overload function_call ::=
#readIdentifier:sFunctionName
=> local iLocation = getOutputLocation();
[
predefined_function_call<sFunctionName>
=> insertText(iLocation, "</A>");
=> insertText($iLocation - sFunctionName.length()$, "<A class=\"function\" href=\"" + this.docURL + "manual_The_scripting_language.html#" + sFunctionName + "\">");
|
module_function_call
|
user_function_call
];
#overload method_call ::=
#readIdentifier:sMethodName
=> local iLocation = getOutputLocation();
[
predefined_method_call<sMethodName>:sFunctionName
=> insertText(iLocation, "</A>");
=> insertText($iLocation - sMethodName.length()$, "<A class=\"function\" href=\"" + this.docURL + "manual_The_scripting_language.html#" + sFunctionName + "\">");
|
user_method_call
];
#overload variable_expression<sIdentifier> : #!ignore ::=
=> if sIdentifier == "project" || sIdentifier == "this" || sIdentifier == "_ARGS" || sIdentifier == "_REQUEST" {
insertText($getOutputLocation() - sIdentifier.length()$, "<a class = \"constant\" href=\"" + this.docURL + "manual_The_scripting_language.html#" + sIdentifier + "\">");
@</a>@
}
#super::variable_expression<sIdentifier>
;
#overload function_parameter_type ::=
=> {@<a class="constant" href="@this.docURL@manual_The_scripting_language.html#function_parameters">@}
#super::function_parameter_type
=> {@</a>@};
#overload DEFAULT ::=
#readIdentifier:"default"
=> insertText($getOutputLocation() - 7$, "<a class = \"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#switch\">");
=> {@</a>@};
#overload CASE ::=
#readIdentifier:"case"
=> insertText($getOutputLocation() - 4$, "<a class = \"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#switch\">");
=> {@</a>@};
#overload START ::=
#readIdentifier:"start"
=> insertText($getOutputLocation() - 5$, "<a class = \"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#switch\">");
=> {@</a>@};
#overload CASCADING ::=
#readIdentifier:"cascading"
=> insertText($getOutputLocation() - 9$, "<a class = \"constant\" href=\"" + this.docURL + "manual_The_scripting_language.html#foreach\">");
=> {@</a>@};
#overload ELSE ::=
#readIdentifier:"else"
=> insertText($getOutputLocation() - 4$, "<a class = \"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#if\">");
=> {@</a>@};
#overload IN ::=
#readIdentifier:"in"
=> insertText($getOutputLocation() - 2$, "<a class = \"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#foreach\">");
=> {@</a>@};
#overload INSET ::=
#readIdentifier:"in"
=> insertText($getOutputLocation() - 2$, "<a class = \"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#boolean_expression\">");
=> {@</a>@};
#overload NO_CASE ::=
#readIdentifier:"no_case"
=> insertText($getOutputLocation() - 7$, "<a class = \"constant\" href=\"" + this.docURL + "manual_The_scripting_language.html#foreach\">");
=> {@</a>@};
#overload REVERSE ::=
#readIdentifier:"reverse"
=> insertText($getOutputLocation() - 7$, "<a class = \"constant\" href=\"" + this.docURL + "manual_The_scripting_language.html#foreach\">");
=> {@</a>@};
#overload SORTED ::=
#readIdentifier:"sorted"
=> insertText($getOutputLocation() - 6$, "<a class = \"constant\" href=\"" + this.docURL + "manual_The_scripting_language.html#foreach\">");
=> {@</a>@};
#overload WHILE ::=
#readIdentifier:"while"
=> insertText($getOutputLocation() - 5$, "<a class = \"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#while\">");
=> {@</a>@};
#overload CONSTANT_STRING ::=
=> local iLocation = getOutputLocation();
[#readCString]+
=> insertText(iLocation, "<span class=\"string\">");
=> {@</span>@}
;
#overload CONSTANT_CHAR ::=
=> local iLocation = getOutputLocation();
'\'' #!ignore #continue ['\\']? #readChar '\''
=> insertText(iLocation, "<span class=\"string\">");
=> {@</span>@}
;
#overload VARIABLE_SPECIAL_ACCESSOR ::=
#super::VARIABLE_SPECIAL_ACCESSOR:sKeyword
=> insertText($getOutputLocation() - sKeyword.length()$, "<a class = \"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#_" + sKeyword + "\">");
=> {@</a>@};
#overload FUNCTION ::=
#readIdentifier:"function"
=> insertText($getOutputLocation() - 8$, "<a class = \"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#function\">");
=> {@</a>@};
#overload DECLARE ::=
#readIdentifier:"declare"
=> insertText($getOutputLocation() - 7$, "<a class = \"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#declare\">");
=> {@</a>@};
#overload EXTERNAL ::=
#readIdentifier:"external"
=> insertText($getOutputLocation() - 8$, "<a class = \"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#external\">");
=> {@</a>@};
#overload PRULE_SYMBOL ::=
=> {@<a class="constant" href="@this.docURL@manual_The_scripting_language.html#parsing_BNF_syntax">@}
"::="
=> {@</a>@}
;
#overload NON_TERMINAL ::=
=> {@<i>@}
#readIdentifier
=> {@</i>@}
;
#overload ALTERNATION ::=
=> local iLocation = getOutputLocation();
'|'
=> insertText(iLocation, "<a class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#parsing_alternation\">");
=> {@</a>@}
;
#overload TR_BEGIN ::=
=> local iLocation = getOutputLocation();
'<'
=> insertText(iLocation, "<a class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#BNF_declaring_a_clause\">");
=> {@</a>@}
;
#overload TR_END ::=
=> local iLocation = getOutputLocation();
'>'
=> insertText(iLocation, "<a class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#BNF_declaring_a_clause\">");
=> {@</a>@}
;
#overload PIPESUP ::=
=> local iLocation = getOutputLocation();
"|>"
=> insertText(iLocation, "<a class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#BNF_restricting_the_sentence\">");
=> {@</a>@}
;
#overload ANDOR ::=
=> local iLocation = getOutputLocation();
"&|"
=> insertText(iLocation, "<a class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#BNF_restricting_the_sentence\">");
=> {@</a>@}
;
#overload ADVICE_TYPE ::=
=> {@<a class="constant" href="@this.docURL@manual_The_scripting_language.html#advice">@}
#super::ADVICE_TYPE
=> {@</a>@};
#overload STARTING_RAW_TEXT ::= => {@<span class="raw_text">@} #super::STARTING_RAW_TEXT => {@</span>@};
#overload STARTING_ENDING_RAW_TEXT ::= => {@<span class="raw_text">@} #super::STARTING_ENDING_RAW_TEXT => {@</span>@};
#overload STARTING_TAG ::= => {@<span class="raw_text">@} #super::STARTING_TAG => {@</span>@};
#overload STARTING_TAG_OR_END ::= => {@<span class="raw_text">@} #super::STARTING_TAG_OR_END => {@</span>@};
#overload BNF_general_directive ::=
=> local iLocation = getOutputLocation();
'#'
#readIdentifier:sKeyword
=> insertText(iLocation, "<a class=\"directive\" href=\"" + this.docURL + "manual_The_scripting_language.html#_" + sKeyword + "\">");
=> {@</a>@}
BNF_general_directive<sKeyword>
;
#overload BNF_general_directive<"overload"> ::=
'#'
=> insertText($getOutputLocation() - 1$, "<a class=\"directive\" href=\"" + this.docURL + "manual_The_scripting_language.html#_ignore\">");
#continue #readIdentifier:"ignore"
=> {@</a>@}
BNF_general_directive<"ignore">
|
production_rule;
#overload BNF_catch ::=
'#'
=> insertText($getOutputLocation() - 1$, "<a class=\"directive\" href=\"" + this.docURL + "manual_The_scripting_language.html#_try\">");
#continue
"catch"
=> {@</a>@}
'(' variable_expression ')';
#overload clause_parameter_type ::=
=> {@<a class="constant" href="@this.docURL@manual_The_scripting_language.html#BNF_declaring_a_clause">@}
#super::function_parameter_type
=> {@</a>@};
#overload BNF_clause_return_value ::=
=> {@<a class="constant" href="@this.docURL@manual_The_scripting_language.html#BNF_declaring_a_clause">@}
#super::BNF_clause_return_value
=> {@</a>@}
;
#overload BNF_clause_preprocessing ::=
':' '#'
=> insertText($getOutputLocation() - 1$, "<a class=\"directive\" href=\"" + this.docURL + "manual_The_scripting_language.html#BNF_preprocessing_of_a_clause\">");
#continue
[
'!'
#continue
#readIdentifier:"ignore"
|
#readIdentifier:"ignore"
['(' #continue BNF_ignore_type ')']?
]
=> {@</a>@};
#overload BNF_ignore_type ::=
=> {
@<a class="constant" href="@this.docURL@manual_The_scripting_language.html#BNF_directives__ignore">@
}
#super::BNF_ignore_type
=> {@</a>@};
#overload BNF_literal<bTokenCondition> ::=
[
CONSTANT_STRING
[#check(bTokenCondition) BNF_variable_assignation]?
|
CONSTANT_CHAR
[
".." #continue CONSTANT_CHAR
[#check(bTokenCondition) BNF_token_post_processing]?
|
[#check(bTokenCondition) BNF_variable_assignation]?
]
|
[
'~'
=> insertText($getOutputLocation() - 1$, "<a class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#BNF_token_complementary\">");
=> {@</a>@}
|
'^'
=> insertText($getOutputLocation() - 1$, "<a class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#BNF_token_complementary\">");
=> {@</a>@}
|
'!'
=> insertText($getOutputLocation() - 1$, "<a class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#BNF_token_negation\">");
=> {@</a>@}
|
"->"
=> insertText($getOutputLocation() - 5$, "<a class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#-_amp_gt_\">");
[multiplicity]?
=> {@</a>@}
[
'(' #continue
[BNF_variable_assignation]?
['-' BNF_variable_assignation]?
[BNF_sequence]?
')'
]?
]
#continue BNF_literal<false>
[#check(bTokenCondition) BNF_token_post_processing]?
|
'['
=> insertText($getOutputLocation() - 1$, "<a class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#BNF_token_repeating_a_token\">");
=> {@</a>@}
#continue BNF_sequence [ALTERNATION #continue BNF_sequence]*
=> {@<a class="instruction" href="@this.docURL@manual_The_scripting_language.html#BNF_token_repeating_a_token">@}
']'
[multiplicity]?
=> {@</a>@}
[#check(bTokenCondition) BNF_token_post_processing]?
|
'#'
=> local iLocation = $getOutputLocation() - 1$;
#continue
[
'!'
#continue
#readIdentifier:"ignore"
=> insertText(iLocation, "<a class=\"directive\" href=\"" + this.docURL + "manual_The_scripting_language.html#_ignore\">");
=> {@</a>@}
|
#readIdentifier:sDirective
=> insertText(iLocation, "<a class=\"directive\" href=\"" + this.docURL + "manual_The_scripting_language.html#_" + sDirective + "\">");
=> {@</a>@}
BNF_directive<sDirective>:bTokenConditionAllowed
[
#check(bTokenCondition && bTokenConditionAllowed)
BNF_token_post_processing
]?
]
|
"=>"
=> insertText($getOutputLocation() - 5$, "<a class=\"instruction\" href=\"" + this.docURL + "manual_The_scripting_language.html#BNF_operator__eq__amp_gt_\">");
=> {@</a>@}
#continue instruction
|
BNF_clause_call
[#check(bTokenCondition) BNF_token_post_processing]?
]
[
[PIPESUP | ANDOR]
#continue
BNF_literal<bTokenCondition>
]?
;
script_file_link(T : value) ::=
=> local iLocation = getOutputLocation();
#readCString:sCWFilename
!![',' | ')' | #check(T == "include")]
#check(sCWFilename.rightString(4) in {".cwt", ".cws", ".cwp", ".gen"})
=> local sTargetPath = rsubString(getOutputFilename(), lengthString(getShortFilename(getOutputFilename())));
=> local sHTMLFilename = sTargetPath + sCWFilename + ".html";
#check(sHTMLFilename.existFile())
=> insertText(iLocation, "<a href=\"" + sCWFilename + ".html" + "\" class=\"string\">");
=> {@</a>@}
|
#super::script_file_expression<T>
;
#overload script_file_expression<"free"> ::= script_file_link("free");
#overload script_file_expression<"pattern"> ::= script_file_link("pattern");
#overload script_file_expression<"BNF"> ::= script_file_link("BNF");
#overload script_file_expression<"translate"> ::= script_file_link("translate");