httk.core.optimade.filter.parser¶
Parser for the OPTIMADE filter language.
Parses an OPTIMADE filter string into a nested tuple abstract syntax tree (the “ojf” format), e.g.:
('AND', ('HAS_ALL', ('=', '='), ('Identifier', 'elements'),
(('String', 'Ga'), ('String', 'Ti'))),
('OR', ('=', ('Identifier', 'nelements'), ('Number', '3')),
('=', ('Identifier', 'nelements'), ('Number', '2'))))
Attributes¶
Exceptions¶
Common base class for all non-exit exceptions. |
|
Common base class for all non-exit exceptions. |
Functions¶
|
Parse an OPTIMADE filter into the public abstract syntax tree format. |
|
Parse an OPTIMADE filter and return its raw grammar parse tree. |
Module Contents¶
- exception httk.core.optimade.filter.parser.ParserError[source]¶
Bases:
ExceptionCommon base class for all non-exit exceptions.
- exception httk.core.optimade.filter.parser.ParserSyntaxError(*args)[source]¶
Bases:
ParserErrorCommon base class for all non-exit exceptions.
- info¶
- line¶
- pos¶
- linestr¶
- httk.core.optimade.filter.parser.parse_optimade_filter(filter_string, verbosity=0)[source]¶
Parse an OPTIMADE filter into the public abstract syntax tree format.
- Parameters:
- Returns:
Nested tuple abstract syntax tree in
ojfformat.- Raises:
ParserSyntaxError – If the filter cannot be parsed, or is too long or too deeply nested to parse within the interpreter’s recursion limit.
ParserError – If the filter cannot be parsed.
- Return type:
- httk.core.optimade.filter.parser.parse_optimade_filter_raw(filter_string, verbosity=0)[source]¶
Parse an OPTIMADE filter and return its raw grammar parse tree.
- Parameters:
- Returns:
Raw nested tuple parse tree before
ojfconversion.- Raises:
ParserSyntaxError – If the filter cannot be parsed, or is too long or too deeply nested to parse within the interpreter’s recursion limit.
ParserError – If the filter cannot be parsed.
- Return type:
tuple[Any, …]