anchor.diff:  	;
   
   qName
  -	: namespace=ID ':' name=ID -> ^($name $namespace)
  -	| TOK^
  -	| ID^
  +	:	namespace=ID ':' name=ID -> ^($name $namespace)
  +	|	TOK^
  +	|	ID^
   	;
   
  -fragment
  +edge_anno
  +	:	'[' qName EQ text_spec ']' -> ^(EQ qName text_spec)
  +	;
  +
  +precedence
  +	: REF PRECEDENCE REF -> ^(PRECEDENCE  TOK ^(FROM_TO REF REF) ^(RANGE))
  +	| REF PRECEDENCE STAR REF -> ^(PRECEDENCE TOK ^(FROM_TO REF REF) ^(RANGE STAR))
  +	| REF PRECEDENCE min=DIGITS (COMMA max=DIGITS)? REF -> ^(PRECEDENCE TOK ^(FROM_TO REF REF) ^(RANGE $min $max?))
  +	| REF PRECEDENCE layer=ID REF -> ^(PRECEDENCE  $layer ^(FROM_TO REF REF) ^(RANGE))
  +	| REF PRECEDENCE layer=ID STAR REF -> ^(PRECEDENCE $layer ^(FROM_TO REF REF) ^(RANGE STAR))
  +	| REF PRECEDENCE layer=ID COMMA? min=DIGITS (COMMA max=DIGITS)? REF -> ^(PRECEDENCE $layer ^(FROM_TO REF REF) ^(RANGE $min $max?))
  +	;
  +
  +dominance
  +	: REF DOMINANCE REF -> ^(PRECEDENCE  TOK ^(FROM_TO REF REF) ^(RANGE))
  +	| REF DOMINANCE STAR REF -> ^(PRECEDENCE TOK ^(FROM_TO REF REF) ^(RANGE STAR))
  +	| REF DOMINANCE min=DIGITS (COMMA max=DIGITS)? REF -> ^(PRECEDENCE TOK ^(FROM_TO REF REF) ^(RANGE $min $max?))
  +	| REF DOMINANCE layer=ID REF -> ^(PRECEDENCE  $layer ^(FROM_TO REF REF) ^(RANGE))
  +	| REF DOMINANCE layer=ID STAR REF -> ^(PRECEDENCE $layer ^(FROM_TO REF REF) ^(RANGE STAR))
  +	| REF DOMINANCE layer=ID COMMA? min=DIGITS (COMMA max=DIGITS)? REF -> ^(PRECEDENCE $layer ^(FROM_TO REF REF) ^(RANGE $min $max?))
  +	;
  +
   binary_linguistic_term
  -	:	REF IDENT_COV^ REF
  +	:	precedence
  +	|	REF IDENT_COV^ REF
   	|	REF LEFT_ALIGN^ REF
   	|	REF RIGHT_ALIGN^ REF
   	|	REF INCLUSION^ REF
   	|	REF OVERLAP^ REF
   	|	REF RIGHT_OVERLAP^ REF
   	| 	REF LEFT_OVERLAP^REF
  -	|	REF DOMINANCE^ REF
  +	|	dominance
   	|	REF POINTING^ REF
   	|	REF COMMON_PARENT^ REF
   	;
   	
  -fragment
   unary_linguistic_term
   	:	REF ROOT^
   	|	REF ARITY^
  
positive.code: 	ROOT=':root';
  	ARITY=':arity';
  	TOKEN_ARITY=':tokenarity';
  	REF;
  	DIGITS;
  }
  
  @parser::header {package annis.ql;}
  
negative.code: REF
  	:	'#' ( '0' .. '9' )+
  	;
  
  DIGITS : ('0'..'9')+;
  
  
  fragment
  HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;
  