The Grammer Quiz

1) Make me a grammar for parsing written counting numbers less than one million.  It should parse numbers like "one hundred four thousand twelve", and "sixteen thousand three hundred twenty seven".
 
 
 
 
 
 
 
 

2) Make me a grammer that parses logic expressions.  Use AND and OR for operators.  The literals are TRUE and FALSE.  Examples are "true and (false or true)" and "false or false and true".



 
 
 






3) Evaluate the following expression: 3 2 4 1 + - *

4) Evaluate the following expression: * - + 5 2 7 6

5) Given the following grammer, and the following strings, show the parse tree.

12 % 32 @ 4
12 % |32 @ 4|
12 32 % @ 4
 

<top> =>     <r> % <t>
            =>     <r> # <t>
            =>     <t>
<d>    =>     any number
            =>     | <top> |
<t>     =>     <t> @ <d>
            =>     <t> ! <d>
            =>     <d>