Changes between Version 7 and Version 8 of compiler/newdesign


Ignore:
Timestamp:
Mar 17, 2010, 10:45:19 AM (9 years ago)
Author:
eamiri
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • compiler/newdesign

    v7 v8  
    44The 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.
    55
    6 Python 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.
     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 subclassed. Visitor methods for nodes of type X are named visit_X and there is a generic_visit() method as well.
    77
    88== Symbol Table ==
     
    1414numbers 1,2,3,... show lines of code with all bodies collapsed.[[BR]]
    1515if line m is a while loop, m-n means line n in the body of while.[[BR]]
    16 if line m is an if statement then m-0-i refers to line i in the true branch and m-1-i refers to line i in false branch[[BR]]
     16if line m is an if statement then m-0-i refers to line i in the true branch and m-1-i refers to line i in false branch. The problem with this scheme is that numbers in a tuple are not semantically homogeneous.[[BR]]
    1717Implementation of line numbers will use tuples. [[BR]]
    1818