FPIBG Utility
|
Public Member Functions | |
__init__ (self, tokens) | |
from_file (cls, f, filename=None, includedir='', seenfiles=None) | |
peek (self) | |
accept (self, *args) | |
expect (self, *args) | |
error (self, msg) | |
finished (self) | |
Public Attributes | |
int | position = 0 |
tokens = list(tokens) | |
Offer a parsing-oriented view on tokens Provide several methods that are useful to parsers, like ``accept()``, ``expect()``, ... The ``from_file()`` method is the preferred way to read input files, as it handles include directives, which the ``Tokenizer`` class does not do.
libconf.TokenStream.__init__ | ( | self, | |
tokens ) |
libconf.TokenStream.accept | ( | self, | |
* | args ) |
Consume and return the next token if it has the correct type Multiple token types (as strings, e.g. 'integer64') can be given as arguments. If the next token is one of them, consume and return it. If the token type doesn't match, return None.
libconf.TokenStream.error | ( | self, | |
msg ) |
Raise a ConfigParseError at the current input position
libconf.TokenStream.expect | ( | self, | |
* | args ) |
Consume and return the next token if it has the correct type Multiple token types (as strings, e.g. 'integer64') can be given as arguments. If the next token is one of them, consume and return it. If the token type doesn't match, raise a ConfigParseError.
libconf.TokenStream.finished | ( | self | ) |
Return ``True`` if the end of the token stream is reached.
libconf.TokenStream.from_file | ( | cls, | |
f, | |||
filename = None, | |||
includedir = '', | |||
seenfiles = None ) |
Create a token stream by reading an input file Read tokens from `f`. If an include directive ('@include "file.cfg"') is found, read its contents as well. The `filename` argument is used for error messages and to detect circular imports. ``includedir`` sets the lookup directory for included files. ``seenfiles`` is used internally to detect circular includes, and should normally not be supplied by users of is function.
libconf.TokenStream.peek | ( | self | ) |
Return (but do not consume) the next token At the end of input, ``None`` is returned.
int libconf.TokenStream.position = 0 |
libconf.TokenStream.tokens = list(tokens) |