Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Acceleo/Text Production Rules"
m (categories) |
|||
Line 1: | Line 1: | ||
= Text production rules = | = Text production rules = | ||
− | + | == Text Production Rules == | |
− | + | === Overview === | |
− | + | ||
− | This is still a draft and is only provided as information. Though this document is still missing some formatting and examples, it can be used to get a precise idea as to how indentation and carriage returns are handled in Acceleo. | + | This is still a draft and is only provided as information. Though this document is still missing some formatting and examples, it can be used to get a precise idea as to how indentation and carriage returns are handled in Acceleo. |
− | + | === Definitions === | |
− | Text production rules will apply to all body elements. | + | Text production rules will apply to all body elements. Each body element can be either stand alone or embedded within other body elements. It will be easier to understand text production rules by splitting these body elements in five main categories : expressions, static text, comments, template invocation and blocks. |
− | Each body element can be either stand alone or embedded within other body elements. | + | |
− | It will be easier to understand text production rules by splitting these body elements in five main categories : expressions, static text, comments, template invocation and blocks. | + | |
− | "Blocks" include template, for, if, let, protected area, file, trace and macro blocks. | + | "Blocks" include template, for, if, let, protected area, file, trace and macro blocks. A block will be considered ��stand-alone�� if it is either one of: |
− | A block will be considered ��stand-alone�� if it is either one of: | + | |
+ | - A single line block that is not surrounded with any other body element, except | ||
− | |||
for white spaces, block tails and comments; | for white spaces, block tails and comments; | ||
− | - A multi-line block that is not surrounded with any other body element, except | + | |
+ | - A multi-line block that is not surrounded with any other body element, except | ||
+ | |||
for white spaces, block tails and comments, on the lines where the block head | for white spaces, block tails and comments, on the lines where the block head | ||
and tail occur. | and tail occur. | ||
− | Any block that does not fall into these categories will be considered an | + | Any block that does not fall into these categories will be considered an "embedded" block. |
− | "embedded" block. | + | |
− | + | ====. Examples ==== | |
+ | ===== Stand-alone single-line blocks ===== | ||
− | + | Nothing relevant for generation between the line start and the block head, nothing relevant between the block tail and the line end; both head and tail on the same line. All of the following are in this category. | |
− | + | ||
− | + | ||
− | Nothing relevant for generation between the line start and the block head, nothing relevant between the block tail and the line end; both head and tail on the same line. | + | |
− | All of the following are in this category. | + | |
:: | :: | ||
Line 63: | Line 58: | ||
[/if] [comment .../] [if (true)]output[/if] | [/if] [comment .../] [if (true)]output[/if] | ||
− | h6. Embedded single-line blocks | + | h6. Embedded single-line blocks |
− | + | ||
− | Head and tail of the block are on the same line, but there is something relevant to the generation other than the block on that same line. | + | <br> Head and tail of the block are on the same line, but there is something relevant to the generation other than the block on that same line. |
:: | :: | ||
Line 84: | Line 78: | ||
[for (Sequence{false, false, false})] [self/][/for] and some text. | [for (Sequence{false, false, false})] [self/][/for] and some text. | ||
− | + | ===== Stand-alone multi-line blocks ===== | |
− | + | Nothing relevant for generation between the line start and the block head, nothing relevant between the block tail and the line end; head and tail on different lines. | |
− | Nothing relevant for generation between the line start and the block head, nothing relevant between the block tail and the line end; head and tail on different lines. | + | |
:: | :: | ||
Line 124: | Line 117: | ||
[/for] | [/for] | ||
− | + | ===== Embedded multi-line blocks ===== | |
− | + | Head and tail of the block are on different lines, but there is something relevant to the generation other than the block on that same line. | |
− | Head and tail of the block are on different lines, but there is something relevant to the generation other than the block on that same line. | + | |
:: | :: | ||
Line 142: | Line 134: | ||
output[/if] text | output[/if] text | ||
+ | === Identifying Body Element Boundaries === | ||
− | + | ==== Block Body ==== | |
− | + | ||
− | + | ||
− | + | ||
**Single-line block** | **Single-line block** | ||
Line 164: | Line 154: | ||
last new line character preceding its tail. | last new line character preceding its tail. | ||
+ | <br> Static Text | ||
− | + | ---- | |
− | + | ||
− | We need to define the concept of line relevance to properly identify these boundaries. For this purpose, we will describe as "white spaces" the white space characters contained in a static text, whatever their position in the text. | + | We need to define the concept of line relevance to properly identify these boundaries. For this purpose, we will describe as "white spaces" the white space characters contained in a static text, whatever their position in the text. |
+ | |||
+ | A line is considered "relevant" if it contains anything else than white spaces, block head, block tail and comment. Note, however, that lines consisting of white spaces *only* are also considered relevant. | ||
− | + | - If a static text is entirely located on a non relevant line, it does not | |
− | + | ||
− | |||
produce any text. | produce any text. | ||
− | - If a static text starts on a non relevant line, all characters located on this | + | |
+ | - If a static text starts on a non relevant line, all characters located on this | ||
+ | |||
line are ignored and the static text is considered to start with the character | line are ignored and the static text is considered to start with the character | ||
after its very first new line character. | after its very first new line character. | ||
− | - If a static text ends on a non relevant line, all characters located on this | + | |
+ | - If a static text ends on a non relevant line, all characters located on this | ||
+ | |||
line are ignored and the static text is considered to end with the character | line are ignored and the static text is considered to end with the character | ||
before its very last new line character. | before its very last new line character. | ||
− | - *Special handling of static text following a ��protected area�� block:* | + | |
+ | - *Special handling of static text following a ��protected area�� block:* | ||
+ | |||
all white spaces following a protected area tail are retained, including the | all white spaces following a protected area tail are retained, including the | ||
new line character. | new line character. | ||
Line 186: | Line 183: | ||
area tail. | area tail. | ||
− | Rules | + | Rules |
− | =========================================== | + | |
− | Considering the boundaries outlined in section | + | ====== =============================== ====== |
− | `Identifying Body Element Boundaries`_ above, the text production rules stand as follows: | + | |
+ | Considering the boundaries outlined in section `Identifying Body Element Boundaries`_ above, the text production rules stand as follows: | ||
+ | |||
+ | - The text produced by the execution of expressions is output as is; - The text produced by the execution of static text is output as is; - Comments do not produce any text; - Each line of the text produced by a template invocation will be indented to | ||
− | |||
− | |||
− | |||
− | |||
match the indentation of the line sporting the invocation; | match the indentation of the line sporting the invocation; | ||
− | - The text produced by the execution of embedded blocks, be they multi-line | + | |
+ | - The text produced by the execution of embedded blocks, be they multi-line | ||
+ | |||
blocks or single line blocks, is output as is along with all text produced by | blocks or single line blocks, is output as is along with all text produced by | ||
the surrounding body elements. | the surrounding body elements. | ||
− | - The text produced by the execution of stand-alone, single line blocks is | + | |
+ | - The text produced by the execution of stand-alone, single line blocks is | ||
+ | |||
output as is. White spaces located before and after the block are retained; | output as is. White spaces located before and after the block are retained; | ||
− | - The text produced by the execution of stand-alone, multi-line blocks will be | + | |
+ | - The text produced by the execution of stand-alone, multi-line blocks will be | ||
+ | |||
output as is considering the aforementioned boundaries: if the very first | output as is considering the aforementioned boundaries: if the very first | ||
character of the block body is a new line, it is ignored. | character of the block body is a new line, it is ignored. | ||
Line 207: | Line 209: | ||
not even a new line character will be present in the resulting text. | not even a new line character will be present in the resulting text. | ||
− | Examples | + | Examples |
− | + | ||
− | + | ====== =============================== ====== | |
+ | In the following examples, invisible characters have been materialized: | ||
− | | |inter| | + | <br> | |inter| | indicates a space character | |
− | | |tab| | + | | |tab| | indicates a horizontal tab character | |
− | | |return| | + | | |return| | indicates a carriage return | |
+ | <br> Blocks | ||
− | + | ---- | |
− | + | ||
− | Embedded Blocks ______________________________________ | + | Embedded Blocks ______________________________________ |
− | Example 1 | + | Example 1 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
@Some@ |inter| @text@ |inter| ``[for`` |inter| @(Sequence{false,@ |inter| | @Some@ |inter| @text@ |inter| ``[for`` |inter| @(Sequence{false,@ |inter| | ||
Line 233: | Line 233: | ||
``-`` |inter| @')]output[/for]@ | ``-`` |inter| @')]output[/for]@ | ||
− | produces the following result: | + | produces the following result: |
@Some@ |inter| @text@ |inter| @output@ |inter| @-@ |inter| @output@ | @Some@ |inter| @text@ |inter| @output@ |inter| @-@ |inter| @output@ | ||
|inter| @-@ |inter| @output@ | |inter| @-@ |inter| @output@ | ||
+ | |||
---- | ---- | ||
− | Example 2 | + | Example 2 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
``[if`` |inter| @(true)]output[/if]@ |inter| @and@ |inter| @some@ | ``[if`` |inter| @(true)]output[/if]@ |inter| @and@ |inter| @some@ | ||
|inter| @text@ | |inter| @text@ | ||
− | produces: | + | produces: |
@output@ |inter| @and@ |inter| @some@ |inter| @text@ | @output@ |inter| @and@ |inter| @some@ |inter| @text@ | ||
Line 253: | Line 252: | ||
---- | ---- | ||
− | Example 3 | + | Example 3 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
|tab| ``[for`` |inter| ``(Sequence{false,`` |inter| @false})]@ |inter| | |tab| ``[for`` |inter| ``(Sequence{false,`` |inter| @false})]@ |inter| | ||
@[self/][/for]@ |inter| @and@ |inter| @some@ |inter| @text@ | @[self/][/for]@ |inter| @and@ |inter| @some@ |inter| @text@ | ||
− | produces: | + | produces: |
|tab| |inter| @false@ |inter| @false@ |inter| @and@ |inter| @some@ | |tab| |inter| @false@ |inter| @false@ |inter| @and@ |inter| @some@ | ||
Line 267: | Line 264: | ||
---- | ---- | ||
− | Example 4 | + | Example 4 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
``text[for`` |inter| ``(Sequence{false,`` |inter| @false})]@ |return| | ``text[for`` |inter| ``(Sequence{false,`` |inter| @false})]@ |return| | ||
Line 277: | Line 272: | ||
@[/for]text@ | @[/for]text@ | ||
− | produces: | + | produces: |
@text@ |tab| @false@ |return| | @text@ |tab| @false@ |return| | ||
Line 287: | Line 282: | ||
---- | ---- | ||
− | Example 5 | + | Example 5 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
``text[for`` |inter| ``(Sequence{false,`` |inter| @false})]@ |return| | ``text[for`` |inter| ``(Sequence{false,`` |inter| @false})]@ |return| | ||
Line 295: | Line 288: | ||
|tab| @output[/for]text@ | |tab| @output[/for]text@ | ||
− | produces: | + | produces: |
@text@ |tab| @output@ |tab| @outputtext@ |return| | @text@ |tab| @output@ |tab| @outputtext@ |return| | ||
+ | <br> Stand-alone single-line blocks ___________________________________________ | ||
− | + | Example 1 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: | |
− | + | ||
− | Example 1 | + | |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
``[for`` |inter| ``(Sequence{false,`` |inter| @false,@ |inter| | ``[for`` |inter| ``(Sequence{false,`` |inter| @false,@ |inter| | ||
@false})][self/][/for]@ | @false})][self/][/for]@ | ||
− | produces: | + | produces: |
@falsefalsefalse@ | @falsefalsefalse@ | ||
Line 315: | Line 305: | ||
---- | ---- | ||
− | Example 2 | + | Example 2 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
``[if`` |inter| @(true)]output[/if]@ | ``[if`` |inter| @(true)]output[/if]@ | ||
− | produces: | + | produces: |
@output@ | @output@ | ||
Line 327: | Line 315: | ||
---- | ---- | ||
− | Example 3 | + | Example 3 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
|tab| ``[for`` |inter| ``(Sequence{false,`` |inter| @false,@ |inter| | |tab| ``[for`` |inter| ``(Sequence{false,`` |inter| @false,@ |inter| | ||
@false})][self/][/for]@ | @false})][self/][/for]@ | ||
− | produces: | + | produces: |
|tab| @falsefalsefalse@ | |tab| @falsefalsefalse@ | ||
Line 340: | Line 326: | ||
---- | ---- | ||
− | Example 4 | + | Example 4 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
``[/if]`` |tab| |tab| ``[if`` |inter| @(true)]output[/if]@ | ``[/if]`` |tab| |tab| ``[if`` |inter| @(true)]output[/if]@ | ||
− | produces: | + | produces: |
|tab| |tab| @output@ | |tab| |tab| @output@ | ||
Line 352: | Line 336: | ||
---- | ---- | ||
− | Example 5 | + | Example 5 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
``[/if]`` |inter| ``[comment .../]`` |tab| ``[if`` |inter| @(true)]output[/if]@ | ``[/if]`` |inter| ``[comment .../]`` |tab| ``[if`` |inter| @(true)]output[/if]@ | ||
− | produces: | + | produces: |
|inter| |tab| @output@ | |inter| |tab| @output@ | ||
− | Stand-alone multi-line blocks ___________________________________________ | + | Stand-alone multi-line blocks ___________________________________________ |
− | Example 1 | + | Example 1 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
``[for`` |inter| ``(Sequence{false,`` |inter| ``false,`` |inter| @false})]@ |return| | ``[for`` |inter| ``(Sequence{false,`` |inter| ``false,`` |inter| @false})]@ |return| | ||
|tab| @[self/]@ |return| | |tab| @[self/]@ |return| | ||
− | + | ||
@[/for]@ | @[/for]@ | ||
− | produces: | + | produces: |
|tab| @false@ |return| | |tab| @false@ |return| | ||
Line 382: | Line 362: | ||
|tab| @false@ |return| | |tab| @false@ |return| | ||
+ | <br> | ||
---- | ---- | ||
− | Example 2 | + | Example 2 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
``[if`` |inter| @(false)]output@ |return| | ``[if`` |inter| @(false)]output@ |return| | ||
Line 393: | Line 372: | ||
@[/if]@ | @[/if]@ | ||
− | produces nothing, neither whitespace nor empty line. | + | produces nothing, neither whitespace nor empty line. |
---- | ---- | ||
− | Example 3 | + | Example 3 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
``[if`` |inter| @(true)]@ |return| | ``[if`` |inter| @(true)]@ |return| | ||
Line 405: | Line 382: | ||
|tab| @output[/if]@ | |tab| @output[/if]@ | ||
− | produces: | + | produces: |
|tab| @output@ | |tab| @output@ | ||
Line 411: | Line 388: | ||
---- | ---- | ||
− | Example 4 | + | Example 4 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
``[comment]for`` |inter| @loop[/comment][for@ |inter| | ``[comment]for`` |inter| @loop[/comment][for@ |inter| | ||
Line 419: | Line 394: | ||
|tab| ``[if`` |inter| @(self)]@ |return| | |tab| ``[if`` |inter| @(self)]@ |return| | ||
− | + | ||
|tab| |tab| @[self/]@ |return| | |tab| |tab| @[self/]@ |return| | ||
− | + | ||
|tab| @[/if]@ |return| | |tab| @[/if]@ |return| | ||
− | + | ||
@[/for]@ | @[/for]@ | ||
− | produces nothing, neither whitespace nor empty line. | + | produces nothing, neither whitespace nor empty line. |
---- | ---- | ||
− | Example 5 | + | Example 5 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code: |
− | 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ | + | |
− | The Acceleo code: | + | |
|tab| ``[for`` |inter| ``(Sequence{false,`` |inter| @false,@ |inter| | |tab| ``[for`` |inter| ``(Sequence{false,`` |inter| @false,@ |inter| | ||
Line 438: | Line 411: | ||
@[self/]@ |return| | @[self/]@ |return| | ||
− | + | ||
|tab| @[/for]@ |return| | |tab| @[/for]@ |return| | ||
− | + | <br> produces: | |
− | produces: | + | |
@false@ |return| | @false@ |return| | ||
Line 450: | Line 422: | ||
@false@ |return| | @false@ |return| | ||
+ | <br> {{Acceleo-index}} | ||
− | + | [[Category:Modeling]] [[Category:M2T]] [[Category:Acceleo]] | |
− | + | ||
− | [[Category:Modeling]] | + | |
− | [[Category:M2T]] | + | |
− | [[Category:Acceleo]] | + |
Revision as of 11:16, 13 January 2011
Contents
Text production rules
Text Production Rules
Overview
This is still a draft and is only provided as information. Though this document is still missing some formatting and examples, it can be used to get a precise idea as to how indentation and carriage returns are handled in Acceleo.
Definitions
Text production rules will apply to all body elements. Each body element can be either stand alone or embedded within other body elements. It will be easier to understand text production rules by splitting these body elements in five main categories : expressions, static text, comments, template invocation and blocks.
"Blocks" include template, for, if, let, protected area, file, trace and macro blocks. A block will be considered ��stand-alone�� if it is either one of:
- A single line block that is not surrounded with any other body element, except
for white spaces, block tails and comments;
- A multi-line block that is not surrounded with any other body element, except
for white spaces, block tails and comments, on the lines where the block head and tail occur.
Any block that does not fall into these categories will be considered an "embedded" block.
. Examples
Stand-alone single-line blocks
Nothing relevant for generation between the line start and the block head, nothing relevant between the block tail and the line end; both head and tail on the same line. All of the following are in this category.
[for (Sequence{false, false, false})][self/][/for]
[if (true)]output[/if]
[for (Sequence{false, false, false})][self/][/for]
[/if] [if (true)]output[/if]
[/if] [comment .../] [if (true)]output[/if]
h6. Embedded single-line blocks
Head and tail of the block are on the same line, but there is something relevant to the generation other than the block on that same line.
Some text[for (Sequence{false, false, false})]output[/for]
[if (true)]output[/if] and some text
[for (Sequence{false, false, false})] [self/][/for] and some text.
Stand-alone multi-line blocks
Nothing relevant for generation between the line start and the block head, nothing relevant between the block tail and the line end; head and tail on different lines.
[for (Sequence{false, false, false})] [self/] [/for]
[if (true)]output [/if]
[if (true)] output[/if]
[comment]Generate booleans [/comment][for (Sequence{false, false, false})] [self/][/for]
[for (Sequence{false, false, false})] [self/] [/for]
Embedded multi-line blocks
Head and tail of the block are on different lines, but there is something relevant to the generation other than the block on that same line.
text[for (Sequence{false, false, false})] [self/] [/for]
[if (true)] output[/if] text
Identifying Body Element Boundaries
Block Body
**Single-line block** Body starts after the closing bracket of the block head and ends before the starting bracket of the block tail. **Multi-line block** If the closing bracket of the block head is directly followed by a new line, the block's body starts at the beginning of the next line after the block head. Otherwise the block's body starts after the closing bracket of its head. The body ends before the starting bracket of the block tail, be it directly preceded by a new line or not. **Special handling of "Template" blocks** If the last characters preceding the starting bracket of the block tail is a new line followed by optional white spaces, the template body ends before the last new line character preceding its tail.
Static Text
We need to define the concept of line relevance to properly identify these boundaries. For this purpose, we will describe as "white spaces" the white space characters contained in a static text, whatever their position in the text.
A line is considered "relevant" if it contains anything else than white spaces, block head, block tail and comment. Note, however, that lines consisting of white spaces *only* are also considered relevant.
- If a static text is entirely located on a non relevant line, it does not
produce any text.
- If a static text starts on a non relevant line, all characters located on this
line are ignored and the static text is considered to start with the character after its very first new line character.
- If a static text ends on a non relevant line, all characters located on this
line are ignored and the static text is considered to end with the character before its very last new line character.
- *Special handling of static text following a ��protected area�� block:*
all white spaces following a protected area tail are retained, including the new line character. The static text then starts right after the closing bracket of the protected area tail.
Rules
===============================
Considering the boundaries outlined in section `Identifying Body Element Boundaries`_ above, the text production rules stand as follows:
- The text produced by the execution of expressions is output as is; - The text produced by the execution of static text is output as is; - Comments do not produce any text; - Each line of the text produced by a template invocation will be indented to
match the indentation of the line sporting the invocation;
- The text produced by the execution of embedded blocks, be they multi-line
blocks or single line blocks, is output as is along with all text produced by the surrounding body elements.
- The text produced by the execution of stand-alone, single line blocks is
output as is. White spaces located before and after the block are retained;
- The text produced by the execution of stand-alone, multi-line blocks will be
output as is considering the aforementioned boundaries: if the very first character of the block body is a new line, it is ignored. Please note that if a stand-alone, multi-line block doesn't produce any text, not even a new line character will be present in the resulting text.
Examples
===============================
In the following examples, invisible characters have been materialized:
| |inter| | indicates a space character |
| |tab| | indicates a horizontal tab character |
| |return| | indicates a carriage return |
Blocks
Embedded Blocks ______________________________________
Example 1 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
@Some@ |inter| @text@ |inter| ``[for`` |inter| @(Sequence{false,@ |inter| ``false,`` |inter| ``false})`` |inter| @separator@ |inter| @('@ |inter| ``-`` |inter| @')]output[/for]@
produces the following result:
@Some@ |inter| @text@ |inter| @output@ |inter| @-@ |inter| @output@ |inter| @-@ |inter| @output@
Example 2 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
``[if`` |inter| @(true)]output[/if]@ |inter| @and@ |inter| @some@ |inter| @text@
produces:
@output@ |inter| @and@ |inter| @some@ |inter| @text@
Example 3 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
|tab| ``[for`` |inter| ``(Sequence{false,`` |inter| @false})]@ |inter| @[self/][/for]@ |inter| @and@ |inter| @some@ |inter| @text@
produces:
|tab| |inter| @false@ |inter| @false@ |inter| @and@ |inter| @some@ |inter| @text@
Example 4 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
``text[for`` |inter| ``(Sequence{false,`` |inter| @false})]@ |return|
|tab| @[self/]@ |return|
@[/for]text@
produces:
@text@ |tab| @false@ |return|
|tab| @false@ |return|
@text@
Example 5 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
``text[for`` |inter| ``(Sequence{false,`` |inter| @false})]@ |return|
|tab| @output[/for]text@
produces:
@text@ |tab| @output@ |tab| @outputtext@ |return|
Stand-alone single-line blocks ___________________________________________
Example 1 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
``[for`` |inter| ``(Sequence{false,`` |inter| @false,@ |inter| @false})][self/][/for]@
produces:
@falsefalsefalse@
Example 2 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
``[if`` |inter| @(true)]output[/if]@
produces:
@output@
Example 3 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
|tab| ``[for`` |inter| ``(Sequence{false,`` |inter| @false,@ |inter| @false})][self/][/for]@
produces:
|tab| @falsefalsefalse@
Example 4 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
``[/if]`` |tab| |tab| ``[if`` |inter| @(true)]output[/if]@
produces:
|tab| |tab| @output@
Example 5 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
``[/if]`` |inter| ``[comment .../]`` |tab| ``[if`` |inter| @(true)]output[/if]@
produces:
|inter| |tab| @output@
Stand-alone multi-line blocks ___________________________________________
Example 1 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
``[for`` |inter| ``(Sequence{false,`` |inter| ``false,`` |inter| @false})]@ |return|
|tab| @[self/]@ |return|
@[/for]@
produces:
|tab| @false@ |return|
|tab| @false@ |return|
|tab| @false@ |return|
Example 2 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
``[if`` |inter| @(false)]output@ |return|
@[/if]@
produces nothing, neither whitespace nor empty line.
Example 3 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
``[if`` |inter| @(true)]@ |return|
|tab| @output[/if]@
produces:
|tab| @output@
Example 4 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
``[comment]for`` |inter| @loop[/comment][for@ |inter| ``(Sequence{false,`` |inter| @false})]@ |return|
|tab| ``[if`` |inter| @(self)]@ |return|
|tab| |tab| @[self/]@ |return|
|tab| @[/if]@ |return|
@[/for]@
produces nothing, neither whitespace nor empty line.
Example 5 08:07, 11 January 2011 (UTC)08:07, 11 January 2011 (UTC)~~ The Acceleo code:
|tab| ``[for`` |inter| ``(Sequence{false,`` |inter| @false,@ |inter| @false})]@ |return|
@[self/]@ |return|
|tab| @[/for]@ |return|
produces:
@false@ |return|
@false@ |return|
@false@ |return|
----
Acceleo Portal | |
Project | Project · Installation |
Features | Acceleo Features · Runtime · Acceleo editor · Views & Perspective · Interpreter · Maven |
User documentation | Getting Started · User Guide · Acceleo operations reference · OCL operations reference · Text Production Rules · Migration From Acceleo 2.x · Best Practices · Videos · FAQ |
Developer documentation | Source code · How to contribute · Compatibility · MOFM2T specification · OCL specification |
Community | Professional Support · Report a bug |