LARA

Modifying a Parser to Construct Trees

Recall our WhileParser.scala

  • each function returned unit (void) type

Now: each function

  • extracts information from tokens
  • obtains information from recursive calls
  • returns a new tree.scala node

Result: ParserTrees.scala (email me any errors you notice)

To try it out:

scalac Lexer.scala Trees.scala ParserTrees.scala
scala -cp . ParserTest isquares.while