anchor.diff:  		{ ret = "_f.parse(%r)" % #s.getText() }
   	| c:CONS 
   		{ ret = "_f.makeStr(%r)" % #c.getText() }
  -	| v:VAR 
  -//		{ ret = "_f.makeVar(%r,_f.makeWildcard())" % #v.getText() }
  +	| v:VAR // p=build_term
  +//		{ ret = "_f.makeVar(%r,%s)" % (#v.getText(), p) }
   		{ ret = "_k[%r]" % #v.getText() }
   	| w:WILDCARD 
   //		{ ret = "_f.makeWildcard()" }
  
positive.code: 	;
  
  alternative
  	: ( predicate )* ( INTO ( production )* )?
  		{ ## = #(#[ALTERNATIVE,"ALTERNATIVE"], ##) }
  	;
  
  predicate
  	: ( SEMPRED ) => SEMPRED
  	| ( ACTION ) => ACTION
  	| debug_term
  	;
  
  production
  	: ( ACTION ) => ACTION
  	| debug_term
  	;
  
  debug_term
  
negative.code: 	| STR^
  	| LSQUARE! term_list RSQUARE!
  		{ ## = #(#[LIST,"LIST"], ##) }
  	| term_args
  		{ ## = #(#[APPL,"APPL"], #[CONS,""], ##) }
  	| CONS ( (LPAREN) => term_args | term_nil_list)
  		{ ## = #(#[APPL,"APPL"], ##) }
  	|! VAR args:term_args
  		{ ## = #(#[APPL,"APPL"], #(#VAR, #[WILDCARD,"_"]), #args) }
  	| WILDCARD term_args
  		{ ## = #(#[APPL,"APPL"], ##) }
  	| VAR^ term_pattern
  	| WILDCARD^
  	| TRANSF^ transf_args ( STAR^ )?
  	;
  
  extended_term
  	: term
  	| ACTION^
  	;
  	
  term_args
  	: LPAREN! term_list RPAREN!
  	;
  
  term_pattern
  	:
  		{ ## = #(#[WILDCARD,"_"]) }
  	| ASSIGN! term
  	;
  
  transf_args
  	: LPAREN! ( transf_arg ( COMMA! transf_arg )* )? RPAREN!
  	| 
  	;
  
  transf_arg
  	: extended_term
  	| TRANSF_ADDR^
  	;
  
  term_opt_args
  	: ( LPAREN ) => LPAREN! term_list RPAREN!
  	| term_nil_list
  	;
  	
  term_nil_list
  	:
  		{ ## = #(#[NIL,"NIL"]) }	
  	;
  
  term_list
  	: term_nil_list
  	| extended_term ( COMMA! term_list | term_nil_list )
  		{ ## = #(#[COMMA,","], ##) }	
  	| STAR! term_opt_wildcard
  	;
  	
  term_opt_wildcard
  	: extended_term
  	|
  		{ ## = #(#[WILDCARD,"_"]) }	
  	;
  