title: Transforming Grammar for Tiny Parser Generator
body: <p>For a personal project to get me ready for an internship, I have decided to try and learn more about grammars and parsers.  I wanted to make a simple compiler, and settled on a grammar that looks like this. Terminals are lowercase.</p>
  
  <pre><code>P -&gt; S P | epsilon
  S -&gt; id assign E semi | print id semi
  E -&gt; T E'
  E'-&gt; + T E' | - T E' | epsilon
  T -&gt; F T'
  T' -&gt; * F T' | / F T' | epsilon
  F -&gt; X F'
  F' -&gt; **X F' | epsilon
  X -&gt; (E) | identifier | number
  </code></pre>
  
  <p>The gramamr would allow for code such as this.  Operations would be assign</p>
  
  <p>statements(=) </p>
  
  <p>addition(-)</p>
  
  <p>multiplication(*)</p>
  
  <p>division(/)</p>
  
  <p>subtraction(-)</p>
  
  <p>exponentiation(**)</p>
  
  <p>statement sequence </p>
  
  <p>and a print statement(print). Also parantheses would be included.</p>
  
  <pre><code>xabc = 3.141592 ; 
  y = -2.0 ; 
  z = xabc * y - 1 ; 
  print z ;
  </code></pre>
  
  <p>I was turned on to a program from codeproject.com called Tiny Parser Generator.  Here is the link.  <a href="https://www.codeproject.com/Articles/28294/a-Tiny-Parser-Generator" rel="nofollow noreferrer">https://www.codeproject.com/Articles/28294/a-Tiny-Parser-Generator</a></p>
  
  <p>The simple example given there that allows for the basic mathematical functions on integers I understand.  I was just hoping someone could give me some insight in using this generator in trying to transform my grammar into a grammar that would work with the generator, specifically working with variables, the assign statements (i.e. =), and allowing for multiple lines of code to be written.  Any help would be appreciated, thanks.</p>
  
  <p>Edit- Thanks for the comments. I realize the confusion created over how I worded my question.  The first task I would like to do is to add to the simple expression 2 grammar given by the website tool I linked, the ability to have variables and assignment statements, such as
      x = 5;</p>