0

I am currently studying Compiler Design and wanted to know if there are other factors (other than operator precedence) that drive an Abstract Syntax Tree construction to be a bottom-up approach.

  1. Is it safe to say that particularly in case of compilers design the abstract syntax tree structure will be constructed always bottom-up?

  2. If yes, what are constraints that will arise going top-down in terms of ambiguity, complexity and feasibility?

P.S. The intent of this question is to get a simple analogy as an answer which addresses it.

What I have read so far is this question on SO and related course material including Wikipedia article but I want the freedom to say that yes they are always and will be constructed bottom-up. I hope there doesn't exist even a failed attempted research to go other ways.

  • I don't know that it will always be bottom up, but certainly from a functional perspective it makes sense to build specific features and work your way up to higher order interactions between operators and operands, expressions, statements, etc., so that everything can be unit tested along the way. If you start from the top, it's much more difficult to coherently test that the compiler is functioning the way you expect it to. – Patrick Roberts Feb 12 '18 at 04:03
  • I assume that topdown parsers produces trees top down ? So no? – Marco van de Voort Feb 12 '18 at 15:59
  • https://stackoverflow.com/questions/47830814/compiler-construction-explicit-parse-trees/47863565#47863565 –  Feb 20 '18 at 14:39

0 Answers0