anchor.diff:  DECIMAL               : [+-]? [0-9]* '.' [0-9]+ ;
   DOUBLE                : [+-]? ([0-9]+ '.' [0-9]* EXPONENT | '.'? [0-9]+ EXPONENT) ;
   EXPONENT              : [eE] [+-]? [0-9]+ ;
  -STRING_LITERAL1       : '\'' ([^#x27#x5C#xA#xD] | ECHAR | UCHAR)* '\'' ; /* #x27=' #x5C=\ #xA=new line #xD=carriage return */
  -STRING_LITERAL2       : '"' ([^#x22#x5C#xA#xD] | ECHAR | UCHAR)* '"' ;   /* #x22=" #x5C=\ #xA=new line #xD=carriage return */
  -STRING_LITERAL_LONG1  : '\'\'\'' (('\'' | '\'\'')? ([^\'\\] | ECHAR | UCHAR))* '\'\'\'' ;
  -STRING_LITERAL_LONG2  : '"""' (('"' | '""')? ([^\"\\] | ECHAR | UCHAR))* '"""' ;
  +STRING_LITERAL1       : '\'' (~[\u0027\u005C\u000A\u000D] | ECHAR | UCHAR)* '\'' ; /* #x27=' #x5C=\ #xA=new line #xD=carriage return */
  +STRING_LITERAL2       : '"' (~[\u0022\u005C\u000A\u000D] | ECHAR | UCHAR)* '"' ;   /* #x22=" #x5C=\ #xA=new line #xD=carriage return */
  +STRING_LITERAL_LONG1  : '\'\'\'' (('\'' | '\'\'')? (~[\'\\] | ECHAR | UCHAR))* '\'\'\'' ;
  +STRING_LITERAL_LONG2  : '"""' (('"' | '""')? (~[\"\\] | ECHAR | UCHAR))* '"""' ;
   UCHAR                 : '\\u' HEX HEX HEX HEX | '\\U' HEX HEX HEX HEX HEX HEX HEX HEX ;
   ECHAR                 : '\\' [tbnrf\\\"\'] ;
   WS                    : [\u0020\u0009\u000D\u000A] ; /* #x20=space #x9=character tabulation #xD=carriage return #xA=new line */
  
positive.code: grammar shExDoc;
  
  
  shExDoc 		: directive* ((shape | start | code+) statement*)? ;
  statement		: directive | start | shape ;
  directive       : baseDecl | prefixDecl ;
  baseDecl 		: 'BASE' IRIREF ;
  prefixDecl		: 'PREFIX' PNAME_NS IRIREF ;
  start           : 'start' '=' ( label | typeSpec CODE* ) ;
  shape           : 'VIRTUAL'? label typeSpec CODE* ;
  typeSpec        : include* '{' choiceExpr? '}' ;
  include         : '&' label;
  choiceExpr      : sequenceExpr ( '|' sequenceExpr )* ;
  sequenceExpr    : unaryExpr ( ',' unaryExpr )* ;
  unaryExpr       : id? ( arc | include | '(' choiceExpr ')' repeatCount? CODE* ) ;
  id              : '$' label ;
  label           : iri | blankNode ;
  arc             : '!'? '^'? (RDF_TYPE | iri) valueClass annotation* repeatCount? CODE* ;
  valueClass      : 'LITERAL' xsFacet*
                  | ('IRI' | 'NONLITERAL') ('@' label)? ('PATTERN' string)?
                  | 'BNODE' ('@' label)?
  
negative.code: code			: CODE ;
  
  PASS				  : [ \t\r\n]+ -> skip;
  COMMENT				  : '#' ~[\r\n]* -> skip;
  
  
  CODE                  : '%' ([a-zA-Z+#_][a-zA-Z0-9+#_]*)? '{' (~[%\\] | '\\%')* '%' '}' ;
  
  RDF_TYPE              : 'a' ;
  iriref : IRIREF ;
  IRIREF                : '<' (~[\u0000-\u0020=<>\"{}|^`\\] | UCHAR)* '>' ; /* #x00=NULL #01-#x1F=control codes #x20=space */
  PNAME_NS              : PN_PREFIX? ':' ;
  PNAME_LN              : PNAME_NS PN_LOCAL ;
  BLANK_NODE_LABEL      : '_:' (PN_CHARS_U | [0-9]) ((PN_CHARS | '.')* PN_CHARS)? ;
  