first version of new parser

--HG--
branch : trunk
diff --git a/jinja2/nodes.py b/jinja2/nodes.py
index 1e20096..974b4ed 100644
--- a/jinja2/nodes.py
+++ b/jinja2/nodes.py
@@ -14,6 +14,7 @@
 """
 import operator
 from itertools import chain, izip
+from collections import deque
 from copy import copy
 
 
@@ -34,6 +35,21 @@
 }
 
 
+def set_ctx(node, ctx):
+    """
+    Reset the context of a node and all child nodes.  Per default the parser
+    will all generate nodes that have a 'load' context as it's the most common
+    one.  This method is used in the parser to set assignment targets and
+    other nodes to a store context.
+    """
+    todo = deque([node])
+    while todo:
+        node = todo.popleft()
+        if 'ctx' in node._fields:
+            node.ctx = ctx
+        todo.extend(node.iter_child_nodes())
+
+
 class Impossible(Exception):
     """
     Raised if the node could not perform a requested action.
@@ -120,7 +136,7 @@
     """
     Node that represents a template.
     """
-    _fields = ('extends', 'body')
+    _fields = ('body',)
 
 
 class Output(Stmt):
@@ -142,7 +158,7 @@
     """
     A node that represents a for loop
     """
-    _fields = ('item', 'seq', 'body', 'else_', 'recursive')
+    _fields = ('target', 'iter', 'body', 'else_', 'recursive')
 
 
 class If(Stmt):
@@ -208,6 +224,13 @@
     _fields = ('node',)
 
 
+class Assign(Stmt):
+    """
+    Assigns an expression to a target.
+    """
+    _fields = ('target', 'node')
+
+
 class Expr(Node):
     """
     Baseclass for all expressions.
@@ -262,7 +285,7 @@
     """
     any name such as {{ foo }}
     """
-    _fields = ('name',)
+    _fields = ('name', 'ctx')
 
     def can_assign(self):
         return True
@@ -289,7 +312,7 @@
     For loop unpacking and some other things like multiple arguments
     for subscripts.
     """
-    _fields = ('items',)
+    _fields = ('items', 'ctx')
 
     def as_const(self):
         return tuple(x.as_const() for x in self.items)
@@ -350,11 +373,18 @@
     _fields = ('node', 'filters')
 
 
+class FilterCall(Expr):
+    """
+    {{ |bar() }}
+    """
+    _fields = ('name', 'args', 'kwargs', 'dyn_args', 'dyn_kwargs')
+
+
 class Test(Expr):
     """
     {{ foo is lower }}
     """
-    _fields = ('node', 'name', 'args')
+    _fields = ('name', 'args', 'kwargs', 'dyn_args', 'dyn_kwargs')
 
 
 class Call(Expr):
@@ -368,7 +398,7 @@
     """
     {{ foo.bar }} and {{ foo['bar'] }} etc.
     """
-    _fields = ('node', 'arg')
+    _fields = ('node', 'arg', 'ctx')
 
     def as_const(self):
         try:
@@ -404,6 +434,13 @@
     _fields = ('expr', 'ops')
 
 
+class Operand(Helper):
+    """
+    Operator + expression.
+    """
+    _fields = ('op', 'expr')
+
+
 class Mul(BinExpr):
     """
     {{ foo * bar }}