Results 1 to 5 of 5

Thread: Parse tree

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2003
    Posts
    149

    Parse tree

    Im working on an assignment and was confused so I was looking for some help not just answers cause I need to understand (test).

    I have these rules:
    1. Expression -> Term | Expression Add_op Term
    2. Term -> Factor | Term Mult_op Factor
    3. Factor -> id | number | '-' Factor | '('Expression')'
    4. Add_op -> '+' | '-'
    5. Mult_op - > '*' | '/'

    I need to draw a parse tree for this:
    5-(3+4)*5

    Here is what I have (its not a perfect tree):
    Code:
                        -------------------E---------------------
                        |                    |                    |      
                  E   A   T                   T   A   T            E      A      T
                  
            (3+4)   -    5                   3   +   4           (3+4)      *     5
    Is anything wrong?

    Thanx
    Last edited by abcdefg; Feb 16th, 2004 at 06:09 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width