Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The parser generated from the following ANTLR grammar:</p> <pre><code>grammar Genexus; parse : foreach_stmt* EOF ; foreach_stmt : 'foreach' where_opt* blockstmt* whennone_opt? 'endfor' ; where_opt : 'where' cond_clause ; cond_clause : test when_opt* ; when_opt : 'when' test ; whennone_opt : 'when' 'none' blockstmt* ; test : identifier '=' atom ; identifier : 'none' | Identifier ; blockstmt : 'print' atom ; atom : Boolean | Number | StringLiteral | Identifier ; Number : '0'..'9'+ ; Boolean : 'true' | 'false' ; Identifier : ('a'..'z' | 'A'..'Z' | '_')+ ; StringLiteral : '\'' ~'\''* '\'' ; Ignore : (' ' | '\t' | '\r' | '\n') {skip();} | '//' ~('\r' | '\n')* {skip();} | '/*' .* '*/' {skip();} ; </code></pre> <p>Produces the following 3 parse-trees from your examples:</p> <hr> <h2>1</h2> <p>Source:</p> <pre><code>foreach where x = 1 when some_variable = true where x = 2 when some_variable = false where y = 0 print z // Main block when none // optional print 'not found' // Exception block endfor </code></pre> <p>Parse tree:</p> <p><img src="https://i.stack.imgur.com/Dki05.png" alt="enter image description here"></p> <p><em><a href="http://big-o.nl/so/1.png" rel="nofollow noreferrer">larger image</a></em></p> <hr> <h2>2</h2> <p>Source:</p> <pre><code>foreach where x = 1 // main block is blank, do nothing when none print 'none' endfor </code></pre> <p>Parse tree:</p> <p><img src="https://i.stack.imgur.com/XY55D.png" alt="enter image description here"></p> <hr> <h2>3</h2> <p>Source:</p> <pre><code>foreach where x = 1 when none = 2 print 'none' // exceptional block is blank endfor </code></pre> <p>Parse tree:</p> <p><img src="https://i.stack.imgur.com/2f3ej.png" alt="enter image description here"></p> <hr>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload