1. src/utils/m_expr_eval [ Modules ]

[ Top ] [ Modules ]

NAME

    m_expr_eval  --  simple expression evaluator

SYNOPSIS

    use m_expr_eval

DESCRIPTION

    This module contains procedures to dissect and evaluate a string
    containing a mathematical expression.
    It converts the infix expression to postfix notation (RPN) using
    Dijkstra's shunting-yard algorithm.
    This was module was written for two purposes:
    - get acquainted with pointers
    - write a simple expression evaluator

USES

    m_precision

MODIFICATION HISTORY

    2008-06-25 -- WvH : expressions are correctly evaluated
    2008-06-27 -- WvH : tokenizer completely rewritten

TODO

    - test it thoroughly
    - make sure it doesn't crash when an expression with unknown intrinsics
      is parsed.

SEE ALSO

    src/utils/test_expr_eval
    http://en.wikipedia.org/wiki/Shunting_yard_algorithm

COPYRIGHT

    Copyright (c) 2008 Wim Van Hoydonck

AUTHOR

    Wim Van Hoydonck

CREATION DATE

    2008-06-20 

2. src/utils/m_expr_eval/debug_mod [ Subroutines ]

[ Top ] [ Subroutines ]

NAME

    debug_mod  --  turn on debugging statements

SYNOPSIS

    call debug_mod (  db )

DESCRIPTION

    Turn on print statements in tokenizer and shunting_yard

INPUTS

    logical  :: db

AUTHOR

    Wim Van Hoydonck

CREATION DATE

    2008-06-28

3. src/utils/m_expr_eval/eval_expr [ Functions ]

[ Top ] [ Functions ]

NAME

    eval_expr  --  evaluate mathematical expression

SYNOPSIS

    res = eval_expr ( expr )

DESCRIPTION

    Evaluate the supplied mathematical expression in four steps.
    0) prepend it with a zero, if necessary
    1) tokenize: the expression is converted into tokens,
    2) shunting_yard: tokens are converted to postfix notation,
    3) eval_rpn: postfix notation is evaluated from left to right.

INPUTS

    character(len=*) :: expr

OUTPUT

    real(dp)         :: res

AUTHOR

    Wim Van Hoydonck

CREATION DATE

    2008-06-25