Nasty Grammar
----- -------

You have been asked to write a parser for the grammar

        E -> T
        E -> T < E
        T -> F
        T -> F * T
        F -> x
        F -> ( E )
        F -> x < T >

where in the second rule < is used as an operator and
in the last rule < > are used as brackets.  Note that
the grammar is unambiguous (not obvious, but true).  To
keep things simple, the only terminals are x, *, (, ),
<, and >.

With this grammar the parse tree of x<x*x> is

                          E
                          |
                          T
                          |
                       ___F___
                      /  / \  \
                     x  <   |  >
                            |
                         ___T___
                        /   |   \
                       F    *    T
                       |         |
                       x         F
                                 |
                                 x


while the parse tree of x<x<x> is

                       ___E___
                      /   |   \
                     T    <    E
                     |         |
                     F         T
                     |         |
                     x      ___F___
                           /  / \   \
                          x  <   T   >
                                 |
                                 F
                                 |
                                 x


and the parse tree of x<(x<x)> is

                          E
                          |
                          T
                          |
                       ___F___
                      /  / \  \
                     x  <   |  >
                            T
                            |
                         ___F___
                        /   |   \
                       (    |    )
                            |
                         ___E___
                        /   |   \
                       T    <    E
                       |         |
                       F         T
                       |         |
                       x         F
                                 |
                                 x


Note
----

This grammar is a little nastier than JAVA in which
`(t<x.y>)z' is a cast of z to the type `t<x.y>' where
`x.y' is a parameter to the parameterized type `t'.

Input
-----

For each test case, an input string made of terminals
on a line by itself.  Only terminal characters will be
on the line.  The maximum line length is 80 characters.
Input ends with an end of file.


Output
------

For each test case, a single line.  If the input string
is an E, the line contains `accept' followed by the
number of E, F, and T nodes in the parse tree, in the
format indicated by the sample output.  If the input
string is NOT an E, the line merely contains `reject'.


Sample Input
------ -----

x*<x>
x<x*x>
x<x<x>
x<(x<x)>
x<x<x>><x>


Sample Output
------ ------

reject
accept 1E 3T 3F
accept 2E 3T 3F
accept 3E 4T 4F
reject





File:	   nastygrammar.txt
Author:	   Bob Walton <walton@deas.harvard.edu>
Date:	   Thu Oct 17 10:11:07 EDT 2002

The authors have placed this file in the public domain;
they make no warranty and accept no liability for this
file.

RCS Info (may not be true date or author):

    $Author: walton $
    $Date: 2002/10/17 14:26:03 $
    $RCSfile: nastygrammar.txt,v $
    $Revision: 1.3 $