modulefdoc_fypp
A port to Fortran of the parts of Fypp, the preprocessor by Bálint Aradi, that the Fortran standard library needs, so that fdoc can read Fypp sources without running Python.
Fypp's directives hold Python expressions. A small evaluator here covers the ones in use: literals,
lists, tuples, comprehensions, f-strings, slices, conditional expressions, and the functions and
string methods listed in call_builtin and call_method. Anything else stops with an error
that names it, and is left for later, as are the directives del, global, stop, nextarg and
contains, direct calls with @: and @{...}@, and line numbering.
All state is in a fypp_t made for each file, so that files can be processed in parallel. As in
the rest of fdoc, no function returns a deferred-length string (see example/slen_race.f90).
Fypp is Copyright (c) 2016-2023 Bálint Aradi, Universität Bremen, and is distributed under the BSD 2-clause license. This port follows its design and keeps its notice:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Uses
Graphs
Uses
Used by
Variables
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
| C_EQ | integer | privateparameter | 1 | |
| C_GE | integer | privateparameter | 6 | |
| C_GT | integer | privateparameter | 4 | |
| C_IN | integer | privateparameter | 7 | |
| C_LE | integer | privateparameter | 5 | |
| C_LT | integer | privateparameter | 3 | |
| C_NE | integer | privateparameter | 2 | |
| C_NOT_IN | integer | privateparameter | 8 | |
| E_ADD | integer | privateparameter | 5 | |
| E_AND | integer | privateparameter | 10 | |
| E_CALL | integer | privateparameter | 14 | |
| E_CLAUSE | integer | privateparameter | 19 | |
| E_COMP | integer | privateparameter | 18 | |
| E_COMPARE | integer | privateparameter | 12 | |
| E_CONST | integer | privateparameter | 1 | |
| E_FSTRING | integer | privateparameter | 20 | |
| E_IF | integer | privateparameter | 13 | |
| E_INDEX | integer | privateparameter | 16 | |
| E_LIST | integer | privateparameter | 3 | |
| E_METHOD | integer | privateparameter | 15 | |
| E_MUL | integer | privateparameter | 7 | |
| E_NAME | integer | privateparameter | 2 | |
| E_NEG | integer | privateparameter | 8 | |
| E_NOT | integer | privateparameter | 9 | |
| E_OR | integer | privateparameter | 11 | |
| E_SLICE | integer | privateparameter | 17 | |
| E_SUB | integer | privateparameter | 6 | |
| E_TUPLE | integer | privateparameter | 4 | |
| FOLD_INDENT | integer | privateparameter | 4 | Fypp's default indentation of continuation lines |
| MAX_FRAMES | integer | privateparameter | 256 | how deeply scopes can nest |
| MAX_LINE | integer | privateparameter | 132 | Fypp's default longest line |
| N_ASSERT | integer | privateparameter | 9 | |
| N_CALL | integer | privateparameter | 7 | |
| N_DEF | integer | privateparameter | 6 | |
| N_EVAL | integer | privateparameter | 2 | |
| N_FOR | integer | privateparameter | 4 | |
| N_IF | integer | privateparameter | 3 | |
| N_MUTE | integer | privateparameter | 8 | |
| N_SET | integer | privateparameter | 5 | |
| N_TEXT | integer | privateparameter | 1 | |
| NL | character(len=1) | privateparameter | achar(10) | |
| T_END | integer | privateparameter | 0 | |
| T_FSTR | integer | privateparameter | 4 | |
| T_INT | integer | privateparameter | 2 | |
| T_NAME | integer | privateparameter | 1 | |
| T_OP | integer | privateparameter | 5 | |
| T_STR | integer | privateparameter | 3 | |
| TAB | character(len=1) | privateparameter | achar(9) | |
| V_BOOL | integer | privateparameter | 1 | |
| V_DICT | integer | privateparameter | 6 | |
| V_INT | integer | privateparameter | 2 | |
| V_LIST | integer | privateparameter | 4 | |
| V_MACRO | integer | privateparameter | 7 | |
| V_NONE | integer | privateparameter | 0 | |
| V_STR | integer | privateparameter | 3 | |
| V_TUPLE | integer | privateparameter | 5 |
Types
block_tprivate
The parts of a directive.
body_tprivate
The nodes of a block.
expr_tprivate
An expression, compiled.
frame_tprivate
Local variables.
fypp_tprivate
The state of processing a file.
macro_tprivate
A macro.
node_tprivate
A piece of the document.
scan_tprivate
Reading an expression.
span_tprivate
Where a result of evaluation is in the output.
value_tprivate
A Python value.
Functions
at_wordpureprivate
True if the current token is word, as an operator or keyword.
end_of_linepureprivate
The position of the end of the line with position from: of its newline, or after the last line.
equalpurerecursiveprivate
True if a equals b.
find_namepureprivate
The number of name name, or 0.
fold_positionpureprivate
Where to end the part of line after first, at most at last. Positions count from 0.
skip_blankspureprivate
The first position from from that is not a blank.
trim_lengthpureprivate
The length of text without blanks at its end.
trim_rightpureprivate
text without blanks at its end.
Subroutines
add_bodyprivate
Add a block to node, with condition condition.
assign_targetsprivate
Set the variables targets to v, unpacking it if there are several.
bind_targetsprivate
Bind the names of a loop to v in a comprehension.
call_builtinrecursiveprivate
A builtin function: defined, dict, len, list, range, reversed, str, zip.
call_directiveprivate
#:call name(arguments) or #:block name(arguments).
call_macrorecursiveprivate
Call macro which.
call_methodrecursiveprivate
A method: of strings startswith, format, join, strip and split, and of dicts get.
control_directiverecursiveprivate
Act on control directive word.
copy_valueelementalrecursiveprivate
Copy a value, with what it holds.
def_directiveprivate
#:def name(arguments). Each argument's default is compiled to an entry of args, or 0 if none.
define_macrorecursiveprivate
Define the macro of node id, evaluating its defaults now.
evaluate_argsrecursiveprivate
Evaluate the arguments of call id.
evaluate_callrecursiveprivate
A call of a macro or a builtin function.
flush_textprivate
Add the text between first and last as a text node.
fold_linepureprivate
Fold a line in Fypp's default way, at a blank near the end of the line if there is one.
fold_outputprivate
Fold the long lines of text that hold results of evaluation. Others stay as they are.
format_stringprivate
text.format(args), for fields {} and {n}.
fypp_process
The output of Fypp for file path. Each of defines is NAME or NAME=expression.
handle_directiverecursiveprivate
Act on a directive of type kind, which is $, # or @.
include_directiverecursiveprivate
#:include "file".
move_exprpureprivate
Move an expression, without copying what it holds.
move_nodepureprivate
Move a node, without copying what it holds.
move_valuepureprivate
Move a value, without copying what it holds.
parse_argumentsrecursiveprivate
The arguments of call id, up to closing.
parse_comprehensionrecursiveprivate
The for clauses after the item element.
parse_filerecursiveprivate
Read file path into the block being read.
parse_fstringrecursiveprivate
An f-string, whose quotes and escapes are already gone.
parse_itemsrecursiveprivate
The items of a list or tuple, after the first, which is first.
parse_listrecursiveprivate
An expression, or several separated by commas, which make a tuple.
parse_postfixrecursiveprivate
A primary with what follows it: calls, subscripts and methods.
parse_primaryrecursiveprivate
A primary: a literal, a name, or something in brackets.
parse_subscriptrecursiveprivate
A subscript of object, or a slice.
parse_testrecursiveprivate
An expression, which may be conditional.
parse_textrecursiveprivate
Split text, the contents of file path, into text and directives.
read_line_directivepureprivate
Read a line directive whose text starts at from, joining continuation lines.
read_targetsprivate
Read the names separated by commas at the start of text.
record_spanprivate
Record that the output from after first to last was evaluated.
render_bodyrecursiveprivate
Render the nodes of body. With top, what is evaluated is recorded for line folding.
render_callrecursiveprivate
Render a call: the block is the last positional argument.
run_clauserecursiveprivate
Run clause k of comprehension id, collecting items.
subscriptprivate
Item index of a, counting from 0, and from the end if negative.
without_carriage_returnspureprivate
Turn the line ends of text into a line feed, as Python does when it reads text.
write_valuepurerecursiveprivate
Write v as str() does, or as repr() does if quoted.