pypuppetdbquery.parser module¶
-
exception
pypuppetdbquery.parser.
ParseException
(message, position)[source]¶ Bases:
Exception
Raised for errors encountered during parsing.
The position of the lexer when the error was encountered (the index into the input string) is stored in the position attribute.
-
class
pypuppetdbquery.parser.
Parser
(lex_options=None, yacc_options=None)[source]¶ Bases:
object
Parser for the PuppetDBQuery language.
This class uses
ply.yacc.yacc()
to implement the parser. In concert withpypuppetdbquery.lexer.Lexer
, it produces an Abstract Syntax Tree (AST) as declared inpypuppetdbquery.ast
.Parameters: - lex_options (dict) – Passed as keyword arguments to
pypuppetdbquery.lexer.Lexer
- yacc_options (dict) – Passed as keyword arguments to
ply.yacc.yacc()
Note
Many of the docstrings in this class are used by
ply.yacc
to build the parser. These strings are not particularly useful for generating documentation from, so the built documentation for this class may not be very useful.-
p_comparison_op
(p)[source]¶ - comparison_op : MATCH
- NOTMATCHEQUALSNOTEQUALSGREATERTHANGREATERTHANEQLESSTHANLESSTHANEQ
-
p_resource_expr_exported_param
(p)[source]¶ resource_expr : EXPORTED string LBRACK identifier RBRACK block_expr
-
parse
(text, debug=0)[source]¶ Parse the input string and return an AST.
Parameters: - text (str) – The query to parse
- debug (bool) – Output detailed information during the parsing process
Returns: An Abstract Syntax Tree
Return type:
-
precedence
= (('left', 'OR'), ('left', 'AND'), ('left', 'EQUALS', 'MATCH', 'LESSTHAN', 'GREATERTHAN'), ('right', 'NOT'))¶ Precedence rules in lowest to highest order
-
start
= 'query'¶ Non-terminal to use as the starting grammar symbol
- lex_options (dict) – Passed as keyword arguments to