gonum.org/v1/gonum@v0.14.0/graph/formats/rdf/nquads.rl (about)

     1  // Copyright ©2020 The Gonum Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Ragel grammar definition derived from http://www.w3.org/TR/n-quads/#sec-grammar.
     6  
     7  %%{
     8  	machine nquads;
     9  
    10  	alphtype rune;
    11  
    12  	PN_CHARS_BASE        = [A-Za-z]
    13  	                     | 0x00c0 .. 0x00d6
    14  	                     | 0x00d8 .. 0x00f6
    15  	                     | 0x00f8 .. 0x02ff
    16  	                     | 0x0370 .. 0x037d
    17  	                     | 0x037f .. 0x1fff
    18  	                     | 0x200c .. 0x200d
    19  	                     | 0x2070 .. 0x218f
    20  	                     | 0x2c00 .. 0x2fef
    21  	                     | 0x3001 .. 0xd7ff
    22  	                     | 0xf900 .. 0xfdcf
    23  	                     | 0xfdf0 .. 0xfffd
    24  	                     | 0x10000 .. 0xeffff
    25  	                     ;
    26  
    27  	PN_CHARS_U           = PN_CHARS_BASE | '_' | ':' ;
    28  
    29  	PN_CHARS             = PN_CHARS_U
    30  	                     | '-'
    31  	                     | [0-9]
    32  	                     | 0xb7
    33  	                     | 0x0300 .. 0x036f
    34  	                     | 0x203f .. 0x2040
    35  	                     ;
    36  
    37  	BLANK_NODE_LABEL     = (PN_CHARS_U | [0-9]) ((PN_CHARS | '.')* PN_CHARS)? ;
    38  
    39  	BLANK_NODE           = '_:' BLANK_NODE_LABEL ;
    40  
    41  	ECHAR                = ('\\' [tbnrf"'\\]) ;
    42  
    43  	UCHAR                = ('\\u' xdigit {4}
    44  	                     | '\\U' xdigit {8})
    45  	                     ;
    46  
    47  	STRING_LITERAL       = (
    48  	                       0x00 .. 0x09
    49  	                     | 0x0b .. 0x0c
    50  	                     | 0x0e .. '!'
    51  	                     | '#' .. '['
    52  	                     | ']' .. 0x10ffff
    53  	                     | ECHAR
    54  	                     | UCHAR)*
    55  	                     ;
    56  
    57  	STRING_LITERAL_QUOTE = '"' STRING_LITERAL '"' ;
    58  
    59  	IRI                  = (
    60  	                       '!' .. ';'
    61  	                     | '='
    62  	                     | '?' .. '['
    63  	                     | ']'
    64  	                     | '_'
    65  	                     | 'a' .. 'z'
    66  	                     | '~'
    67  	                     | 0x80 .. 0x10ffff
    68  	                     | UCHAR)*
    69  	                     ;
    70  
    71  	IRIREF               = '<' IRI >StartIRI %EndIRI '>' ;
    72  
    73  	LANGTAG              = '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* ;
    74  
    75  	whitespace           = [ \t] ;
    76  
    77  	literal              = STRING_LITERAL_QUOTE ('^^' IRIREF | LANGTAG)? ;
    78  
    79  	subject              = IRIREF | BLANK_NODE ;
    80  	predicate            = IRIREF ;
    81  	object               = IRIREF | BLANK_NODE | literal ;
    82  	graphLabel           = IRIREF | BLANK_NODE ;
    83  }%%