anchor.diff:      | A
       ;
   
  +triplesSameSubjectPath
  +    : varOrTerm propertyListNotEmptyPath 
  +    | triplesNode propertyListPath
  +    ;
  +  
  +propertyListNotEmptyPath
  +    : ( verbPath | verbSimple ) objectList ( SEMICOLON ( ( verbPath | verbSimple ) objectList )? )* //-> verbPath* verbSimple* objectList verbPath* 
  +    ;
  +    
  +propertyListPath
  +    : propertyListNotEmpty?
  +    ;
  +    
  +verbPath
  +    : path
  +    ;
  +    
  +verbSimple
  +    : var
  +    ;
  +    	
  +path
  +    : pathSequence ( PIPE pathSequence )*
  +    ; 
  +
  +pathSequence
  +    : pathEltOrInverse ( DIVIDE pathEltOrInverse )*
  +    ;
  +    	  	
  +pathElt
  +    : pathPrimary pathMod?
  +    ;
  +    
  +pathEltOrInverse
  +    : pathElt | INVERSE pathElt
  +    ;
  +    
  +pathMod
  +    : ( ASTERISK | QUESTION_MARK | PLUS | OPEN_CURLY_BRACE ( INTEGER ( COMMA ( CLOSE_CURLY_BRACE | INTEGER CLOSE_CURLY_BRACE ) | CLOSE_CURLY_BRACE ) | COMMA INTEGER CLOSE_CURLY_BRACE ) )
  +    ;
  +
  +pathPrimary
  +    : ( iriRef | A | NEGATION pathNegatedPropertySet | OPEN_BRACE path CLOSE_BRACE )
  +    ;
  +
  +pathNegatedPropertySet
  +    : ( pathOneInPropertySet | OPEN_BRACE ( pathOneInPropertySet ( PIPE pathOneInPropertySet )* )? CLOSE_BRACE )
  +    ;  	
  +
  +pathOneInPropertySet
  +    : INVERSE? ( iriRef | A )
  +    ;
  +	
   triplesNode
  -    : collection
  -    | blankNodePropertyList
  -    ;
  -
  -blankNodePropertyList
  -    : OPEN_SQUARE_BRACE propertyListNotEmpty CLOSE_SQUARE_BRACE
  -    ;
  -
  -collection
  -    : OPEN_BRACE graphNode+ CLOSE_BRACE
  +    : OPEN_BRACE graphNode+ CLOSE_BRACE -> ^(COLLECTION graphNode+)
  +    | OPEN_SQUARE_BRACKET propertyListNotEmpty CLOSE_SQUARE_BRACKET -> ^(BLANKNODEPROPERTYLIST propertyListNotEmpty)
       ;
   
   graphNode
  
positive.code:     | '\uF900'..'\uFDCF'
      | '\uFDF0'..'\uFFFD'
      ;
  
  fragment
  DIGIT
      : '0'..'9'
  
negative.code:  */
  grammar Sparql;
  
  options{
  output = AST;
  }
  
  tokens{
  QUERY;
  UPDATE;
  PROLOGUE;
  SUBSELECT;
  SELECTCLAUSE;
  WHERE_CLAUSE;
  VAR;
  ALIAS;
  GROUPBY;
  ORDERBY;
  ORDERCONDITION;
  BINDINGVALUE;
  TRIPLESTEMPLATE;
  GROUPGRAPHPATTERN;
  GROUPGRAPHPATTERNSUB;
  GRAPHPATTERNNOTTRIPLES;
  TRIPLESBLOCK;
  ARGLIST;
  EXPRESSIONLIST;
  CONSTRUCTTRIPLES;
  PROPERTYLIST;
  COLLECTION;
  BLANKNODEPROPERTYLIST;
  OBJECTLIST;
  NOTEXISTS;
  CONDITIONAL_OR_EXPRESSION;
  CONDITIONAL_AND_EXPRESSION;
  }
  
  @header {
      package com.googlecode.sparkleg;
  }
  