The function parser class.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(stack_func_container), | public, | dimension(:), allocatable | :: | bytecode_ops | array of function pointers |
||
integer, | public, | dimension(:), allocatable | :: | bytecode | array of integers |
||
integer, | public | :: | bytecodesize | = | 0 | ||
real(kind=wp), | public, | dimension(:), allocatable | :: | immed | |||
integer, | public | :: | immedsize | = | 0 | ||
real(kind=wp), | public, | dimension(:), allocatable | :: | stack | |||
integer, | public | :: | stacksize | = | 0 | ||
integer, | public | :: | stackptr | = | 0 | ||
type(list_of_errors), | public | :: | error_msg | list of error messages |
Parse the function string funcstr
and compile it into bytecode
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(fparser), | intent(inout) | :: | me | |||
character(len=*), | intent(in) | :: | funcstr | function string |
||
character(len=*), | intent(in), | dimension(:) | :: | var | array with variable names |
|
logical, | intent(in), | optional | :: | case_sensitive | are the variables case sensitive? [default is false] |
Evaluate bytecode of function for the values passed in array val
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(fparser), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in), | dimension(:) | :: | val | variable values |
|
real(kind=wp), | intent(out) | :: | res | result |
fparser destructor.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(fparser), | intent(inout) | :: | me |
Returns true if there are any errors in the class.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(fparser), | intent(in) | :: | me |
true if there are any errors in the class
Prints the error messages (if any) in the class.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(fparser), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | iunit | unit number for printing (assumed to be open) |
Clears any error messages in the class.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(fparser), | intent(inout) | :: | me |
Compile i-th function string f
into bytecode
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(fparser), | intent(inout) | :: | me | |||
character(len=*), | intent(in) | :: | f | function substring |
||
integer, | intent(in) | :: | b | begin position substring |
||
integer, | intent(in) | :: | e | end position substring |
||
character(len=*), | intent(in), | dimension(:) | :: | var | array with variable names |
Compile function string f
into bytecode
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(fparser), | intent(inout) | :: | me | |||
character(len=*), | intent(in) | :: | f | function string |
||
character(len=*), | intent(in), | dimension(:) | :: | var | array with variable names |
Check syntax of function string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(fparser), | intent(inout) | :: | me | |||
character(len=*), | intent(in) | :: | func | function string without spaces |
||
character(len=*), | intent(in) | :: | funcstr | original function string |
||
character(len=*), | intent(in), | dimension(:) | :: | var | array with variable names |
|
integer, | intent(in), | dimension(:) | :: | ipos |
add error message to the class.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(fparser), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | j | |||
integer, | intent(in), | dimension(:) | :: | ipos | ||
character(len=*), | intent(in) | :: | funcstr | original function string |
||
character(len=*), | intent(in), | optional | :: | msg |
type,public :: fparser
private
type(stack_func_container),dimension(:),allocatable :: bytecode_ops !! array of function pointers
integer,dimension(:),allocatable :: bytecode !! array of integers
integer :: bytecodesize = 0
real(wp),dimension(:),allocatable :: immed
integer :: immedsize = 0
real(wp),dimension(:),allocatable :: stack
integer :: stacksize = 0
integer :: stackptr = 0
type(list_of_errors) :: error_msg !! list of error messages
contains
private
procedure,public :: parse => parse_function
procedure,public :: evaluate => evaluate_function
procedure,public :: destroy => destroy_parser
procedure,public :: error
procedure,public :: print_errors
procedure,public :: clear_errors
procedure :: compile_substr
procedure :: compile
procedure :: check_syntax
procedure :: add_error
end type fparser