File: nquads.rl

package info (click to toggle)
golang-gonum-v1-gonum 0.15.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,792 kB
  • sloc: asm: 6,252; fortran: 5,271; sh: 377; ruby: 211; makefile: 98
file content (83 lines) | stat: -rw-r--r-- 2,503 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright ©2020 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Ragel grammar definition derived from http://www.w3.org/TR/n-quads/#sec-grammar.

%%{
	machine nquads;

	alphtype rune;

	PN_CHARS_BASE        = [A-Za-z]
	                     | 0x00c0 .. 0x00d6
	                     | 0x00d8 .. 0x00f6
	                     | 0x00f8 .. 0x02ff
	                     | 0x0370 .. 0x037d
	                     | 0x037f .. 0x1fff
	                     | 0x200c .. 0x200d
	                     | 0x2070 .. 0x218f
	                     | 0x2c00 .. 0x2fef
	                     | 0x3001 .. 0xd7ff
	                     | 0xf900 .. 0xfdcf
	                     | 0xfdf0 .. 0xfffd
	                     | 0x10000 .. 0xeffff
	                     ;

	PN_CHARS_U           = PN_CHARS_BASE | '_' | ':' ;

	PN_CHARS             = PN_CHARS_U
	                     | '-'
	                     | [0-9]
	                     | 0xb7
	                     | 0x0300 .. 0x036f
	                     | 0x203f .. 0x2040
	                     ;

	BLANK_NODE_LABEL     = (PN_CHARS_U | [0-9]) ((PN_CHARS | '.')* PN_CHARS)? ;

	BLANK_NODE           = '_:' BLANK_NODE_LABEL ;

	ECHAR                = ('\\' [tbnrf"'\\]) ;

	UCHAR                = ('\\u' xdigit {4}
	                     | '\\U' xdigit {8})
	                     ;

	STRING_LITERAL       = (
	                       0x00 .. 0x09
	                     | 0x0b .. 0x0c
	                     | 0x0e .. '!'
	                     | '#' .. '['
	                     | ']' .. 0x10ffff
	                     | ECHAR
	                     | UCHAR)*
	                     ;

	STRING_LITERAL_QUOTE = '"' STRING_LITERAL '"' ;

	IRI                  = (
	                       '!' .. ';'
	                     | '='
	                     | '?' .. '['
	                     | ']'
	                     | '_'
	                     | 'a' .. 'z'
	                     | '~'
	                     | 0x80 .. 0x10ffff
	                     | UCHAR)*
	                     ;

	IRIREF               = '<' IRI >StartIRI %EndIRI '>' ;

	LANGTAG              = '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* ;

	whitespace           = [ \t] ;

	literal              = STRING_LITERAL_QUOTE ('^^' IRIREF | LANGTAG)? ;

	subject              = IRIREF | BLANK_NODE ;
	predicate            = IRIREF ;
	object               = IRIREF | BLANK_NODE | literal ;
	graphLabel           = IRIREF | BLANK_NODE ;
}%%