diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2001-01-16 14:18:55 (GMT) |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2001-01-16 14:18:55 (GMT) |
commit | bd1a489759db0f2019d740ce5f36d8d223e57488 (patch) | |
tree | 68dcaeb2ad31a865035f3bd0e35a1c2eb0a930a0 /Doc | |
parent | 159830ec3ab44249a45100e15eb4c697ff3562bb (diff) | |
download | cpython-bd1a489759db0f2019d740ce5f36d8d223e57488.zip cpython-bd1a489759db0f2019d740ce5f36d8d223e57488.tar.gz cpython-bd1a489759db0f2019d740ce5f36d8d223e57488.tar.bz2 |
push_source() and pop_source() entry points for shlex instances.
These basically just make available to the user what userhook()
does to the source stack. Documentation included.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libshlex.tex | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/Doc/lib/libshlex.tex b/Doc/lib/libshlex.tex index 85cbbcd..b908937 100644 --- a/Doc/lib/libshlex.tex +++ b/Doc/lib/libshlex.tex @@ -66,15 +66,34 @@ request in effect, or the previous source was a stream result is a relative pathname, the directory part of the name of the file immediately before it on the source inclusion stack is prepended (this behavior is like the way the C preprocessor handles -\code{\#include "file.h"}). The result of the manipulations is treated -as a filename, and returned as the first component of the tuple, with -\function{open()} called on it to yield the second component. +\code{\#include "file.h"}). + +The result of the manipulations is treated as a filename, and returned +as the first component of the tuple, with +\function{open()} called on it to yield the second component. (Note: +this is the reverse of the order of arguments in instance initialization!) This hook is exposed so that you can use it to implement directory search paths, addition of file extensions, and other namespace hacks. There is no corresponding `close' hook, but a shlex instance will call the \method{close()} method of the sourced input stream when it returns \EOF. + +For more explicit control of source stacking, use the next two +methods. +\end{methoddesc} + +\begin{methoddesc}{push_source}{stream\optional{, filename}} +Push an input source stream onto the input stack. If the filename +argument is specified it will later be available for use in error +messages. This is the same method used internally by the +\method{sourcehook} method. (New in 2.1) +\end{methoddesc} + +\begin{methoddesc}{pop_source}{}} +Pop the last-pushed input source from the input stack. +This is the same method used internally when the lexer reaches +\EOF on a stacked input stream. (New in 2.1) \end{methoddesc} \begin{methoddesc}{error_leader}{\optional{file\optional{, line}}} |