Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.compilers    |    Compiler construction, theory, etc. (Mod    |    2,753 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 915 of 2,753    |
|    Hans-Peter Diettrich to leppoc@gmail.com    |
|    Re: about syntax trees    |
|    26 Mar 07 09:11:38    |
   
   From: DrDiettrich1@aol.com   
      
   leppoc@gmail.com wrote:   
      
   > A good idea is to use AST (Abstract Syntax Tree). To do so, make for   
   > each type of Tree, a struct, or object.   
      
   And don't forget to add an node type to the basic node structure, so   
   that a visitor can know who is who. An extended "operator" enum,   
   covering all node types, will be helpful.   
      
   > e.g. in pseudo-code:   
   >   
   > BinOp extends Tree {   
   > Tree leftOperand   
   > Tree rightOperand   
   > Operator operator //+, -, *, /, % ....   
   > }   
   >   
   > IfThenElse extends Tree {   
   > Tree condition   
   > Tree thenPart   
   > Tree elsePart   
   > }   
   >   
   > When you parse it with your recursive descent, you can almost directly   
   > fill those trees.   
      
   Trees should not be write-only. There exists no absolutely best   
   implementation for trees, but the list oriented approach (LISP...) IMO   
   is the most flexible one, with regards to postprocessing of trees.   
      
   DoDi   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca