From 27b6ade8819dbe14e78a2b01173d7cfc0a2dfa17 Mon Sep 17 00:00:00 2001 From: "Flavio S. Glock" Date: Tue, 9 Jul 2024 15:27:54 +0200 Subject: [PATCH] Perlito5 - misc/Perl5_parser error messages --- misc/perl5_parser/perl5_parser.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/misc/perl5_parser/perl5_parser.pl b/misc/perl5_parser/perl5_parser.pl index 2f80cbe6e..b4a23b1e2 100644 --- a/misc/perl5_parser/perl5_parser.pl +++ b/misc/perl5_parser/perl5_parser.pl @@ -329,6 +329,14 @@ sub tokenize { '=>' => 1, ); +sub error_message_string_terminator { + my ( $tokens, $index, $quote ) = @_; + if ($quote eq '"') { + return "Can't find string terminator '$quote' anywhere before EOF\n"; + } + return "Can't find string terminator \"$quote\" anywhere before EOF\n"; +} + sub error_message { my ( $tokens, $index, $message ) = @_; @@ -673,6 +681,7 @@ sub parse_single_quote_string { # 'abc' $value .= $tokens->[$pos][1]; $pos++; } + die error_message_string_terminator( $tokens, $index, $quote ); } sub parse_double_quote_string { # "abc" @@ -718,6 +727,7 @@ sub parse_double_quote_string { # "abc" $value .= $tokens->[$pos][1]; $pos++; } + die error_message_string_terminator( $tokens, $index, $quote ); } sub parse_regex_string { # /abc/ @@ -763,6 +773,7 @@ sub parse_regex_string { # /abc/ $value .= $tokens->[$pos][1]; $pos++; } + die error_message( $tokens, $index, "Search pattern not terminated" ); } sub parse_delim_expression { @@ -993,6 +1004,7 @@ sub token_as_string { sub main { $Data::Dumper::Sortkeys = 1; + $Data::Dumper::Indent = 1; binmode( STDOUT, ":utf8" ); my $perl_code = join( '', ); my $tokens = tokenize($perl_code);