From 898571aa6cc9bccaa53877f570f963b1663f9a51 Mon Sep 17 00:00:00 2001 From: Amasaki Shinobu Date: Fri, 23 Aug 2024 12:56:01 +0900 Subject: [PATCH 1/2] [add] help messages to disable literal search optimization. --- src/forgex_cli/cli_help_messages_m.f90 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/forgex_cli/cli_help_messages_m.f90 b/src/forgex_cli/cli_help_messages_m.f90 index d1cd6556..708014ec 100644 --- a/src/forgex_cli/cli_help_messages_m.f90 +++ b/src/forgex_cli/cli_help_messages_m.f90 @@ -155,9 +155,9 @@ subroutine print_help_debug_thompson op(1) = "--verbose" odesc(1) ="Print more information." - op(2) ="--no-table " + op(2) ="--no-table" odesc(2) ="Suppresses the output of the property information table." - op(3) ="--table-only " + op(3) ="--table-only" odesc(3) ="Print the property information table only." call generate_and_output(header, usage, "OPTIONS", op, odesc) @@ -205,8 +205,8 @@ subroutine print_help_find_match_lazy_dfa implicit none character(LINE_SIZ) :: header character(LINE_SIZ) :: usage(2) - character(CMD_SIZ) :: op(3) - character(CMD_DESC_SIZ) :: odesc(3) + character(CMD_SIZ) :: op(4) + character(CMD_DESC_SIZ) :: odesc(4) header = "Executes a search for matches using a lazy DFA regex engine." usage(1) = "forgex-cli debug lazy-dfa .match. " usage(2) = "forgex-cli debug lazy-dfa .in. " @@ -214,9 +214,11 @@ subroutine print_help_find_match_lazy_dfa op(1) = "--verbose" odesc(1) = "Print more information." op(2) = "--no-table" - odesc(2) = "Suppresses the output of the property information table." + odesc(2) = "Suppress the output of the property information table." op(3) = "--table-only" odesc(3) = "Print the property information table only. " + op(4) = "--disable-literal-optimize" + odesc(4) = "Disable literals search optimization." call generate_and_output(header, usage, "OPTIONS", op, odesc) end subroutine print_help_find_match_lazy_dfa @@ -227,14 +229,14 @@ subroutine print_help_find_match_dense_dfa character(LINE_SIZ) :: usage(2) character(CMD_SIZ) :: op(3) character(CMD_DESC_SIZ) :: odesc(3) - header = "Executes a search for matches using a fully-compiled DFA regex engine." + header = "Execute a search for matches using a fully-compiled DFA regex engine." usage(1) = "forgex-cli find match dense .match. " usage(2) = "forgex-cli find match dense .in. " op(1) = "--verbose" odesc(1) = "Print more information." op(2) = "--no-table" - odesc(2) = "Suppresses the output of the property information table." + odesc(2) = "Suppress the output of the property information table." op(3) = "--table-only" odesc(3) = "Print the property information table only. " @@ -252,7 +254,7 @@ subroutine print_help_find_match_forgex_api usage(2) = "forgex-cli find match forgex .in. " op(1) = "--no-table" - odesc(1) = "Suppresses the output of the property information table." + odesc(1) = "Suppress the output of the property information table." call generate_and_output(header, usage, "OPTIONS", op, odesc) end subroutine print_help_find_match_forgex_api From 1cc2cf52c3a8a27f71ff1a948142b7fd218df1b9 Mon Sep 17 00:00:00 2001 From: Amasaki Shinobu Date: Fri, 23 Aug 2024 13:17:39 +0900 Subject: [PATCH 2/2] [del] unused variables are removed. --- src/forgex_cli/cli_cla_m.f90 | 4 +- src/forgex_cli/cli_help_messages_m.f90 | 2 +- src/syntax_tree_graph_m.F90 | 2 +- src/test_m.f90 | 70 +++++++++++++------------- 4 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/forgex_cli/cli_cla_m.f90 b/src/forgex_cli/cli_cla_m.f90 index 97fddf2a..0a1c2360 100644 --- a/src/forgex_cli/cli_cla_m.f90 +++ b/src/forgex_cli/cli_cla_m.f90 @@ -95,7 +95,6 @@ end subroutine cla__init_find_subc subroutine cla__init_find_match_subsubc(cla) implicit none class(cla_t), intent(inout) :: cla - integer :: idx allocate(cla%sub_cmd%subc(NUM_SUBSUBC_MATCH)) cla%sub_cmd%subc(1) = ENGINE_LAZY_DFA @@ -172,7 +171,6 @@ subroutine cla__do_debug_subc(cla) use :: forgex_cli_debug_m implicit none class(cla_t), intent(inout) :: cla - logical :: is_exactly integer :: pattern_offset pattern_offset = 3 @@ -222,7 +220,7 @@ subroutine cla__do_find_subc(cla) implicit none class(cla_t), intent(inout) :: cla logical :: is_exactly - integer :: i, pattern_offset + integer :: pattern_offset character(:), allocatable :: text pattern_offset = 4 diff --git a/src/forgex_cli/cli_help_messages_m.f90 b/src/forgex_cli/cli_help_messages_m.f90 index 708014ec..358461b7 100644 --- a/src/forgex_cli/cli_help_messages_m.f90 +++ b/src/forgex_cli/cli_help_messages_m.f90 @@ -24,7 +24,7 @@ module forgex_cli_help_messages_m public :: print_help_find_match_forgex_api integer(int32), parameter :: LINE_SIZ = 128 - integer(int32), parameter :: CMD_SIZ = 13 + integer(int32), parameter :: CMD_SIZ = 26 integer(int32), parameter :: CMD_DESC_SIZ = 109 contains diff --git a/src/syntax_tree_graph_m.F90 b/src/syntax_tree_graph_m.F90 index e74c1fdc..364386e4 100644 --- a/src/syntax_tree_graph_m.F90 +++ b/src/syntax_tree_graph_m.F90 @@ -12,7 +12,7 @@ module forgex_syntax_tree_graph_m use :: forgex_parameters_m use :: forgex_enums_m - use :: forgex_segment_m, + use :: forgex_segment_m use :: forgex_syntax_tree_node_m, & only: tree_node_t, tape_t, terminal, make_atom, make_tree_node, make_repeat_node implicit none diff --git a/src/test_m.f90 b/src/test_m.f90 index c7380d49..4c69eec4 100644 --- a/src/test_m.f90 +++ b/src/test_m.f90 @@ -21,13 +21,13 @@ module forgex_test_m public :: is_valid__regex public :: is_valid__prefix public :: is_valid__suffix - public :: is_valid__middle + ! public :: is_valid__middle public :: runner_in public :: runner_match public :: runner_regex public :: runner_prefix public :: runner_suffix - public :: runner_middle + ! public :: runner_middle contains @@ -118,26 +118,26 @@ function is_valid__suffix(pattern, expected_suffix) result(res) end function is_valid__suffix - function is_valid__middle(pattern, expected, middle) result(res) - use :: forgex_syntax_tree_optimize_m - use :: forgex_utf8_m - implicit none - character(*), intent(in) :: pattern, expected - character(:), allocatable :: middle - logical :: res + ! function is_valid__middle(pattern, expected, middle) result(res) + ! use :: forgex_syntax_tree_optimize_m + ! use :: forgex_utf8_m + ! implicit none + ! character(*), intent(in) :: pattern, expected + ! character(:), allocatable :: middle + ! logical :: res - character(:), allocatable :: resulting - type(tree_t) :: tree - ! call tree%build(pattern) - ! resulting = get_middle_literal(tree) - ! middle = resulting - ! if (len_utf8(expected) == len_utf8(resulting)) then - ! res = expected == resulting - ! return - ! end if - ! res = .false. + ! ! character(:), allocatable :: resulting + ! ! type(tree_t) :: tree + ! ! ! call tree%build(pattern) + ! ! ! resulting = get_middle_literal(tree) + ! ! ! middle = resulting + ! ! ! if (len_utf8(expected) == len_utf8(resulting)) then + ! ! ! res = expected == resulting + ! ! ! return + ! ! ! end if + ! ! ! res = .false. - end function is_valid__middle + ! end function is_valid__middle @@ -248,22 +248,22 @@ subroutine runner_suffix(pattern, suffix, result) end subroutine runner_suffix - subroutine runner_middle(pattern, middle, result) - implicit none - character(*), intent(in) :: pattern, middle - logical, intent(inout) :: result - character(:),allocatable :: resulting - logical :: res + ! subroutine runner_middle(pattern, middle, result) + ! implicit none + ! character(*), intent(in) :: pattern, middle + ! logical, intent(inout) :: result + ! character(:),allocatable :: resulting + ! logical :: res - ! res = is_valid__middle(pattern, middle, resulting) + ! ! res = is_valid__middle(pattern, middle, resulting) - ! if (res) then - ! write(error_unit, '(a,a,a)') 'result(middle): Success', ' '//trim(pattern), ' "'//trim(middle)//'"' - ! else - ! write(error_unit, '(a,a,a a)') 'result(middle): FAILED ', ' '//trim(pattern), ': got "'//resulting//'"', & - ! ', "'//trim(middle)//'" is expected.' - ! end if - ! result = result .and. res - end subroutine runner_middle + ! ! if (res) then + ! ! write(error_unit, '(a,a,a)') 'result(middle): Success', ' '//trim(pattern), ' "'//trim(middle)//'"' + ! ! else + ! ! write(error_unit, '(a,a,a a)') 'result(middle): FAILED ', ' '//trim(pattern), ': got "'//resulting//'"', & + ! ! ', "'//trim(middle)//'" is expected.' + ! ! end if + ! ! result = result .and. res + ! end subroutine runner_middle end module forgex_test_m \ No newline at end of file