Lexer/parser of Notus files. More...
Functions | |
recursive integer function | mod_nts_language::nts_evaluate_integer_expression (parser) |
Evaluate an integer expression. | |
recursive double precision function | mod_nts_language::nts_evaluate_double_expression (parser) |
Evaluate a double precision expression. | |
recursive double precision function | mod_nts_language::nts_evaluate_double_expression_positive (parser) |
Evaluate a positive (>=0) double precision expression (. | |
recursive double precision function | mod_nts_language::nts_evaluate_double_expression_spositive (parser) |
Evaluate a strictly positive (>0) double precision expression (. | |
recursive character(len=:) function, allocatable | mod_nts_language::nts_evaluate_string_expression (parser) |
Evaluate a string precision expression. | |
recursive logical function | mod_nts_language::nts_evaluate_boolean_expression (parser) |
Evaluate a boolean expression. | |
recursive double precision function, dimension(dimension) | mod_nts_parse_array::nts_parse_double_array (parser, dimension) |
Parse an array of real numbers. | |
recursive integer function, dimension(dimension) | mod_nts_parse_array::nts_parse_integer_array (parser, dimension) |
Parse an array of integers. | |
recursive subroutine | mod_nts_parse_array::nts_parse_double_array_nodimension (parser, array) |
Parse an array of real numbers with undefined dimension. | |
recursive subroutine | mod_ui_parse_block::ui_parse_block (parser, block_reader) |
Read a new block. | |
Capabilities:
To read real expression such as
or integer expression such as
or boolean expression such as
or string expression such as
the instructions are:
To read a 3-dimensional integer array such as
or a 2-dimensional real array
the instructions are:
The following instructions read the next token without consuming it
To ensure that the next token is a semicolon, the following instruction must be used:
If the next token is not a semicolon, an error is thrown, with, for example, the message: "'semicolon' expected, but got 'keyword'" if the next token is a keyword.
Sometimes, we want only to check if there is specific token without throwing an error. For example, to check if the next token is a comma, the following instruction can be used:
If we want to check if the next token is a keyword and the keyword is 'domain', there is a special instruction:
Note that this instruction will return false without throwing any error if the next token is not a keyword.
A block starts with an opening brace '{', ends with a closing brace '}' and may contains other blocks, variable declarations, loop instruction (while, exit) or conditionals (if, else).
A block defines also a scope for the variable definition, that is a variable declared in a block is available in the current block, in child blocks, but not in parent blocks.
For example, we want to read the following block:
The parser has already read the keyword 'domain' and the syntax requires that a block must be started. The first thing to do is to ensure that the next token is an opening brace. Then, we start a new scope that begins with the opening brace token. Finally, we start the block reader. The next listing contains the code to start the block reader of the above example:
The example block above can be read by the following code:
Organisation:
Concepts:
recursive logical function mod_nts_language::nts_evaluate_boolean_expression | ( | type(t_parser) | parser | ) |
This routine evaluate expressions such as:
recursive double precision function mod_nts_language::nts_evaluate_double_expression | ( | type(t_parser) | parser | ) |
This routine evaluate expressions such as:
recursive double precision function mod_nts_language::nts_evaluate_double_expression_positive | ( | type(t_parser) | parser | ) |
recursive double precision function mod_nts_language::nts_evaluate_double_expression_spositive | ( | type(t_parser) | parser | ) |
recursive integer function mod_nts_language::nts_evaluate_integer_expression | ( | type(t_parser) | parser | ) |
This routine evaluate integer expressions such as:
If the expression contains real number, they will be converted in integers at the evaluation.
recursive character(len=:) function, allocatable mod_nts_language::nts_evaluate_string_expression | ( | type(t_parser) | parser | ) |
This routine evaluate expressions such as:
recursive double precision function, dimension(dimension) mod_nts_parse_array::nts_parse_double_array | ( | type(t_parser) | parser, |
integer, intent(in) | dimension ) |
Read a double precision array of dimension dimension
. Return an array of the required dimension.
!! (<double expression>, <double expression>,..., <double expression>) !! <---------------------------------------------------------------> !! dimension double precision expressions !!
parser | current parser |
dimension | required dimension |
recursive subroutine mod_nts_parse_array::nts_parse_double_array_nodimension | ( | type(t_parser) | parser, |
double precision, dimension(:), intent(inout), allocatable | array ) |
Read a double precision array of unknown dimension. Return an array of the dimension .
!! (<double expression>, <double expression>,...) !! <------------------------------------------> !! dimension double precision expressions !!
parser | current parser |
recursive integer function, dimension(dimension) mod_nts_parse_array::nts_parse_integer_array | ( | type(t_parser) | parser, |
integer, intent(in) | dimension ) |
Read an integer array of dimension dimension
. Return an array of the required dimension.
!! (<integer expression>, <integer expression>,..., <integer expression>) !! <------------------------------------------------------------------> !! dimension integer expressions !!
parser | current parser |
dimension | required dimension |
recursive subroutine mod_ui_parse_block::ui_parse_block | ( | type(t_parser) | parser, |
procedure(block_function) | block_reader ) |
A block starts with an opening brace '{' and ends with a closing brace '}'.
In a block, a user may define variables, start a new block, use controle structures (loops, if, else, etc.) and use authorized keywords. Authorized keyword are defined by a specific block reader.
A block reader is a routine with a specific interface:
Where:
parser
is the current parsertok
is the keyword token being readkeyword_id
is the keyword id of tok
parser | current parser |
block_reader | routine containing |