| (?&InlineTable)
)
- (?<NLSeq> \x0D? \x0A)
- (?<NL> (?&NLSeq) | (?&Comment))
-
- (?<WSChar> \x20 | \x09) # (space, tab)
- (?<WS> (?&WSChar)*)
-
- (?<Comment> \x23 .* (?&NLSeq)?)
+ (?<WS> [ \x20 \x09 ]*) # space, tab
+ (?<CRLF> \x0D? \x0A) # cr? lf
+ (?<EOL> (?: \x23 .*)? (?&CRLF)) # crlf or comment -> crlf
#-----------------------------------------------------------------------------
# Array of tables
(?m)
(?s)
- \[\[ (?&Key) \]\] \n
+ \[\[ (?&Key) \]\] (?&EOL)
+
(?:
- (?: (?&KeyValuePair) (?=(?&NLSeq)) )
+ (?: (?&KeyValuePair) (?=(?&CRLF)) )
| (?&ArrayOfTables)
| (?&Table)
)*
# Table
#-----------------------------------------------------------------------------
(?<KeyValuePair> (?&Key) (?&WS) = (?&WS) (?&Value))
- (?<KeyValuePairDecl> (?&Key) (?&WS) = (?&WS) (?&Value) (?&WS) (?&NL))
+ (?<KeyValuePairDecl> (?&Key) (?&WS) = (?&WS) (?&Value) (?&WS) (?&EOL))
(?<KeyValuePairList>
(?&KeyValuePair) (?&WS) (?: [,] (?&WS) (?&KeyValuePairList) )?
}
)
- (?<TableDecl>
- \[ (?&Key) \] \n
- )
+ (?<TableDecl> \[ (?&Key) \] (?&EOL))
(?<Table>
(?&TableDecl)
(?&WS)
[,]
(?&WS)
- (?&NLSeq)?
+ (?&CRLF)?
(?&WS)
)
(?<Array>
\[
- (?&WS) (?&NLSeq)? (?&WS)
+ (?&WS) (?&CRLF)? (?&WS)
(?&List)
- (?&WS) (?&NLSeq)? (?&WS)
+ (?&WS) (?&CRLF)? (?&WS)
\]
)
[^"\\]
| "{1,2} # 1-2 quotation marks
| (?&EscapeChar) # escape
- | (?: \\ (?&NLSeq)) # backslash-terminated line
+ | (?: \\ (?&CRLF)) # backslash-terminated line
)*?
""" # closing triple-quote
)
=head1 RULES
=head2 (?&WS)
-=head2 (?&NL)
-=head2 (?&Comment)
+=head2 (?&EOL)
=head2 (?&Value)
=head3 (?&Boolean)
$str = substr $toml, 3, length($toml) - 6;
my @newlines = $str =~ /(\x0D?\x0A)/g;
$self->{line} += scalar @newlines;
- $str =~ s/^[\x20 \x09]* (?&NL) $TOML//x; # trim leading whitespace
- $str =~ s/\\(?&NL)\s* $TOML//xgs; # trim newlines from lines ending in backslash
+ $str =~ s/^[\x20 \x09]* (?&EOL) $TOML//x; # trim leading whitespace
+ $str =~ s/\\(?&EOL)\s* $TOML//xgs; # trim newlines from lines ending in backslash
} else {
$str = substr($toml, 1, length($toml) - 2);
}