anchor.diff:  	;
   
   alternative
  -	: ( p:SEMPRED )* term (element)*
  +	:
  +		( SEMPRED
  +		| ACTION
  +		)*
  +		term
  +		( SEMPRED
  +		| ACTION
  +		)*
  +		( INTO 
  +			( ACTION )*
  +			( term )
  +			( ACTION )*
  +		)?
   		{ ## = #(#[ALTERNATIVE,"ALTERNATIVE"], ##) }
  -	;
  -
  -element
  -	: p:SEMPRED^
  -	| INTO^ term
  -	| a:ACTION^
   	;
   
   term
  
positive.code: 	  )
  	;
  
  element
  	:
  		( p:SEMPRED 
  	        {
                  self.writeln("if not (%s):" % p)
                  self.indent()
                  self.writeln("raise TransformationFailureException")
                  self.deindent()
  	        }
  	    | pattern=mpat:stringify_term
  	        {
                  self.writeln("if not self.factory.match(%r, target, args, kargs):" % pattern)
                  self.indent()
                  self.writeln("raise TransformationFailureException")
                  self.deindent()
                  if not self.is_static_term(#mpat):
                      self.argn = 0
                      self.post_match_term(#mpat)
                      self.writeln("result = self.factory.make(%r, *args, **kargs)" % pattern)
  	        }
  	    )
  	| #( INTO bpat:. )
  		{
              print self.is_static_term(#bpat)
              if self.is_static_term(#bpat):
                  pattern = self.stringify_term(#bpat)
                  self.writeln("result = self.factory.make(%r, *args, **kargs)" % pattern)
              else:
                  pattern = self.build_term(#bpat)
                  self.writeln("result = %s.make(*args, **kargs)" % pattern)
          }
  	| action
  	;
  
  is_static_term returns [ret]
  
negative.code: 	| UCID ( LPAREN! terms RPAREN! )?
  		{ ## = #(#[APPL,"APPL"], ##) }
  	|
  		( LCID^ | WILDCARD^ )
  		( LPAREN! terms RPAREN!
  			{ ## = #(#[APPL,"APPL"], ##) }	
  		)?
  