Changes between Version 6 and Version 7 of compiler/newdesign


Ignore:
Timestamp:
Mar 15, 2010, 6:58:09 PM (9 years ago)
Author:
eamiri
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • compiler/newdesign

    v6 v7  
    22Usually compiler has a number of passes and each pass traverses the code line by line and each line of code has a specific type from among a few different types. The work that a pass does on each line of code depends on the type of the line. The simplest implementation for this is that each pass, checks the type of each line of code. The main drawback of this solution is that the compiler code cannot be extended easily by introducing new operations.
    33
    4 The solution to this problem is visitor pattern. A good explanation of visitor pattern is available [http://www.butunclebob.com/ArticleS.UncleBob.IuseVisitor here]. To implement it a python ideas suggested [http://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/ here] and [http://nice.sourceforge.net/visitor.html here] are useful. Also python AST module has a visitor method that might have similar functionality.
     4The solution to this problem is visitor pattern. A good explanation of visitor pattern is available [http://www.butunclebob.com/ArticleS.UncleBob.IuseVisitor here]. To implement it a python ideas suggested [http://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/ here] and [http://nice.sourceforge.net/visitor.html here] are useful.
     5
     6Python AST module has two classes NodeVisitor and NodeTransformer that implement visitor pattern. Subclasses of the first class cannot modify the node they are visiting and for this purpose the second class should be subclasses. Visitor methods for nodes of type X are named visit_X and there is a generic_visit() method as well.
    57
    68== Symbol Table ==