Commit 57938647 authored by di68kap's avatar di68kap
Browse files

- some doc-strings updated

parent 75324a6f
......@@ -27,9 +27,9 @@ However, this becomes costly (in terms of space and as a consequence also
time) when parsing longer documents. Unfortunately, Python's `memoryview`
does not work for unicode strings. Hence, the StringView class.
It is recommended to compile this modules with the Cython-compiler for
It is recommended to compile this module with the Cython-compiler for
speedup. The modules comes with a ``stringview.pxd`` that contains some type
declarations to fully exploit the potential of the Cython-compiler.
declarations to more fully exploit the benefits of the Cython-compiler.
"""
from typing import Optional, Union, Iterable, Tuple
......
......@@ -185,17 +185,23 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil
pos (int): the position of the node within the parsed text.
The value of ``pos`` is -1 meaning invalid by default.
Setting this value will set the positions of all child
nodes relative to this value.
To set the pos values of all nodes in a syntax tree, the
pos value of the root node should be set to 0 right
after parsing.
Other than that, this value should be considered READ ONLY.
At any rate, it should only be reassigned during the parsing
stage and never during or after the AST-transformation.
The default value of ``pos`` is -1 meaning invalid by default.
Setting pos to a value >= 0 will trigger the assignment
of position values of all child nodes relative to this value.
The pos field is WRITE ONCE, i.e. once assigned it cannot be
reassigned. The assignment of the pos values happens either
during the parsing process or, when later added to a tree,
the pos-values of which have already been initialized.
Thus, pos-values always retain their position in the source
text. If in any tree-processing stage after parsing, nodes
are added or deleted, the pos values will not represent
the position within in the string value of the tree.
Retaining the original source positions is crucial for
correctly locating errors which might only be detected at
later stages of the tree-transformation within the source text.
attr (dict): An optional dictionary of XML-attr. This
dictionary is created lazily upon first usage. The attr
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment