Skip to content

Commit

Permalink
Remove when from Tiny::Tokenizer
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed May 23, 2023
1 parent 1c88882 commit 27b3533
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions lib/TOML/Tiny/Tokenizer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -82,59 +82,70 @@ sub next_token {
/\G$WS+/gc; # ignore whitespace
/\G$Comment$/mgc && next; # ignore comments

last when /\G$/gc;
last if /\G$/gc;

when (/\G$EOL/gc) {
# my $res = $_ ~~ /\G$EOL/gc;
# print "$res\n";

if (/\G$EOL/gc) {
#if ( $_ ~~ /\G$EOL/gc ) {
++$self->{line};
$type = 'EOL';
last;
}

if ($newline) {
when (/$table/gc) {
if (/$table/gc) {
$type = 'table';
$value = $self->tokenize_key($1);
last;
}

when (/$array_table/gc) {
if (/$array_table/gc) {
$type = 'array_table';
$value = $self->tokenize_key($1);
last;
}
}

when (/$key_set/gc) {
if (/$key_set/gc) {
$type = 'key';
$value = $1;
last;
}

when (/\G ( [\[\]{}=,] | true | false )/xgc) {
if (/\G ( [\[\]{}=,] | true | false )/xgc) {
$value = $1;
$type = $simple->{$value};
last;
}

when (/\G($String)/gc) {
if (/\G($String)/gc) {
$type = 'string';
$value = $1;
last;
}

when (/\G($DateTime)/gc) {
if (/\G($DateTime)/gc) {
$type = 'datetime';
$value = $1;
last;
}

when (/\G($Float)/gc) {
if (/\G($Float)/gc) {
$type = 'float';
$value = $1;
last;
}

when (/\G($Integer)/gc) {
if (/\G($Integer)/gc) {
$type = 'integer';
$value = $1;
last;
}

default{
my $substr = substr($self->{source}, $self->{position}, 30) // 'undef';
die "toml syntax error on line $self->{line}\n\t-->|$substr|\n";
}
my $substr = substr($self->{source}, $self->{position}, 30) // 'undef';
die "toml syntax error on line $self->{line}\n\t-->|$substr|\n";
}

if ($type) {
Expand Down

0 comments on commit 27b3533

Please sign in to comment.