Build.PL100644000765000024 45512627075071 16000 0ustar00karupanerurastaff000000000000TOML-Parser-0.06# ========================================================================= # THIS FILE IS AUTOMATICALLY GENERATED BY MINILLA. # DO NOT EDIT DIRECTLY. # ========================================================================= use 5.008_001; use strict; use Module::Build::Tiny 0.035; Build_PL(); Changes100644000765000024 124412627075071 16014 0ustar00karupanerurastaff000000000000TOML-Parser-0.06Revision history for Perl extension TOML-Parser 0.06 2015-11-30T16:32:44Z - [FIXED] strict_mode is broken. (tests for strict_mode didn't worked.) - [FEATURE] The v.0.4.0 spec is supported. 0.05 2015-02-18T06:19:11Z - [FIXED] Dependency fixes (dolmen) 0.04 2014-10-08T23:33:32Z - [FIXED] Allow "." in key name. - [INTERNAL] Switch to Module::Build::Tiny. 0.03 2014-05-22T13:22:37Z - [FIXED] Die when key duplicate. - [FIXED] Allow comma at last of array. - [FEATURE] Added `strict_mode`. 0.02 2014-05-20T04:08:28Z - [FIXED] Allow empty comment. - [FIXED] Allow empty string. 0.01 2014-05-13T12:21:22Z - original version LICENSE100644000765000024 4374012627075071 15555 0ustar00karupanerurastaff000000000000TOML-Parser-0.06This software is copyright (c) 2014 by karupanerura . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2014 by karupanerura . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2014 by karupanerura . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End META.json100644000765000024 463412627075071 16150 0ustar00karupanerurastaff000000000000TOML-Parser-0.06{ "abstract" : "simple toml parser", "author" : [ "karupanerura " ], "dynamic_config" : 0, "generated_by" : "Minilla/v3.0.0", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "TOML-Parser", "no_index" : { "directory" : [ "t", "xt", "inc", "share", "eg", "examples", "author", "builder" ] }, "prereqs" : { "configure" : { "requires" : { "Module::Build::Tiny" : "0.035" } }, "develop" : { "requires" : { "JSON" : "2", "Path::Tiny" : "0", "TOML" : "0", "Test::CPAN::Meta" : "0", "Test::MinimumVersion::Fast" : "0.04", "Test::PAUSE::Permissions" : "0.04", "Test::Pod" : "1.41", "Test::Spellunker" : "v0.2.7" } }, "runtime" : { "requires" : { "Encode" : "0", "Exporter" : "5.57", "Types::Serialiser" : "0", "parent" : "0", "perl" : "5.008005" } }, "test" : { "requires" : { "MIME::Base64" : "0", "Storable" : "2.38", "Test::More" : "0.98" } } }, "provides" : { "TOML::Parser" : { "file" : "lib/TOML/Parser.pm", "version" : "0.06" }, "TOML::Parser::Tokenizer" : { "file" : "lib/TOML/Parser/Tokenizer.pm" }, "TOML::Parser::Tokenizer::Strict" : { "file" : "lib/TOML/Parser/Tokenizer/Strict.pm" }, "TOML::Parser::Util" : { "file" : "lib/TOML/Parser/Util.pm" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/karupanerura/TOML-Parser/issues" }, "homepage" : "https://github.com/karupanerura/TOML-Parser", "repository" : { "url" : "git://github.com/karupanerura/TOML-Parser.git", "web" : "https://github.com/karupanerura/TOML-Parser" } }, "version" : "0.06", "x_authority" : "cpan:KARUPA", "x_contributors" : [ "Olivier Mengué ", "karupanerura " ], "x_serialization_backend" : "JSON::PP version 2.27300" } README.md100644000765000024 532012627075071 15777 0ustar00karupanerurastaff000000000000TOML-Parser-0.06[![Build Status](https://travis-ci.org/karupanerura/TOML-Parser.svg?branch=master)](https://travis-ci.org/karupanerura/TOML-Parser) [![Coverage Status](http://codecov.io/github/karupanerura/TOML-Parser/coverage.svg?branch=master)](https://codecov.io/github/karupanerura/TOML-Parser?branch=master) # NAME TOML::Parser - simple toml parser # SYNOPSIS use TOML::Parser; my $parser = TOML::Parser->new; my $data = $parser->parse($toml); # DESCRIPTION TOML::Parser is a simple toml parser. This data structure complies with the tests provided at [https://github.com/toml-lang/toml/tree/v0.4.0/tests](https://github.com/toml-lang/toml/tree/v0.4.0/tests). The v0.4.0 specification is supported. # METHODS - my $parser = TOML::Parser->new(\\%args) Creates a new TOML::Parser instance. use TOML::Parser; # create new parser my $parser = TOML::Parser->new(); Arguments can be: - `inflate_datetime` If use it, You can replace inflate `datetime` process. The subroutine of default is `identity`. `e.g.) sub { $_[0] }` use TOML::Parser; use DateTime; use DateTime::Format::ISO8601; # create new parser my $parser = TOML::Parser->new( inflate_datetime => sub { my $dt = shift; return DateTime::Format::ISO8601->parse_datetime($dt); }, ); - `inflate_boolean` If use it, You can replace inflate boolean process. The return value of default subroutine is `Types::Serialiser::true` or `Types::Serialiser::false`. use TOML::Parser; # create new parser my $parser = TOML::Parser->new( inflate_boolean => sub { my $boolean = shift; return $boolean eq 'true' ? 1 : 0; }, ); - `strict_mode` TOML::Parser is using a more flexible rule for compatibility with old TOML of default. If make this option true value, You can parse a toml with strict rule. use TOML::Parser; # create new parser my $parser = TOML::Parser->new( strict_mode => 1 ); - my $data = $parser->parse\_file($path) - my $data = $parser->parse\_fh($fh) - my $data = $parser->parse($src) Transforms a string containing toml to a perl data structure or vice versa. # SEE ALSO [TOML](https://metacpan.org/pod/TOML) # LICENSE Copyright (C) karupanerura. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. # AUTHOR karupanerura <karupa@cpan.org> # CONTRIBUTOR Olivier Mengu <dolmen@cpan.org> benchmark.pl100755000765000024 311112627075071 20310 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/authoruse strict; use warnings; use utf8; use Benchmark qw/cmpthese timethese/; use TOML; use TOML::Parser; my $parser = TOML::Parser->new(); my $toml = do { local $/; }; cmpthese timethese 10000 => +{ 'TOML' => sub { TOML::from_toml($toml); }, 'TOML::Parser' => sub { $parser->parse($toml); }, }; # Benchmark: timing 10000 iterations of TOML, TOML::Parser... # TOML: 11 wallclock secs (11.11 usr + 0.02 sys = 11.13 CPU) @ 898.47/s (n=10000) # TOML::Parser: 7 wallclock secs ( 6.84 usr + 0.01 sys = 6.85 CPU) @ 1459.85/s (n=10000) # Rate TOML TOML::Parser # TOML 898/s -- -38% # TOML::Parser 1460/s 62% -- __DATA__ # This is a TOML document. Boom. title = "TOML Example" [owner] name = "Tom Preston-Werner" organization = "GitHub" bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." dob = 1979-05-27T07:32:00Z # First class dates? Why not? [database] server = "192.168.1.1" ports = [ 8001, 8001, 8002 ] connection_max = 5000 enabled = true [servers] # You can indent as you please. Tabs or spaces. TOML don't care. [servers.alpha] ip = "10.0.0.1" dc = "eqdc10" [servers.beta] ip = "10.0.0.2" dc = "eqdc10" country = "中国" # This should be parsed as UTF-8 [clients] data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it # Line breaks are OK when inside arrays hosts = [ "alpha", "omega" ] # Products [[products]] name = "Hammer" sku = 738594937 [[products]] name = "Nail" sku = 284758393 color = "gray" extract-toml.sh100755000765000024 15312627075071 20763 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/author#!/bin/bash file=$1 line=`fgrep __DATA__ -n $file | cut -d: -f1` line=`expr $line + 1` tail -n +$line $filetest-case-maker.pl100755000765000024 221412627075071 21346 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/author#!/usr/bin/env perl use strict; use warnings; use utf8; use JSON 2; use Storable qw/nfreeze/; use MIME::Base64; use Path::Tiny; use Data::Dumper (); local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 0; local $Data::Dumper::Sortkeys = 1; my $file = shift @ARGV or die "Usage: $0 target.toml"; my $toml = path($file)->slurp; my $toml_data = decode_json(`ruby -rtoml -rjson -e 'print JSON.dump TOML.load_file("$file")'`); printf <<'...', encode_base64(nfreeze($toml_data)), $file, $toml; use strict; use warnings; use utf8; use Test::More tests => 2; use Storable qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); %s __EXPECTED__ for my $strict_mode (0, 1) { my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => $strict_mode); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "%s: strict: $strict"; } __DATA__ %s ... cpanfile100644000765000024 63512627075071 16210 0ustar00karupanerurastaff000000000000TOML-Parser-0.06requires 'Encode'; requires 'Exporter', '5.57'; requires 'Types::Serialiser'; requires 'parent'; requires 'perl', '5.008005'; on configure => sub { requires 'Module::Build::Tiny', '0.035'; }; on test => sub { requires 'MIME::Base64'; requires 'Storable', '2.38'; requires 'Test::More', '0.98'; }; on develop => sub { requires 'JSON', '2'; requires 'Path::Tiny'; requires 'TOML'; }; Parser.pm100644000765000024 1731012627075071 17655 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/lib/TOMLpackage TOML::Parser; use 5.008005; use strict; use warnings; use Encode; our $VERSION = "0.06"; use TOML::Parser::Tokenizer qw/:constant/; use TOML::Parser::Tokenizer::Strict; use TOML::Parser::Util qw/unescape_str/; use Types::Serialiser; sub new { my $class = shift; my $args = (@_ == 1 and ref $_[0] eq 'HASH') ? +shift : +{ @_ }; return bless +{ inflate_datetime => sub { $_[0] }, inflate_boolean => sub { $_[0] eq 'true' ? Types::Serialiser::true : Types::Serialiser::false }, strict_mode => 0, %$args, } => $class; } sub parse_file { my ($self, $file) = @_; open my $fh, '<:encoding(utf-8)', $file or die $!; return $self->parse_fh($fh); } sub parse_fh { my ($self, $fh) = @_; my $src = do { local $/; <$fh> }; return $self->parse($src); } sub _tokenizer_class { my $self = shift; return $self->{strict_mode} ? 'TOML::Parser::Tokenizer::Strict' : 'TOML::Parser::Tokenizer'; } our @TOKENS; our $ROOT; our $CONTEXT; sub parse { my ($self, $src) = @_; local $ROOT = {}; local $CONTEXT = $ROOT; local @TOKENS = $self->_tokenizer_class->tokenize($src); return $self->_parse_tokens(); } sub _parse_tokens { my $self = shift; while (my $token = shift @TOKENS) { $self->_parse_token($token); } return $CONTEXT; } sub _parse_token { my ($self, $token) = @_; my ($type, $val) = @$token; if ($type eq TOKEN_TABLE) { $self->_parse_table($val); } elsif ($type eq TOKEN_ARRAY_OF_TABLE) { $self->_parse_array_of_table($val); } elsif (my ($key, $value) = $self->_parse_key_and_value($token)) { die "Duplicate key. key:$key" if exists $CONTEXT->{$key}; $CONTEXT->{$key} = $value; } elsif ($type eq TOKEN_COMMENT) { # pass through } else { die "Unknown case. type:$type"; } } sub _parse_key_and_value { my ($self, $token) = @_; my ($type, $val) = @$token; if ($type eq TOKEN_KEY) { my $token = shift @TOKENS; my $key = $val; my $value = $self->_parse_value_token($token); return ($key, $value); } return; } sub _parse_table { my ($self, $keys) = @_; my @keys = @$keys; local $CONTEXT = $ROOT; for my $k (@keys) { if (exists $CONTEXT->{$k}) { $CONTEXT = ref $CONTEXT->{$k} eq 'ARRAY' ? $CONTEXT->{$k}->[-1] : ref $CONTEXT->{$k} eq 'HASH' ? $CONTEXT->{$k} : die "invalid structure. @{[ join '.', @keys ]} cannot be `Table`"; } else { $CONTEXT = $CONTEXT->{$k} ||= +{}; } } $self->_parse_tokens(); } sub _parse_array_of_table { my ($self, $keys) = @_; my @keys = @$keys; my $last_key = pop @keys; local $CONTEXT = $ROOT; for my $k (@keys) { if (exists $CONTEXT->{$k}) { $CONTEXT = ref $CONTEXT->{$k} eq 'ARRAY' ? $CONTEXT->{$k}->[-1] : ref $CONTEXT->{$k} eq 'HASH' ? $CONTEXT->{$k} : die "invalid structure. @{[ join '.', @keys ]} cannot be `Array of table`."; } else { $CONTEXT = $CONTEXT->{$k} ||= +{}; } } $CONTEXT->{$last_key} = [] unless exists $CONTEXT->{$last_key}; die "invalid structure. @{[ join '.', @keys ]} cannot be `Array of table`" unless ref $CONTEXT->{$last_key} eq 'ARRAY'; push @{ $CONTEXT->{$last_key} } => $CONTEXT = {}; $self->_parse_tokens(); } sub _parse_value_token { my $self = shift; my $token = shift; my ($type, $val) = @$token; if ($type eq TOKEN_COMMENT) { return; # pass through } elsif ($type eq TOKEN_INTEGER || $type eq TOKEN_FLOAT) { $val =~ tr/_//d; return 0+$val; } elsif ($type eq TOKEN_BOOLEAN) { return $self->inflate_boolean($val); } elsif ($type eq TOKEN_DATETIME) { return $self->inflate_datetime($val); } elsif ($type eq TOKEN_STRING) { return unescape_str($val); } elsif ($type eq TOKEN_MULTI_LINE_STRING_BEGIN) { my $value = $self->_parse_value_token(shift @TOKENS); $value =~ s/\A\s+//msg; $value =~ s/\\\s+//msg; if (my $token = shift @TOKENS) { my ($type) = @$token; return $value if $type eq TOKEN_MULTI_LINE_STRING_END; die "Unexpected token: $type"; } } elsif ($type eq TOKEN_INLINE_TABLE_BEGIN) { my %data; while (my $token = shift @TOKENS) { last if $token->[0] eq TOKEN_INLINE_TABLE_END; my ($key, $value) = $self->_parse_key_and_value($token); die "Duplicate key. key:$key" if exists $data{$key}; $data{$key} = $value; } return \%data; } elsif ($type eq TOKEN_ARRAY_BEGIN) { my @data; my $last_token; while (my $token = shift @TOKENS) { last if $token->[0] eq TOKEN_ARRAY_END; if ($self->{strict_mode} && $token->[0] ne TOKEN_COMMENT) { die "Unexpected token: $token->[0]" if defined $last_token && $token->[0] ne $last_token->[0]; } push @data => $self->_parse_value_token($token); $last_token = $token; } return \@data; } die "Unexpected token: $type"; } sub inflate_datetime { my $self = shift; return $self->{inflate_datetime}->(@_); } sub inflate_boolean { my $self = shift; return $self->{inflate_boolean}->(@_); } 1; __END__ =encoding utf-8 =for stopwords versa =head1 NAME TOML::Parser - simple toml parser =head1 SYNOPSIS use TOML::Parser; my $parser = TOML::Parser->new; my $data = $parser->parse($toml); =head1 DESCRIPTION TOML::Parser is a simple toml parser. This data structure complies with the tests provided at L. The v0.4.0 specification is supported. =head1 METHODS =over =item my $parser = TOML::Parser->new(\%args) Creates a new TOML::Parser instance. use TOML::Parser; # create new parser my $parser = TOML::Parser->new(); Arguments can be: =over =item * C If use it, You can replace inflate C process. The subroutine of default is C. C use TOML::Parser; use DateTime; use DateTime::Format::ISO8601; # create new parser my $parser = TOML::Parser->new( inflate_datetime => sub { my $dt = shift; return DateTime::Format::ISO8601->parse_datetime($dt); }, ); =item * C If use it, You can replace inflate boolean process. The return value of default subroutine is C or C. use TOML::Parser; # create new parser my $parser = TOML::Parser->new( inflate_boolean => sub { my $boolean = shift; return $boolean eq 'true' ? 1 : 0; }, ); =item * C TOML::Parser is using a more flexible rule for compatibility with old TOML of default. If make this option true value, You can parse a toml with strict rule. use TOML::Parser; # create new parser my $parser = TOML::Parser->new( strict_mode => 1 ); =back =item my $data = $parser->parse_file($path) =item my $data = $parser->parse_fh($fh) =item my $data = $parser->parse($src) Transforms a string containing toml to a perl data structure or vice versa. =back =head1 SEE ALSO L =head1 LICENSE Copyright (C) karupanerura. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR karupanerura Ekarupa@cpan.orgE =head1 CONTRIBUTOR Olivier Mengué Edolmen@cpan.orgE =cut Tokenizer.pm100644000765000024 2426012627075071 21631 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/lib/TOML/Parserpackage TOML::Parser::Tokenizer; use 5.008005; use strict; use warnings; use Exporter 5.57 'import'; use constant DEBUG => $ENV{TOML_PARSER_TOKENIZER_DEBUG} ? 1 : 0; BEGIN { my @TOKENS = map uc, qw/ comment table array_of_table key integer float boolean datetime string multi_line_string_begin multi_line_string_end inline_table_begin inline_table_end array_begin array_end /; my %CONSTANTS = map { ("TOKEN_$_" => $_) } @TOKENS; require constant; constant->import(\%CONSTANTS); # Exporter our @EXPORT_OK = keys %CONSTANTS; our %EXPORT_TAGS = ( constant => [keys %CONSTANTS], ); }; sub grammar_regexp { return +{ comment => qr{#(.*)}, table => { start => qr{\[}, key => qr{(?:"(.*?)(? qr{\.}, end => qr{\]}, }, array_of_table => { start => qr{\[\[}, key => qr{(?:"(.*?)(? qr{\.}, end => qr{\]\]}, }, key => qr{(?:"(.*?)(? { datetime => qr{([0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]+)?(?:Z|[-+][0-9]{2}:[0-9]{2}))}, float => qr{([-+]?(?:[0-9_]+(?:\.[0-9_]+)?[eE][-+]?[0-9_]+|[0-9_]*\.[0-9_]+))}, integer => qr{([-+]?[0-9_]+)}, boolean => qr{(true|false)}, string => qr{(?:"(.*?)(? qr{("""|''')}, inline => { start => qr{\{}, sep => qr{\s*,\s*}, end => qr{\}}, }, array => { start => qr{\[}, sep => qr{\s*,\s*}, end => qr{\]}, }, }, }; } sub tokenize { my ($class, $src) = @_; local $_ = $src; return $class->_tokenize(); } sub _tokenize { my $class = shift; my $grammar_regexp = $class->grammar_regexp(); my @tokens; until (/\G\z/mgco) { if (/\G$grammar_regexp->{comment}/mgc) { warn "[TOKEN] COMMENT: $1" if DEBUG; $class->_skip_whitespace(); push @tokens => [TOKEN_COMMENT, $1 || '']; } elsif (/\G$grammar_regexp->{array_of_table}->{start}/mgc) { push @tokens => $class->_tokenize_array_of_table(); } elsif (/\G$grammar_regexp->{table}->{start}/mgc) { push @tokens => $class->_tokenize_table(); } elsif (my @t = $class->_tokenize_key_and_value()) { push @tokens => @t; } elsif (/\G\s+/mgco) { # pass through $class->_skip_whitespace(); } else { $class->_syntax_error(); } } return @tokens; } sub _tokenize_key_and_value { my $class = shift; my $grammar_regexp = $class->grammar_regexp(); my @tokens; if (/\G$grammar_regexp->{key}/mgc) { my $key = $1 || $2 || $3; warn "[TOKEN] KEY: $key" if DEBUG; $class->_skip_whitespace(); push @tokens => [TOKEN_KEY, $key]; push @tokens => $class->_tokenize_value(); return @tokens; } return; } sub _tokenize_value { my $class = shift; my $grammar_regexp = $class->grammar_regexp(); warn "[CALL] _tokenize_value" if DEBUG; if (/\G$grammar_regexp->{comment}/mgc) { warn "[TOKEN] COMMENT: $1" if DEBUG; $class->_skip_whitespace(); return [TOKEN_COMMENT, $1 || '']; } elsif (/\G$grammar_regexp->{value}->{datetime}/mgc) { warn "[TOKEN] DATETIME: $1" if DEBUG; $class->_skip_whitespace(); return [TOKEN_DATETIME, $1]; } elsif (/\G$grammar_regexp->{value}->{float}/mgc) { warn "[TOKEN] FLOAT: $1" if DEBUG; $class->_skip_whitespace(); return [TOKEN_FLOAT, $1]; } elsif (/\G$grammar_regexp->{value}->{integer}/mgc) { warn "[TOKEN] INTEGER: $1" if DEBUG; $class->_skip_whitespace(); return [TOKEN_INTEGER, $1]; } elsif (/\G$grammar_regexp->{value}->{boolean}/mgc) { warn "[TOKEN] BOOLEAN: $1" if DEBUG; $class->_skip_whitespace(); return [TOKEN_BOOLEAN, $1]; } elsif (/\G$grammar_regexp->{value}->{mlstring}/mgc) { warn "[TOKEN] BOOLEAN: $1" if DEBUG; return ( [TOKEN_MULTI_LINE_STRING_BEGIN], $class->_extract_multi_line_string($1), [TOKEN_MULTI_LINE_STRING_END], ); } elsif (/\G$grammar_regexp->{value}->{string}/mgc) { warn "[TOKEN] STRING: $1" if DEBUG; $class->_skip_whitespace(); return [TOKEN_STRING, $1 || $2 || '']; } elsif (/\G$grammar_regexp->{value}->{inline}->{start}/mgc) { warn "[TOKEN] INLINE TABLE" if DEBUG; $class->_skip_whitespace(); return ( [TOKEN_INLINE_TABLE_BEGIN], $class->_tokenize_inline_table(), [TOKEN_INLINE_TABLE_END], ); } elsif (/\G$grammar_regexp->{value}->{array}->{start}/mgc) { warn "[TOKEN] ARRAY" if DEBUG; $class->_skip_whitespace(); return ( [TOKEN_ARRAY_BEGIN], $class->_tokenize_array(), [TOKEN_ARRAY_END], ); } $class->_syntax_error(); } sub _tokenize_table { my $class = shift; my $grammar_regexp = $class->grammar_regexp()->{table}; warn "[CALL] _tokenize_table" if DEBUG; $class->_skip_whitespace(); my @expected = ($grammar_regexp->{key}); my @keys; LOOP: while (1) { for my $rx (@expected) { if (/\G$rx/smgc) { if ($rx eq $grammar_regexp->{key}) { my $key = $1 || $2 || $3; warn "[TOKEN] table key: $key" if DEBUG; push @keys => $key; @expected = ($grammar_regexp->{sep}, $grammar_regexp->{end}); } elsif ($rx eq $grammar_regexp->{sep}) { warn "[TOKEN] table key separator" if DEBUG; @expected = ($grammar_regexp->{key}); } elsif ($rx eq $grammar_regexp->{end}) { warn "[TOKEN] table key end" if DEBUG; @expected = (); last LOOP; } $class->_skip_whitespace(); next LOOP; } } $class->_syntax_error(); } warn "[TOKEN] TABLE: @{[ join '.', @keys ]}" if DEBUG; return [TOKEN_TABLE, \@keys]; } sub _tokenize_array_of_table { my $class = shift; my $grammar_regexp = $class->grammar_regexp()->{array_of_table}; warn "[CALL] _tokenize_array_of_table" if DEBUG; $class->_skip_whitespace(); my @expected = ($grammar_regexp->{key}); my @keys; LOOP: while (1) { for my $rx (@expected) { if (/\G$rx/smgc) { if ($rx eq $grammar_regexp->{key}) { my $key = $1 || $2 || $3; warn "[TOKEN] table key: $key" if DEBUG; push @keys => $key; @expected = ($grammar_regexp->{sep}, $grammar_regexp->{end}); } elsif ($rx eq $grammar_regexp->{sep}) { warn "[TOKEN] table key separator" if DEBUG; @expected = ($grammar_regexp->{key}); } elsif ($rx eq $grammar_regexp->{end}) { warn "[TOKEN] table key end" if DEBUG; @expected = (); last LOOP; } $class->_skip_whitespace(); next LOOP; } } $class->_syntax_error(); } warn "[TOKEN] ARRAY_OF_TABLE: @{[ join '.', @keys ]}" if DEBUG; return [TOKEN_ARRAY_OF_TABLE, \@keys]; } sub _extract_multi_line_string { my ($class, $delimiter) = @_; if (/\G(.+?)\Q$delimiter/smgc) { warn "[TOKEN] MULTI LINE STRING: $1" if DEBUG; $class->_skip_whitespace(); return [TOKEN_STRING, $1]; } $class->_syntax_error(); } sub _tokenize_inline_table { my $class = shift; my $grammar_regexp = $class->grammar_regexp()->{value}->{inline}; warn "[CALL] _tokenize_inline_table" if DEBUG; return if /\G(?:$grammar_regexp->{sep})?$grammar_regexp->{end}/smgc; my @tokens = $class->_tokenize_key_and_value(); while (/\G$grammar_regexp->{sep}/smgc || !/\G$grammar_regexp->{end}/mgc) { last if /\G$grammar_regexp->{end}/mgc; warn "[CONTEXT] _tokenize_inline_table [loop]" if DEBUG; $class->_skip_whitespace(); push @tokens => $class->_tokenize_key_and_value(); $class->_skip_whitespace(); } return @tokens; } sub _tokenize_array { my $class = shift; my $grammar_regexp = $class->grammar_regexp()->{value}->{array}; warn "[CALL] _tokenize_array" if DEBUG; return if /\G(?:$grammar_regexp->{sep})?$grammar_regexp->{end}/smgc; my @tokens = $class->_tokenize_value(); while (/\G$grammar_regexp->{sep}/smgc || !/\G$grammar_regexp->{end}/mgc) { last if /\G$grammar_regexp->{end}/mgc; warn "[CONTEXT] _tokenize_array [loop]" if DEBUG; $class->_skip_whitespace(); push @tokens => $class->_tokenize_value(); $class->_skip_whitespace(); } return @tokens; } sub _skip_whitespace { my $class = shift; if (/\G\s+/smgco) { # pass through warn "[PASS] WHITESPACE" if DEBUG; } } sub _syntax_error { shift->_error('Syntax Error') } sub _error { my ($class, $msg) = @_; my $src = $_; my $line = 1; my $start = pos $src || 0; while ($src =~ /$/smgco and pos $src <= pos) { $start = pos $src; $line++; } my $end = pos $src; my $len = pos() - $start; $len-- if $len > 0; my $trace = join "\n", "${msg}: line:$line", substr($src, $start || 0, $end - $start), (' ' x $len) . '^'; die $trace, "\n"; } 1; __END__ Strict.pm100644000765000024 137312627075071 23061 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/lib/TOML/Parser/Tokenizerpackage TOML::Parser::Tokenizer::Strict; use 5.008005; use strict; use warnings; use parent qw/TOML::Parser::Tokenizer/; BEGIN { import TOML::Parser::Tokenizer qw/:constant/ } sub grammar_regexp { my $grammar_regexp = {%{ shift->SUPER::grammar_regexp() }}; $grammar_regexp->{table} = {%{ $grammar_regexp->{table} }}; $grammar_regexp->{array_of_table} = {%{ $grammar_regexp->{array_of_table} }}; $grammar_regexp->{table}->{key} = qr{(?:"(.*?)(?{array_of_table}->{key} = qr{(?:"(.*?)(?{key} = qr{(?:"(.*?)(? 3; use_ok $_ for qw( TOML::Parser TOML::Parser::Tokenizer TOML::Parser::Util ); broken.t100644000765000024 417412627075071 20312 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use Test::More tests => 15; use TOML::Parser; eval { TOML::Parser->new->parse(<<'...'); foo = "bar' ... }; like $@, qr/\ASyntax Error: line:1/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); xxx = "yyy" foo = "bar' ... }; like $@, qr/\ASyntax Error: line:2/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); xxx = "yyy" # comment # and, empty line foo = "bar' ... }; like $@, qr/\ASyntax Error: line:5/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); [] ... }; like $@, qr/\ASyntax Error: line:1/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); [a.] ... }; like $@, qr/\ASyntax Error: line:1/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); [a..b] ... }; like $@, qr/\ASyntax Error: line:1/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); [.b] ... }; like $@, qr/\ASyntax Error: line:1/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); [.] ... }; like $@, qr/\ASyntax Error: line:1/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); = "no key name" # not allowed ... }; like $@, qr/\ASyntax Error: line:1/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); [[]] ... }; like $@, qr/\ASyntax Error: line:1/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); [[a.]] ... }; like $@, qr/\ASyntax Error: line:1/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); [[a..b]] ... }; like $@, qr/\ASyntax Error: line:1/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); [[.b]] ... }; like $@, qr/\ASyntax Error: line:1/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); [[.]] ... }; like $@, qr/\ASyntax Error: line:1/m, 'detect syntax error' or diag $@; eval { TOML::Parser->new->parse(<<'...'); key = """ never ending multi line string ... }; like $@, qr/\ASyntax Error: line:2/m, 'detect syntax error' or diag $@; comma_at_last_of_array.t100644000765000024 151512627075071 23513 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use Storable 2.38 qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); BQkDAAAAAgQCAAAAAQiBAAAABmFycmF5MQQCAAAAAgQCAAAAAQiCBAIAAAACCIMIhAAAAAZhcnJh eTI= __EXPECTED__ for my $strict (0, 1) { my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => $strict); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "t/toml/comma_at_last_of_array.toml: strict: $strict"; } __DATA__ array1 = [1,] array2 = [ [ 2 ], [ 3, 4, ] # empty!! , ] dot_in_key.t100644000765000024 145312627075071 21153 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use Storable 2.38 qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); BQoDAAAAAgoHRm9vLkJhcgAAAAdGb28uQmFyCgZGb29CYXIAAAAGRm9vQmFy __EXPECTED__ my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "t/toml/dot_in_key.toml"; eval { TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => 1)->parse($toml) }; like $@, qr/\ASyntax Error: line:2/m; __DATA__ FooBar="FooBar" Foo.Bar="Foo.Bar" duplicate_key.t100644000765000024 241112627075071 21644 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use Test::More tests => 6; use TOML::Parser; eval { TOML::Parser->new->parse(<<'...'); foo = "foo" hoge = "fuga" ... }; is $@, '', 'should live when another key'; eval { TOML::Parser->new->parse(<<'...'); foo = "foo" hoge = "fuga" [bar] foo = "foo" hoge = "fuga" [baz] foo = "foo" hoge = "fuga" ... }; is $@, '', 'should live when another table'; eval { TOML::Parser->new->parse(<<'...'); foo = "foo" hoge = "fuga" [[bar]] foo = "foo" hoge = "fuga" [[bar]] foo = "foo" hoge = "fuga" ... }; is $@, '', 'should live when another array of table'; eval { my $data = TOML::Parser->new->parse(<<'...'); foo = "foo" foo = "foo" ... note explain $data; }; like $@, qr/^\QDuplicate key. key:foo/, 'should die when same key'; eval { my $data = TOML::Parser->new->parse(<<'...'); foo = "foo" hoge = "fuga" [bar] foo = "foo" foo = "foo" [baz] foo = "foo" hoge = "fuga" ... note explain $data; }; like $@, qr/^\QDuplicate key. key:foo/, 'should die when same key in table'; eval { my $data = TOML::Parser->new->parse(<<'...'); foo = "foo" hoge = "fuga" [[bar]] foo = "foo" foo = "foo" [[bar]] foo = "foo" hoge = "fuga" ... note explain $data; }; like $@, qr/^\QDuplicate key. key:foo/, 'should die when same key in array of table'; empty_array.t100644000765000024 136012627075071 21360 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use Storable 2.38 qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); BQkDAAAAAgQCAAAAAAAAAAZhcnJheTEEAgAAAAAAAAAGYXJyYXky __EXPECTED__ for my $strict (0, 1) { my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => $strict); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "t/toml/empty_array.toml: strict: $strict"; } __DATA__ array1 = [] array2 = [ # empty!! ] empty_comment.t100644000765000024 135512627075071 21710 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = +{ aaaa => 1, bbbb => 2.5, cccc => Types::Serialiser::true(), dddd => 'dddd', }; for my $strict (0, 1) { my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => $strict); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "t/toml/empty_comment.toml: strict: $strict"; } __DATA__ # # # fooo # aaaa = 1 # bbbb = 2.5# cccc = true# cccc # # #aaaa dddd="dddd" empty_string.t100644000765000024 130012627075071 21542 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use Storable 2.38 qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); BQkDAAAAAQoAAAAABnN0cmluZw== __EXPECTED__ for my $strict (0, 1) { my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => $strict); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "t/toml/empty_string.toml: strict: $strict"; } __DATA__ string = "" escape.t100644000765000024 47112627075071 20246 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 1; use TOML::Parser; my $dat = TOML::Parser->new->parse(<<'...'); all="\b\t\n\f\r\"\/\\" unichar="\u0022" unichar8="\U00000022" ... is_deeply $dat, +{ all => "\x08\x09\x0A\x0C\x0D\x22\x2F\x5C", unichar => q{"}, unichar8 => q{"}, }; example.t100644000765000024 452212627075071 20462 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use Storable 2.38 qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); BQkDAAAABgoMVE9NTCBFeGFtcGxlAAAABXRpdGxlBAMAAAAEChkxOTc5LTA1LTI3VDA3OjMyOjAw KzAwOjAwAAAAA2RvYgoxR2l0SHViIENvZm91bmRlciAmIENFTwpMaWtlcyB0YXRlciB0b3RzIGFu ZCBiZWVyLgAAAANiaW8KBkdpdEh1YgAAAAxvcmdhbml6YXRpb24KElRvbSBQcmVzdG9uLVdlcm5l cgAAAARuYW1lAAAABW93bmVyBAMAAAACBAMAAAACCgZlcWRjMTAAAAACZGMKCDEwLjAuMC4xAAAA AmlwAAAABWFscGhhBAMAAAADCgZlcWRjMTAAAAACZGMXBuS4reWbvQAAAAdjb3VudHJ5CggxMC4w LjAuMgAAAAJpcAAAAARiZXRhAAAAB3NlcnZlcnMEAwAAAAIEAgAAAAIKBWFscGhhCgVvbWVnYQAA AAVob3N0cwQCAAAAAgQCAAAAAgoFZ2FtbWEKBWRlbHRhBAIAAAACCIEIggAAAARkYXRhAAAAB2Ns aWVudHMEAgAAAAIEAwAAAAIJLAYQeQAAAANza3UKBkhhbW1lcgAAAARuYW1lBAMAAAADCgROYWls AAAABG5hbWUKBGdyYXkAAAAFY29sb3IJEPkReQAAAANza3UAAAAIcHJvZHVjdHMEAwAAAAQEAgAA AAMJAAAfQQkAAB9BCQAAH0IAAAAFcG9ydHMKCzE5Mi4xNjguMS4xAAAABnNlcnZlchQREUpTT046 OlBQOjpCb29sZWFuCIEAAAAHZW5hYmxlZAkAABOIAAAADmNvbm5lY3Rpb25fbWF4AAAACGRhdGFi YXNl __EXPECTED__ for my $strict (0, 1) { my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => $strict); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "t/toml/example.toml: strict: $strict"; } __DATA__ # This is a TOML document. Boom. title = "TOML Example" [owner] name = "Tom Preston-Werner" organization = "GitHub" bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." dob = 1979-05-27T07:32:00Z # First class dates? Why not? [database] server = "192.168.1.1" ports = [ 8001, 8001, 8002 ] connection_max = 5000 enabled = true [servers] # You can indent as you please. Tabs or spaces. TOML don't care. [servers.alpha] ip = "10.0.0.1" dc = "eqdc10" [servers.beta] ip = "10.0.0.2" dc = "eqdc10" country = "中国" # This should be parsed as UTF-8 [clients] data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it # Line breaks are OK when inside arrays hosts = [ "alpha", "omega" ] # Products [[products]] name = "Hammer" sku = 738594937 [[products]] name = "Nail" sku = 284758393 color = "gray" example_fruit.t100644000765000024 230712627075071 21672 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use Storable 2.38 qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); BQkDAAAAAQQCAAAAAgQDAAAAAwQCAAAAAgQDAAAAAQoNcmVkIGRlbGljaW91cwAAAARuYW1lBAMA AAABCgxncmFubnkgc21pdGgAAAAEbmFtZQAAAAd2YXJpZXR5CgVhcHBsZQAAAARuYW1lBAMAAAAC CgVyb3VuZAAAAAVzaGFwZQoDcmVkAAAABWNvbG9yAAAACHBoeXNpY2FsBAMAAAACBAIAAAABBAMA AAABCghwbGFudGFpbgAAAARuYW1lAAAAB3ZhcmlldHkKBmJhbmFuYQAAAARuYW1lAAAABWZydWl0 __EXPECTED__ for my $strict (0, 1) { my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => $strict); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "t/toml/example_fruit.toml: strict: $strict"; } __DATA__ [[fruit]] name = "apple" [fruit.physical] color = "red" shape = "round" [[fruit.variety]] name = "red delicious" [[fruit.variety]] name = "granny smith" [[fruit]] name = "banana" [[fruit.variety]] name = "plantain" float.t100644000765000024 173712627075071 20141 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use Storable qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); BQoDAAAACQoGMy4xNDE1AAAABGtleTIIgQAAAARrZXkxChA5MjI0NjE3LjQ0NTk5MTIzAAAABGtl eTgKBTVlKzIyAAAABGtleTQKBS0wLjAyAAAABGtleTYKCTYuNjI2ZS0zNAAAAARrZXk3CgUtMC4w MQAAAARrZXkzCQAPQkAAAAAEa2V5NQoGMWUrMTAwAAAABGtleTk= __EXPECTED__ for my $strict (0, 1) { my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => $strict); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "float.toml: strict: $strict"; } __DATA__ key1 = +1.0 key2 = 3.1415 key3 = -0.01 key4 = 5e+22 key5 = 1e6 key6 = -2E-2 key7 = 6.626e-34 key8 = 9_224_617.445_991_228_313 key9 = 1e1_00 hard_example.t100644000765000024 517312627075071 21463 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use Storable 2.38 qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); BQkDAAAAAQQDAAAAAgQDAAAABQQCAAAAAgoCXSAKAyAjIAAAAAp0ZXN0X2FycmF5CiAgU2FtZSB0 aGluZywgYnV0IHdpdGggYSBzdHJpbmcgIwAAABNhbm90aGVyX3Rlc3Rfc3RyaW5nCi8gQW5kIHdo ZW4gIidzIGFyZSBpbiB0aGUgc3RyaW5nLCBhbG9uZyB3aXRoICMgIgAAABJoYXJkZXJfdGVzdF9z dHJpbmcEAgAAAAIKFVRlc3QgIzExIF1wcm92ZWQgdGhhdAobRXhwZXJpbWVudCAjOSB3YXMgYSBz dWNjZXNzAAAAC3Rlc3RfYXJyYXkyBAMAAAACCihZb3UgZG9uJ3QgdGhpbmsgc29tZSB1c2VyIHdv bid0IGRvIHRoYXQ/AAAABXdoYXQ/BAIAAAABCgFdAAAAEG11bHRpX2xpbmVfYXJyYXkAAAAEYml0 IwAAAARoYXJkCh1Zb3UnbGwgaGF0ZSBtZSBhZnRlciB0aGlzIC0gIwAAAAt0ZXN0X3N0cmluZwAA AAN0aGU= __EXPECTED__ my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "t/toml/hard_example.toml"; eval { TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => 1)->parse($toml) }; like $@, qr{\ASyntax Error: line:16}m; __DATA__ # Test file for TOML # Only this one tries to emulate a TOML file written by a user of the kind of parser writers probably hate # This part you'll really hate [the] test_string = "You'll hate me after this - #" # " Annoying, isn't it? [the.hard] test_array = [ "] ", " # "] # ] There you go, parse this! test_array2 = [ "Test #11 ]proved that", "Experiment #9 was a success" ] # You didn't think it'd as easy as chucking out the last #, did you? another_test_string = " Same thing, but with a string #" harder_test_string = " And when \"'s are in the string, along with # \"" # "and comments are there too" # Things will get harder [the.hard.bit#] what? = "You don't think some user won't do that?" multi_line_array = [ "]", # ] Oh yes I did ] # Each of the following keygroups/key value pairs should produce an error. Uncomment to them to test #[error] if you didn't catch this, your parser is broken #string = "Anything other than tabs, spaces and newline after a keygroup or key value pair has ended should produce an error unless it is a comment" like this #array = [ # "This might most likely happen in multiline arrays", # Like here, # "or here, # and here" # ] End of array comment, forgot the # #number = 3.14 pi <--again forgot the # inline_table.t100644000765000024 210012627075071 21442 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use Storable qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); BQoDAAAAAwQDAAAAAgiBAAAAAXgIggAAAAF5AAAABXBvaW50BAIAAAADBAMAAAADCIIAAAABeQiD AAAAAXoIgQAAAAF4BAMAAAADCIkAAAABegiHAAAAAXgIiAAAAAF5BAMAAAADCIIAAAABeAiIAAAA AXoIhAAAAAF5AAAABnBvaW50cwQDAAAAAgoOUHJlc3Rvbi1XZXJuZXIAAAAEbGFzdAoDVG9tAAAA BWZpcnN0AAAABG5hbWU= __EXPECTED__ for my $strict (0, 1) { my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => $strict); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "inline_table.toml: strict: $strict"; } __DATA__ name = { first = "Tom", last = "Preston-Werner" } point = { x = 1, y = 2 } points = [ { x = 1, y = 2, z = 3 }, { x = 7, y = 8, z = 9 }, { x = 2, y = 4, z = 8 } ] integer.t100644000765000024 152412627075071 20463 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use Storable qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); BQoDAAAABwjjAAAABGtleTEIbwAAAARrZXk0CQBRn2UAAAAEa2V5NgkAAAPoAAAABGtleTUIgAAA AARrZXkzCQAAMDkAAAAEa2V5NwiqAAAABGtleTI= __EXPECTED__ for my $strict (0, 1) { my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => $strict); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "integer.toml: strict: $strict"; } __DATA__ key1 = +99 key2 = 42 key3 = 0 key4 = -17 key5 = 1_000 key6 = 5_349_221 key7 = 1_2_3_4_5 multi_line_string.t100644000765000024 312012627075071 22547 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use Storable qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); BQoDAAAABgoeUm9zZXMgYXJlIHJlZApWaW9sZXRzIGFyZSBibHVlAAAABGtleTAKLFRoZSBxdWlj ayBicm93biBmb3gganVtcHMgb3ZlciB0aGUgbGF6eSBkb2cuAAAABGtleTEKLFRoZSBxdWljayBi cm93biBmb3gganVtcHMgb3ZlciB0aGUgbGF6eSBkb2cuAAAABGtleTMKX1RoZSBmaXJzdCBuZXds aW5lIGlzCnRyaW1tZWQgaW4gcmF3IHN0cmluZ3MuCiAgIEFsbCBvdGhlciB3aGl0ZXNwYWNlCiAg ICAgIGlzIHByZXNlcnZlZC4KICAgICAgAAAABWxpbmVzCixUaGUgcXVpY2sgYnJvd24gZm94IGp1 bXBzIG92ZXIgdGhlIGxhenkgZG9nLgAAAARrZXkyChxJIFtkd11vbid0IG5lZWQgXGR7Mn0gYXBw bGVzAAAABnJlZ2V4Mg== __EXPECTED__ for my $strict (0, 1) { my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => $strict); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "multi_line_string.toml: strict: $strict"; } __DATA__ key0 = """ Roses are red Violets are blue""" # The following strings are byte-for-byte equivalent: key1 = "The quick brown fox jumps over the lazy dog." key2 = """ The quick brown \ fox jumps over \ the lazy dog.""" key3 = """\ The quick brown \ fox jumps over \ the lazy dog.\ """ regex2 = '''I [dw]on't need \d{2} apples''' lines = ''' The first newline is trimmed in raw strings. All other whitespace is preserved. ''' single_quote.t100644000765000024 107512627075071 21525 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More; use Storable 2.38 qw/thaw/; use MIME::Base64; plan tests => 1; use TOML::Parser; use Types::Serialiser; my $parser = TOML::Parser->new( inflate_datetime => sub { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; }, ); my $data = $parser->parse_fh(\*DATA); is_deeply $data => +{ string1 => 'foobar', string2 => 'barbaz', string3 => 'foo"bar', string4 => 'bar\'baz', }, 'single_quote.toml'; __DATA__ string1='foobar' string2="barbaz" string3='foo"bar' string4="bar'baz" table.t100644000765000024 257112627075071 20120 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/001_parseruse strict; use warnings; use utf8; use Test::More tests => 2; use Storable qw/thaw/; use MIME::Base64; use TOML::Parser; sub inflate_datetime { my $dt = shift; $dt =~ s/Z$/+00:00/; return $dt; } my $toml = do { local $/; }; my $expected = thaw(decode_base64(<<'__EXPECTED__')); BQoDAAAABgQDAAAAAQQDAAAAAQQDAAAAAAAAAAFpAAAAAWgAAAABZwQZAAAAAAEEAwAAAAEEAwAA AAAAAAABbAEAAAACyp4AAAABagQZAAAAAAYKBXZhbHVlAAAAAAkxMjcuMC4wLjEKBXZhbHVlAQAA AAbKjsedyp4KBXZhbHVlAAAAAAhiYXJlLWtleQoFdmFsdWUAAAAACGJhcmVfa2V5CgV2YWx1ZQAA AAADa2V5CgV2YWx1ZQAAAAASY2hhcmFjdGVyIGVuY29kaW5nAAAABXRhYmxlBAMAAAABBAMAAAAB CgNwdWcAAAAEdHlwZQAAAAl0YXRlci5tYW4AAAADZG9nBAMAAAABBAMAAAABBAMAAAAAAAAAAWMA AAABYgAAAAFhBAMAAAABBAMAAAABBAMAAAAAAAAAAWYAAAABZQAAAAFk __EXPECTED__ for my $strict (0, 1) { my $parser = TOML::Parser->new(inflate_datetime => \&inflate_datetime, strict_mode => $strict); my $data = $parser->parse($toml); note explain { data => $data, expected => $expected } if $ENV{AUTHOR_TESTING}; is_deeply $data => $expected, "table.toml: strict: $strict"; } __DATA__ [table] key = "value" bare_key = "value" bare-key = "value" "127.0.0.1" = "value" "character encoding" = "value" "ʎǝʞ" = "value" [dog."tater.man"] type = "pug" [a.b.c] # this is best practice [ d.e.f ] # same as [d.e.f] [ g . h . i ] # same as [g.h.i] [ j . "ʞ" . l ] # same as [j."ʞ".l] comma_at_last_of_array.toml100644000765000024 13212627075071 23274 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/tomlarray1 = [1,] array2 = [ [ 2 ], [ 3, 4, ] # empty!! , ]dot_in_key.toml100644000765000024 4212627075071 20713 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/tomlFooBar="FooBar" Foo.Bar="Foo.Bar" empty_array.toml100644000765000024 4512627075071 21126 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/tomlarray1 = [] array2 = [ # empty!! ]empty_comment.toml100644000765000024 13012627075071 21465 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/toml# # # fooo # aaaa = 1 # bbbb = 2.5# cccc = true# cccc # # #aaaa dddd="dddd" empty_string.toml100644000765000024 1412627075071 21312 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/tomlstring = "" example.toml100644000765000024 155412627075071 20273 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/toml# This is a TOML document. Boom. title = "TOML Example" [owner] name = "Tom Preston-Werner" organization = "GitHub" bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." dob = 1979-05-27T07:32:00Z # First class dates? Why not? [database] server = "192.168.1.1" ports = [ 8001, 8001, 8002 ] connection_max = 5000 enabled = true [servers] # You can indent as you please. Tabs or spaces. TOML don't care. [servers.alpha] ip = "10.0.0.1" dc = "eqdc10" [servers.beta] ip = "10.0.0.2" dc = "eqdc10" country = "中国" # This should be parsed as UTF-8 [clients] data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it # Line breaks are OK when inside arrays hosts = [ "alpha", "omega" ] # Products [[products]] name = "Hammer" sku = 738594937 [[products]] name = "Nail" sku = 284758393 color = "gray" example_fruit.toml100644000765000024 37312627075071 21462 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/toml[[fruit]] name = "apple" [fruit.physical] color = "red" shape = "round" [[fruit.variety]] name = "red delicious" [[fruit.variety]] name = "granny smith" [[fruit]] name = "banana" [[fruit.variety]] name = "plantain"hard_example.toml100644000765000024 260712627075071 21271 0ustar00karupanerurastaff000000000000TOML-Parser-0.06/t/toml# Test file for TOML # Only this one tries to emulate a TOML file written by a user of the kind of parser writers probably hate # This part you'll really hate [the] test_string = "You'll hate me after this - #" # " Annoying, isn't it? [the.hard] test_array = [ "] ", " # "] # ] There you go, parse this! test_array2 = [ "Test #11 ]proved that", "Experiment #9 was a success" ] # You didn't think it'd as easy as chucking out the last #, did you? another_test_string = " Same thing, but with a string #" harder_test_string = " And when \"'s are in the string, along with # \"" # "and comments are there too" # Things will get harder [the.hard.bit#] what? = "You don't think some user won't do that?" multi_line_array = [ "]", # ] Oh yes I did ] # Each of the following keygroups/key value pairs should produce an error. Uncomment to them to test #[error] if you didn't catch this, your parser is broken #string = "Anything other than tabs, spaces and newline after a keygroup or key value pair has ended should produce an error unless it is a comment" like this #array = [ # "This might most likely happen in multiline arrays", # Like here, # "or here, # and here" # ] End of array comment, forgot the # #number = 3.14 pi <--again forgot the # wercker.yml100644000765000024 2412627075071 16641 0ustar00karupanerurastaff000000000000TOML-Parser-0.06box: wercker/defaultMETA.yml100644000765000024 244512627075071 15776 0ustar00karupanerurastaff000000000000TOML-Parser-0.06--- abstract: 'simple toml parser' author: - 'karupanerura ' build_requires: MIME::Base64: '0' Storable: '2.38' Test::More: '0.98' configure_requires: Module::Build::Tiny: '0.035' dynamic_config: 0 generated_by: 'Minilla/v3.0.0, CPAN::Meta::Converter version 2.150005' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: TOML-Parser no_index: directory: - t - xt - inc - share - eg - examples - author - builder provides: TOML::Parser: file: lib/TOML/Parser.pm version: '0.06' TOML::Parser::Tokenizer: file: lib/TOML/Parser/Tokenizer.pm TOML::Parser::Tokenizer::Strict: file: lib/TOML/Parser/Tokenizer/Strict.pm TOML::Parser::Util: file: lib/TOML/Parser/Util.pm requires: Encode: '0' Exporter: '5.57' Types::Serialiser: '0' parent: '0' perl: '5.008005' resources: bugtracker: https://github.com/karupanerura/TOML-Parser/issues homepage: https://github.com/karupanerura/TOML-Parser repository: git://github.com/karupanerura/TOML-Parser.git version: '0.06' x_authority: cpan:KARUPA x_contributors: - 'Olivier Mengué ' - 'karupanerura ' x_serialization_backend: 'CPAN::Meta::YAML version 0.016' MANIFEST100644000765000024 166212627075071 15656 0ustar00karupanerurastaff000000000000TOML-Parser-0.06Build.PL Changes LICENSE META.json README.md author/benchmark.pl author/extract-toml.sh author/test-case-maker.pl cpanfile lib/TOML/Parser.pm lib/TOML/Parser/Tokenizer.pm lib/TOML/Parser/Tokenizer/Strict.pm lib/TOML/Parser/Util.pm minil.toml t/000_compile.t t/001_parser/broken.t t/001_parser/comma_at_last_of_array.t t/001_parser/dot_in_key.t t/001_parser/duplicate_key.t t/001_parser/empty_array.t t/001_parser/empty_comment.t t/001_parser/empty_string.t t/001_parser/escape.t t/001_parser/example.t t/001_parser/example_fruit.t t/001_parser/float.t t/001_parser/hard_example.t t/001_parser/inline_table.t t/001_parser/integer.t t/001_parser/multi_line_string.t t/001_parser/single_quote.t t/001_parser/table.t t/toml/comma_at_last_of_array.toml t/toml/dot_in_key.toml t/toml/empty_array.toml t/toml/empty_comment.toml t/toml/empty_string.toml t/toml/example.toml t/toml/example_fruit.toml t/toml/hard_example.toml wercker.yml META.yml MANIFEST