Printer
Indent
indent line in printed output
PopIndentation
reduce indentation depth
PushIndentation
increase indentation depth
Calling Sequence
Parameters
Description
Examples
Printer:-Indent()
Printer:-PopIndentation()
Printer:-PushIndentation()
-
Printer module
The procedure Indent, when used as an argument to a Print call, indicates the argument following Indent() should be indented at the current indentation level.
The procedures PushIndentation and PopIndentation, when called, respectively increase and decrease the current indentation level.
The string used for indentation is controlled by the language attribute "Indent_Char". The number of indentation characters used for all lines, and the number of characters for each level of indentation are controlled by the language attributes "Indent_Base" and "Indent_Increment" respectively.
Any indented output line will have d⁢l+b indentation characters, where b is the value of "Indent_Base", d the value of "Indent_Increment", and l the current indentation level.
Define a language IndentExample, as an extension of C, in which statements are indented and appended with a semicolon, a comment and an end-of-line delimiter.
with(CodeGeneration): LanguageDefinition:-Define("IndentExample", 'extend' = "C", AddPrintHandler( Names:-Statement = proc(x) Printer:-Print( Printer:-Indent(), x, "; /* statement */", Printer:-Endline() ) end proc, Names:-Assignment = proc(x,y) Printer:-Print( Printer:-Indent(), x, " = ", y, "; /* assignment */", Printer:-Endline() ) end proc ), AddFunction( "f", [numeric]::numeric, "f" ) ); Translate(proc(x) local t; t := f(x); t/2 end, language = "IndentExample", resultname = t);
double t (double x) { double t; /* statement */ t = f(x); /* assignment */ return(t / 0.2e1); }
Define a language identical to VisualBasic, but which uses tab characters instead of spaces for indentation.
LanguageDefinitionDefine⁡VB_with_tab,extend=VisualBasic,SetLanguageAttribute⁡Indent_Base=1,Indent_Increment=1,Indent_Char=\t
Translate⁡a=sin⁡x,b=arcsin⁡a,language=VB_with_tab
a = Sin(x) b = Asin(a)
See Also
Language Attributes
Print
Download Help Document