From: Jeff Ober Date: Thu, 16 Jan 2020 20:09:49 +0000 (-0500) Subject: Minor fixups X-Git-Tag: nailing-cargo/1.0.0~234^2~36 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=75ba31be3518b251787eca015f79ec38539a5ef9;p=nailing-cargo.git Minor fixups --- diff --git a/lib/TOML/Tiny/Grammar.pm b/lib/TOML/Tiny/Grammar.pm index 73c58ec..1a7e236 100644 --- a/lib/TOML/Tiny/Grammar.pm +++ b/lib/TOML/Tiny/Grammar.pm @@ -27,13 +27,9 @@ our $TOML = qr{ | (?&InlineTable) ) - (? \x0D? \x0A) - (? (?&NLSeq) | (?&Comment)) - - (? \x20 | \x09) # (space, tab) - (? (?&WSChar)*) - - (? \x23 .* (?&NLSeq)?) + (? [ \x20 \x09 ]*) # space, tab + (? \x0D? \x0A) # cr? lf + (? (?: \x23 .*)? (?&CRLF)) # crlf or comment -> crlf #----------------------------------------------------------------------------- # Array of tables @@ -42,9 +38,10 @@ our $TOML = qr{ (?m) (?s) - \[\[ (?&Key) \]\] \n + \[\[ (?&Key) \]\] (?&EOL) + (?: - (?: (?&KeyValuePair) (?=(?&NLSeq)) ) + (?: (?&KeyValuePair) (?=(?&CRLF)) ) | (?&ArrayOfTables) | (?&Table) )* @@ -57,7 +54,7 @@ our $TOML = qr{ # Table #----------------------------------------------------------------------------- (? (?&Key) (?&WS) = (?&WS) (?&Value)) - (? (?&Key) (?&WS) = (?&WS) (?&Value) (?&WS) (?&NL)) + (? (?&Key) (?&WS) = (?&WS) (?&Value) (?&WS) (?&EOL)) (? (?&KeyValuePair) (?&WS) (?: [,] (?&WS) (?&KeyValuePairList) )? @@ -72,9 +69,7 @@ our $TOML = qr{ } ) - (? - \[ (?&Key) \] \n - ) + (? \[ (?&Key) \] (?&EOL)) (? (?&TableDecl) @@ -91,7 +86,7 @@ our $TOML = qr{ (?&WS) [,] (?&WS) - (?&NLSeq)? + (?&CRLF)? (?&WS) ) @@ -103,11 +98,11 @@ our $TOML = qr{ (? \[ - (?&WS) (?&NLSeq)? (?&WS) + (?&WS) (?&CRLF)? (?&WS) (?&List) - (?&WS) (?&NLSeq)? (?&WS) + (?&WS) (?&CRLF)? (?&WS) \] ) @@ -216,7 +211,7 @@ our $TOML = qr{ [^"\\] | "{1,2} # 1-2 quotation marks | (?&EscapeChar) # escape - | (?: \\ (?&NLSeq)) # backslash-terminated line + | (?: \\ (?&CRLF)) # backslash-terminated line )*? """ # closing triple-quote ) @@ -258,8 +253,7 @@ Exports C<$TOML>, a regex grammar for parsing TOML source. =head1 RULES =head2 (?&WS) -=head2 (?&NL) -=head2 (?&Comment) +=head2 (?&EOL) =head2 (?&Value) =head3 (?&Boolean) diff --git a/lib/TOML/Tiny/Tokenizer.pm b/lib/TOML/Tiny/Tokenizer.pm index 51f78bd..8b58485 100644 --- a/lib/TOML/Tiny/Tokenizer.pm +++ b/lib/TOML/Tiny/Tokenizer.pm @@ -217,8 +217,8 @@ sub tokenize_string { $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); }