Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need them to be able to construct the strings that are in the language <code>L</code>.</p> <p><code>B --&gt; aBb | A</code> means that if you have a nonterminal <code>B</code> it can be replaced by either <code>aBb</code> <em>or</em> <code>A</code>. (Capital letters represent nonterminals and the lower case letters represent terminals).</p> <p>Let's take a look at the grammar:</p> <pre><code>S --&gt; B | ^ B --&gt; aBb | A A --&gt; aA | a </code></pre> <p><strong>Why do we have a <code>| ^</code>?</strong> You need it to be able to generate the empty string. The empty string is clearly part of the language <code>L</code> since it contain an equal amount of <code>a</code>s and <code>b</code>s.</p> <p><strong>Why do we have <code>| A</code>?</strong> To be able to use the rule for <code>A</code>. Now you can replace <code>B</code> with <code>A</code> so you can insert either <code>aA</code> or <code>a</code>. You need this rule to be able to generate strings that have more <code>a</code>s than <code>b</code>s.</p> <p><strong>Why do we have <code>| a</code>?</strong> To be able to replace <code>A</code> with <code>a</code> <em>without</em> adding a new nonterminal that need to be replaced. </p> <p>When I look at this grammar I would say that you need to change <code>A --&gt; aA | a</code> to <code>A --&gt; aA | a | ^</code> to be able to generate strings with an equal amount of <code>a</code>s and <code>b</code>s. (So you can replace <code>A</code> with the empty string (or null) instead of having to add an extra <code>a</code>)</p> <p>Let's say you want to generate the string <code>aaabb</code>:</p> <pre><code>S //You start with S B //Rule: S --&gt; B aBb //Rule: B --&gt; aBb aaBbb //Rule: B --&gt; aBb aaAbb //Rule: B --&gt; A aaabb //Rule: A --&gt; a </code></pre>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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