EquationParser Derived Type

type, public :: EquationParser


Contents

Source Code


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

public interface EquationParser

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

    Arguments

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

    Return Value type(EquationParser)


Finalization Procedures

final :: Finalize_EquationParser


Type-Bound Procedures

procedure, public :: CleanEquation

  • private subroutine CleanEquation(parser, equationCleaned)

    Arguments

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

procedure, public :: ConvertToPostfix => ConvertToPostFix

  • 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 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))

procedure, private :: Evaluate_r1fp32

  • 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))

procedure, private :: Evaluate_r1fp64

  • 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))

procedure, private :: Evaluate_r2fp32

  • 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))

procedure, private :: Evaluate_r2fp64

  • 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))

procedure, private :: Evaluate_r3fp32

  • 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))

procedure, private :: Evaluate_r3fp64

  • 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))

procedure, private :: Evaluate_r4fp32

  • 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))

procedure, private :: Evaluate_r4fp64

  • 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))

procedure, private :: Evaluate_sfp32

  • 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)

procedure, private :: Evaluate_sfp64

  • 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)

procedure, public :: Print_InFixTokens => Print_InfixTokens

procedure, public :: Print_PostFixTokens => Print_PostfixTokens

procedure, private, nopass :: Priority

  • private function Priority(toke)

    Arguments

    TypeIntentOptionalAttributesName
    type(Token) :: toke

    Return Value integer

procedure, public :: Tokenize

  • private subroutine Tokenize(parser, tokenized, errorMsg)

    Arguments

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

Source Code

  type,public :: EquationParser
    character(:),allocatable                   :: equation
    character(:),allocatable                   :: variableName
    character(:),allocatable                   :: inFixFormula
    integer                                     :: nIndepVars
    type(IndepVar),dimension(:),allocatable   :: indepVars
    type(TokenStack)                            :: inFix
    type(TokenStack)                            :: postFix
  contains
    final :: Finalize_EquationParser
    procedure :: CleanEquation
    procedure :: Tokenize
    procedure :: ConvertToPostfix

    generic ::  Evaluate => Evaluate_sfp32,Evaluate_sfp64, &
      Evaluate_r1fp32,Evaluate_r1fp64, &
      Evaluate_r2fp32,Evaluate_r2fp64, &
      Evaluate_r3fp32,Evaluate_r3fp64, &
      Evaluate_r4fp32,Evaluate_r4fp64
    procedure,private :: Evaluate_sfp32,Evaluate_sfp64
    procedure,private :: Evaluate_r1fp32,Evaluate_r1fp64
    procedure,private :: Evaluate_r2fp32,Evaluate_r2fp64
    procedure,private :: Evaluate_r3fp32,Evaluate_r3fp64
    procedure,private :: Evaluate_r4fp32,Evaluate_r4fp64

    procedure :: Print_InFixTokens
    procedure :: Print_PostFixTokens

    procedure,nopass,private :: Priority

  endtype EquationParser