forgex_syntax_tree_optimize_m Module



Variables

Type Visibility Attributes Name Initial
character(len=0), private, parameter :: theta = ''

Derived Types

type, private ::  character_array_element_t

This type is wrapper to make a allocatable character array with variable length.

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: c

type, private ::  literal_t

This type contains a character variables that represents each literal: all, pref, suff, and fact.

Components

Type Visibility Attributes Name Initial
type(character_array_element_t), public :: all
type(character_array_element_t), public :: fact
logical, public :: flag_class = .false.
logical, public :: flag_closure = .false.
type(character_array_element_t), public :: pref
type(character_array_element_t), public :: suff

Functions

private pure function best(c1, c2) result(res)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: c1
character(len=*), intent(in) :: c2

Return Value character(len=:), allocatable

private pure function get_literal(tree) result(literal)

Wrapping function to retrieve literals: all, prefix, suffix, factor.

Arguments

Type IntentOptional Attributes Name
type(tree_t), intent(in) :: tree

Return Value type(literal_t)

private pure function return_class_closure(f_L_class, f_r_class, f_l_closure, f_r_closure) result(retval)

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: f_L_class
logical, intent(in) :: f_r_class
logical, intent(in) :: f_l_closure
logical, intent(in) :: f_r_closure

Return Value integer

private pure function same_part_of_prefix(c1, c2) result(res)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: c1
character(len=*), intent(in) :: c2

Return Value character(len=:), allocatable

private pure function same_part_of_suffix(c1, c2) result(retval)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: c1
character(len=*), intent(in) :: c2

Return Value character(len=:), allocatable


Subroutines

public pure subroutine extract_literal(tree, all, prefix, suffix, factor)

This is the public procedure of this module to obtain each literal from AST.

Arguments

Type IntentOptional Attributes Name
type(tree_t), intent(in) :: tree
character(len=:), intent(inout), allocatable :: all
character(len=:), intent(inout), allocatable :: prefix
character(len=:), intent(inout), allocatable :: suffix
character(len=:), intent(inout), allocatable :: factor

private pure recursive subroutine best_factor(nodes, idx, lit)

This is recursive procedure to tour a given syntax tree.

Arguments

Type IntentOptional Attributes Name
type(tree_node_t), intent(in) :: nodes(:)
integer, intent(in) :: idx
type(literal_t), intent(inout) :: lit