Parse Trees

  • Parse trees show EVERYTHING
    • All code parts
    • All rule names
  • Start with top rule (start symbol / entry point)
  • Given a grammar
    
                assign_stmt -> VAR = exp ;  
                exp -> exp + exp | NUM
                
    Add a program
    
                y = 4 + 5;
                

Parse Trees

    Using the text-based tree drawing, with the below code:
    
                [assign [var y] [=] [exp [exp [num 4] ] [+] [exp [num 5]]] [;]]
                
    it generates the below parse tree: