Note that there are some explanatory texts on larger screens.

plurals
  1. POGrouping block of conditional statements
    primarykey
    data
    text
    <p>I want to group the conditional stmt inside an if parenthesis. Say i have a text from my contenteditable div</p> <pre><code>if ( x==1 &amp;&amp; (x&gt;2 || (!x&gt;2 || x&lt;=0)) ) </code></pre> <p>I would like them to be group accordingly and stored in an array like this</p> <pre><code>condFragment.push('x==1 &amp;&amp; (x&gt;2 || (!x&gt;2 || x&lt;=0))'); condFragment.push('x==1'); condFragment.push('(x&gt;2 || (!x&gt;2 || x&lt;=0))'); condFragment.push('x&gt;2'); condFragment.push('(!x&gt;2 || x&lt;=0)'); condFragment.push('!x&gt;2'); condFragment.push('x&gt;2'); condFragment.push('x&lt;=0'); </code></pre> <p>Is it right to start this by detecting the conditional operators and then splitting them side by side? Modifying split function? Help please. </p> <p>I am grouping them this way because i will fetch the array later and them evaluate it to show if it is true or false. I used push because this might become dynamic array. </p> <p>From this:</p> <pre><code>&lt;div id="board"&gt; &lt;div&gt;int main(){&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;if(x==1 &amp;&amp; !x&gt;2)&lt;/div&gt; &lt;div&gt;statement;&lt;/div&gt; &lt;div&gt;while(!x&gt;5){&lt;/div&gt; &lt;div&gt;statement;}&lt;/div&gt; &lt;div&gt;}&lt;/div&gt; &lt;/div&gt; </code></pre> <p>To this using <code>condFragment</code> content</p> <pre><code>&lt;div id="board"&gt; &lt;div&gt;int main(){&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt; if(&lt;span class="frag"&gt;&lt;span class="frag"&gt;x==1&lt;/span&gt; &amp;&amp; &lt;span class="frag"&gt;!&lt;span class="frag"&gt;x&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;) &lt;/div&gt; &lt;div&gt;statement;&lt;/div&gt; &lt;div&gt;while(!x&gt;5){&lt;/div&gt; &lt;div&gt;statement;}&lt;/div&gt; &lt;div&gt;}&lt;/div&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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