line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: exports regex definitions used to parse TOML source |
2
|
|
|
|
|
|
|
$TOML::Tiny::Grammar::VERSION = '0.15'; |
3
|
|
|
|
|
|
|
use strict; |
4
|
286
|
|
|
286
|
|
1578
|
use warnings; |
|
286
|
|
|
|
|
445
|
|
|
286
|
|
|
|
|
6440
|
|
5
|
286
|
|
|
286
|
|
1116
|
use v5.18; |
|
286
|
|
|
|
|
436
|
|
|
286
|
|
|
|
|
5716
|
|
6
|
286
|
|
|
286
|
|
2349
|
|
|
286
|
|
|
|
|
791
|
|
7
|
|
|
|
|
|
|
use parent 'Exporter'; |
8
|
286
|
|
|
286
|
|
100535
|
|
|
286
|
|
|
|
|
70120
|
|
|
286
|
|
|
|
|
1246
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw( |
10
|
|
|
|
|
|
|
$WS |
11
|
|
|
|
|
|
|
$CRLF |
12
|
|
|
|
|
|
|
$EOL |
13
|
|
|
|
|
|
|
$Comment |
14
|
|
|
|
|
|
|
$NonASCII |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$BareKey |
17
|
|
|
|
|
|
|
$QuotedKey |
18
|
|
|
|
|
|
|
$SimpleKey |
19
|
|
|
|
|
|
|
$DottedKey |
20
|
|
|
|
|
|
|
$Key |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$Boolean |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$Escape |
25
|
|
|
|
|
|
|
$StringLiteral |
26
|
|
|
|
|
|
|
$MultiLineStringLiteral |
27
|
|
|
|
|
|
|
$BasicString |
28
|
|
|
|
|
|
|
$MultiLineString |
29
|
|
|
|
|
|
|
$String |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$Date |
32
|
|
|
|
|
|
|
$Time |
33
|
|
|
|
|
|
|
$DateTime |
34
|
|
|
|
|
|
|
$TimeOffset |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$Hex |
37
|
|
|
|
|
|
|
$Oct |
38
|
|
|
|
|
|
|
$Bin |
39
|
|
|
|
|
|
|
$Dec |
40
|
|
|
|
|
|
|
$Integer |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$Float |
43
|
|
|
|
|
|
|
$SpecialFloat |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
47
|
|
|
|
|
|
|
# Primitives |
48
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
49
|
|
|
|
|
|
|
our $WS = qr/[\x20\x09]/; # space, tab |
50
|
|
|
|
|
|
|
our $CRLF = qr/\x0D?\x0A/; # cr? lf |
51
|
|
|
|
|
|
|
our $CommentChar = qr/(?>[^[:cntrl:]]|\t)/; # non-control chars other than tab |
52
|
|
|
|
|
|
|
our $Comment = qr/\x23$CommentChar*/; # #comment |
53
|
|
|
|
|
|
|
our $EOL = qr/$Comment?$CRLF/; # crlf or comment + crlf |
54
|
|
|
|
|
|
|
our $Boolean = qr/\b(?:true)|(?:false)\b/; |
55
|
|
|
|
|
|
|
our $NonASCII = qr/[\x80-\x{D7FF}\x{E000}-\x{10FFFF}]/; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
58
|
|
|
|
|
|
|
# Strings |
59
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
60
|
|
|
|
|
|
|
our $Escape = qr{ |
61
|
|
|
|
|
|
|
\x5C # leading \ |
62
|
|
|
|
|
|
|
(?> |
63
|
|
|
|
|
|
|
[\x5C"btfnr] # escapes: \\ \" \b \t \n \f \r |
64
|
|
|
|
|
|
|
| (?> u [_0-9a-fA-F]{4}) # unicode (4 bytes) |
65
|
|
|
|
|
|
|
| (?> U [_0-9a-fA-F]{8}) # unicode (8 bytes) |
66
|
|
|
|
|
|
|
) |
67
|
|
|
|
|
|
|
}x; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
our $LiteralChar = qr{ [\x09\x20-\x26\x28-\x7E] | $NonASCII }x; |
70
|
|
|
|
|
|
|
our $StringLiteral = qr{ ' (?: $LiteralChar )* ' }x; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
our $MLLChar = qr{ [\x09\x20-\x26\x28-\x7E] | $NonASCII }x; |
73
|
|
|
|
|
|
|
our $MLLContent = qr{ $MLLChar | $CRLF }x; |
74
|
|
|
|
|
|
|
our $MLLQuotes = qr{ '{1,2} }x; |
75
|
|
|
|
|
|
|
our $MLLBody = qr{ $MLLContent* (?: $MLLQuotes | $MLLContent{0,1} )*? $MLLQuotes? }x; |
76
|
|
|
|
|
|
|
our $MultiLineStringLiteral = qr{ ''' (?: $CRLF? $MLLBody ) ''' }x; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
our $BasicChar = qr{ $WS | [\x21\x23-\x5B\x5D-\x7E] | $NonASCII | $Escape }x; |
79
|
|
|
|
|
|
|
our $BasicString = qr{ " (?: $BasicChar )* " }x; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
our $MLBEscapedNL = qr{ \x5c $WS* $CRLF (?: $WS | $CRLF)* }x; |
82
|
|
|
|
|
|
|
our $MLBUnescaped = qr{ $WS | [\x21\x23-\x5B\x5D-\x7E] | $NonASCII }x; |
83
|
|
|
|
|
|
|
our $MLBQuotes = qr{ "{1,2} }x; |
84
|
|
|
|
|
|
|
our $MLBChar = qr{ $MLBUnescaped | $Escape }x; |
85
|
|
|
|
|
|
|
our $MLBContent = qr{ $MLBChar | $CRLF | $MLBEscapedNL }x; |
86
|
|
|
|
|
|
|
our $MLBasicBody = qr{ $MLBContent* (?: $MLBQuotes | $MLBContent{0,1} )*? $MLBQuotes? }x; |
87
|
|
|
|
|
|
|
our $MultiLineString = qr{ """ $CRLF? $MLBasicBody """ }x; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
our $String = qr/$MultiLineString | $BasicString | $MultiLineStringLiteral | $StringLiteral/x; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
92
|
|
|
|
|
|
|
# Keys |
93
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
94
|
|
|
|
|
|
|
our $BareKey = qr/[-_\p{PosixAlnum}]+/; |
95
|
|
|
|
|
|
|
our $QuotedKey = qr/$BasicString|$StringLiteral/; |
96
|
|
|
|
|
|
|
our $SimpleKey = qr/$QuotedKey|$BareKey/; |
97
|
|
|
|
|
|
|
our $DottedKey = qr/$SimpleKey (?: $WS* \. $WS* $SimpleKey)+/x; |
98
|
|
|
|
|
|
|
our $Key = qr{ (?: $DottedKey | $SimpleKey ) }x; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
102
|
|
|
|
|
|
|
# Dates (RFC 3339) |
103
|
|
|
|
|
|
|
# 1985-04-12T23:20:50.52Z |
104
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
105
|
|
|
|
|
|
|
our $DateFullYear = qr{ \d{4} }x; |
106
|
|
|
|
|
|
|
our $DateMonth = qr{ (?: 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 ) }x; |
107
|
|
|
|
|
|
|
our $DateDay = qr{ (?: 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 ) }x; |
108
|
|
|
|
|
|
|
our $TimeDelim = qr{ (?: [tT] | \x20 ) }x; |
109
|
|
|
|
|
|
|
our $TimeHour = qr{ (?: 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 ) }x; |
110
|
|
|
|
|
|
|
our $TimeMinute = qr{ (?: 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 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 ) }x; |
111
|
|
|
|
|
|
|
our $TimeSecond = qr{ (?: 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 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 ) }x; # may be 60 during leap second |
112
|
|
|
|
|
|
|
our $TimeSecFrac = qr{ \. \d+ }x; |
113
|
|
|
|
|
|
|
our $TimeNumOffset = qr{ (?: [-+] $TimeHour : $TimeMinute ) }x; |
114
|
|
|
|
|
|
|
our $TimeOffset = qr{ (?: [zZ] | $TimeNumOffset ) }x; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
our $PartialTime = qr{ (?: $TimeHour : $TimeMinute : $TimeSecond $TimeSecFrac? ) }x; |
117
|
|
|
|
|
|
|
our $FullTime = qr{ (?: $PartialTime $TimeOffset ) }x; |
118
|
|
|
|
|
|
|
our $FullDate = qr{ (?: $DateFullYear - $DateMonth - $DateDay ) }x; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
our $OffsetDateTime = qr{ (?: $FullDate $TimeDelim $FullTime ) }x; |
121
|
|
|
|
|
|
|
our $LocalDateTime = qr{ (?: $FullDate $TimeDelim $PartialTime ) }x; |
122
|
|
|
|
|
|
|
our $LocalDate = qr{ (?: $FullDate ) }x; |
123
|
|
|
|
|
|
|
our $LocalTime = qr{ (?: $PartialTime ) }x; |
124
|
|
|
|
|
|
|
our $DateTime = qr{ (?: $OffsetDateTime | $LocalDateTime | $LocalDate | $LocalTime ) }x; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
127
|
|
|
|
|
|
|
# Integer |
128
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
129
|
|
|
|
|
|
|
our $DecFirstChar = qr/[1-9]/; |
130
|
|
|
|
|
|
|
our $DecChar = qr/[0-9]/; |
131
|
|
|
|
|
|
|
our $HexChar = qr/[0-9a-fA-F]/; |
132
|
|
|
|
|
|
|
our $OctChar = qr/[0-7]/; |
133
|
|
|
|
|
|
|
our $BinChar = qr/[01]/; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
our $Zero = qr/[-+]? 0/x; |
136
|
|
|
|
|
|
|
our $Hex = qr/0x $HexChar (?> _? $HexChar )*/x; |
137
|
|
|
|
|
|
|
our $Oct = qr/0o $OctChar (?> _? $OctChar )*/x; |
138
|
|
|
|
|
|
|
our $Bin = qr/0b $BinChar (?> _? $BinChar )*/x; |
139
|
|
|
|
|
|
|
our $Dec = qr/$Zero | (?> [-+]? $DecFirstChar (?> _? $DecChar )* )/x; |
140
|
|
|
|
|
|
|
our $Integer = qr/$Hex | $Oct | $Bin | $Dec/x; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
143
|
|
|
|
|
|
|
# Float |
144
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
145
|
|
|
|
|
|
|
our $SpecialFloat = qr/[-+]? (?: (?:inf) | (?:nan) | (?:NaN) )/x; |
146
|
|
|
|
|
|
|
our $Fraction = qr/\. $DecChar (?> _? $DecChar)*/x; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
our $Exponent = qr{ |
149
|
|
|
|
|
|
|
[eE] |
150
|
|
|
|
|
|
|
(?> |
151
|
|
|
|
|
|
|
$Zero+ # dec matches only one zero, but toml exponents apparently accept e00 |
152
|
|
|
|
|
|
|
| $Dec |
153
|
|
|
|
|
|
|
) |
154
|
|
|
|
|
|
|
}x; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
our $Float = qr{ |
157
|
|
|
|
|
|
|
(?> $Dec (?> (?> $Fraction $Exponent?) | $Exponent ) ) |
158
|
|
|
|
|
|
|
| $SpecialFloat |
159
|
|
|
|
|
|
|
}x; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=pod |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=encoding UTF-8 |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 NAME |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
TOML::Tiny::Grammar - exports regex definitions used to parse TOML source |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 VERSION |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
version 0.15 |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 SYNOPSIS |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
use TOML::Tiny::Grammar; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
if ($src =~ /$MultiLineString/) { |
182
|
|
|
|
|
|
|
... |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 DESCRIPTION |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Exports various regexex for parsing TOML source. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 PATTERNS |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 White space and ignorables |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head3 $WS |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head3 $CRLF |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head3 $EOL |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head3 $Comment |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head2 Keys |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head3 $BareKey |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head3 $QuotedKey |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head3 $SimpleKey |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head3 $DottedKey |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head3 $Key |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head2 Values |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head3 $Boolean |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head3 $Escape |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head3 $StringLiteral |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head3 $MultiLineStringLiteral |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head3 $BasicString |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head3 $MultiLineString |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head3 $String |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head3 $Date |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head3 $Time |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head3 $DateTime |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head3 $Hex |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head3 $Oct |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head3 $Bin |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head3 $Dec |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head3 $Integer |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head3 $Float |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head2 $SpecialFloat |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head1 AUTHOR |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
Jeff Ober <sysread@fastmail.fm> |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Jeff Ober. |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
258
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=cut |