FEQParse Module



Contents


Variables

TypeVisibilityAttributesNameInitial
integer, private, parameter:: Stack_Length =256
integer, private, parameter:: nSeparators =7
character(len=1), private :: numbers(10) =['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
character(len=1), private :: operators(5) =['+', '-', '*', '/', '^']
real(kind=real32), public, parameter:: pi_real32 =4.0_real32*atan(1.0_real32)
real(kind=real64), public, parameter:: pi_real64 =4.0_real64*atan(1.0_real64)
character(len=1), private :: separators(7) =['+', '-', '*', '/', "(", ")", '^']

Enumerations

enum, bind(c)

Enumerators

enumerator:: None_Token = 0
enumerator:: Number_Token = 1
enumerator:: Variable_Token = 2
enumerator:: Operator_Token = 3
enumerator:: Function_Token = 4
enumerator:: OpeningParentheses_Token = 5
enumerator:: ClosingParentheses_Token = 6
enumerator:: Monadic_Token = 7

Interfaces

public interface EquationParser

  • private function Construct_EquationParser(equation, indepVars) result(parser)

    Arguments

    TypeIntentOptionalAttributesName
    character :: equation
    character :: indepVars(:)

    Return Value type(EquationParser)


Derived Types

type, public :: EquationParser

Components

TypeVisibilityAttributesNameInitial
character, public, allocatable:: equation
type(TokenStack), public :: inFix
character, public, allocatable:: inFixFormula
type(IndepVar), public, dimension(:), allocatable:: indepVars
integer, public :: nIndepVars
type(TokenStack), public :: postFix
character, public, allocatable:: variableName

Constructor

private function Construct_EquationParser(equation, indepVars)

Finalizations Procedures

final :: Finalize_EquationParser

Type-Bound Procedures

procedure, public :: CleanEquation
procedure, public :: ConvertToPostfix => ConvertToPostFix
generic, public :: Evaluate => Evaluate_sfp32, Evaluate_sfp64, Evaluate_r1fp32, Evaluate_r1fp64, Evaluate_r2fp32, Evaluate_r2fp64, Evaluate_r3fp32, Evaluate_r3fp64, Evaluate_r4fp32, Evaluate_r4fp64
procedure, private :: Evaluate_r1fp32
procedure, private :: Evaluate_r1fp64
procedure, private :: Evaluate_r2fp32
procedure, private :: Evaluate_r2fp64
procedure, private :: Evaluate_r3fp32
procedure, private :: Evaluate_r3fp64
procedure, private :: Evaluate_r4fp32
procedure, private :: Evaluate_r4fp64
procedure, private :: Evaluate_sfp32
procedure, private :: Evaluate_sfp64
procedure, public :: Print_InFixTokens => Print_InfixTokens
procedure, public :: Print_PostFixTokens => Print_PostfixTokens
procedure, private, nopass :: Priority
procedure, public :: Tokenize

type, private :: IndepVar

Components

TypeVisibilityAttributesNameInitial
character, private, allocatable:: value

Functions

private function Construct_EquationParser(equation, indepVars) result(parser)

Arguments

TypeIntentOptionalAttributesName
character :: equation
character :: indepVars(:)

Return Value type(EquationParser)

private function Evaluate_r1fp32(parser, x) result(f)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser) :: parser
real(kind=real32) :: x(:,:)

Return Value real(kind=real32)(lbound(x,1):ubound(x,1))

private function Evaluate_r1fp64(parser, x) result(f)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser) :: parser
real(kind=real64) :: x(:,:)

Return Value real(kind=real64)(lbound(x,1):ubound(x,1))

private function Evaluate_r2fp32(parser, x) result(f)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser) :: parser
real(kind=real32) :: x(:,:,:)

Return Value real(kind=real32)(lbound(x,1):ubound(x,1),lbound(x,2):ubound(x,2))

private function Evaluate_r2fp64(parser, x) result(f)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser) :: parser
real(kind=real64) :: x(:,:,:)

Return Value real(kind=real64)(lbound(x,1):ubound(x,1),lbound(x,2):ubound(x,2))

private function Evaluate_r3fp32(parser, x) result(f)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser) :: parser
real(kind=real32) :: x(:,:,:,:)

Return Value real(kind=real32)(lbound(x,1):ubound(x,1),lbound(x,2):ubound(x,2),lbound(x,3):ubound(x,3))

private function Evaluate_r3fp64(parser, x) result(f)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser) :: parser
real(kind=real64) :: x(:,:,:,:)

Return Value real(kind=real64)(lbound(x,1):ubound(x,1),lbound(x,2):ubound(x,2),lbound(x,3):ubound(x,3))

private function Evaluate_r4fp32(parser, x) result(f)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser) :: parser
real(kind=real32) :: x(:,:,:,:,:)

Return Value real(kind=real32)(lbound(x,1):ubound(x,1),lbound(x,2):ubound(x,2),lbound(x,3):ubound(x,3),lbound(x,4):ubound(x,4))

private function Evaluate_r4fp64(parser, x) result(f)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser) :: parser
real(kind=real64) :: x(:,:,:,:,:)

Return Value real(kind=real64)(lbound(x,1):ubound(x,1),lbound(x,2):ubound(x,2),lbound(x,3):ubound(x,3),lbound(x,4):ubound(x,4))

private function Evaluate_sfp32(parser, x) result(f)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser) :: parser
real(kind=real32) :: x(1:parser%nIndepVars)

Return Value real(kind=real32)

private function Evaluate_sfp64(parser, x) result(f)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser) :: parser
real(kind=real64) :: x(1:parser%nIndepVars)

Return Value real(kind=real64)

private function IsFunction(varlen, eqChar, idx)

Arguments

TypeIntentOptionalAttributesName
integer, intent(inout) :: varlen
character, intent(in) :: eqChar
integer, intent(out) :: idx

Return Value logical

private function IsNumber(eqChar)

Arguments

TypeIntentOptionalAttributesName
character(len=1) :: eqChar

Return Value logical

private function IsOperator(eqChar)

Arguments

TypeIntentOptionalAttributesName
character(len=1) :: eqChar

Return Value logical

private function IsSeparator(eqChar)

Arguments

TypeIntentOptionalAttributesName
character(len=1) :: eqChar

Return Value logical

private function IsVariable(varlen, eqChar, variables, nvariables)

Arguments

TypeIntentOptionalAttributesName
integer, intent(inout) :: varlen
character, intent(in) :: eqChar
type(IndepVar) :: variables(1:nvariables)
integer :: nvariables

Return Value logical

private function Priority(toke)

Arguments

TypeIntentOptionalAttributesName
type(Token) :: toke

Return Value integer

private pure recursive function ReplaceStr(string, search, substitute) result(modifiedString)

Arguments

TypeIntentOptionalAttributesName
character, intent(in) :: string
character, intent(in) :: search
character, intent(in) :: substitute

Return Value character,allocatable


Subroutines

private subroutine CleanEquation(parser, equationCleaned)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser), intent(inout) :: parser
logical, intent(out) :: equationCleaned

private subroutine ConvertToPostFix(parser)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser), intent(inout) :: parser

private subroutine Finalize_EquationParser(parser)

Arguments

TypeIntentOptionalAttributesName
type(EquationParser), intent(inout) :: parser

private subroutine Print_InfixTokens(parser)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser), intent(in) :: parser

private subroutine Print_PostfixTokens(parser)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser), intent(in) :: parser

private subroutine Tokenize(parser, tokenized, errorMsg)

Arguments

TypeIntentOptionalAttributesName
class(EquationParser), intent(inout) :: parser
logical, intent(out) :: tokenized
character, intent(out), allocatable:: errorMsg