zero.config.query module

Library query parser

exception zero.config.query.LibraryParserError(message, line=None, pos=None, **kwargs)[source]

Bases: ValueError

Library parser error

class zero.config.query.LibraryQueryEngine[source]

Bases: object

Query engine for op-amp library

property opamp_set
property parameters
query(text, sort_order=None)[source]

Query the library.

Parameters
  • text (str) – The query text.

  • sort_order (dict, optional) – The sort order map. If specified, the items in this dictionary are used to determine the sort order for the returned results. The keys represent the parameter to filter, and the values represent the order (standard or reverse). The sorting is applied in the order that the parameter appears in the query text (left to right).

Returns

list – The matched op-amps.

class zero.config.query.LibraryQueryParser[source]

Bases: object

Op-amp library query parser.

This implements a lexer to identify search terms for the Zero op-amp library, and returns lambda functions that perform corresponding checks.

p_binary_expression(t)[source]

expression : expression binary_operator expression

p_binary_operator(t)[source]

binary_operator : OR | AND

p_comparison_expression(t)[source]

expression : PARAMETER comparison_operator ID | PARAMETER comparison_operator value_with_unit

p_comparison_operator(t)[source]

comparison_operator : EQUAL | NOT_EQUAL | GREATER_THAN | GREATER_THAN_EQUAL | LESS_THAN | LESS_THAN_EQUAL

p_error(p)[source]
p_expression_group(t)[source]

expression : LPAREN expression RPAREN

p_statement(t)[source]

statement : expression

p_value_with_unit(t)[source]

value_with_unit : ID ID

parameters = {'a0': 'OPEN_LOOP_GAIN', 'gbw': 'GAIN_BANDWIDTH', 'icorner': 'INOISE_CORNER', 'imax': 'I_MAX', 'inoise': 'INOISE', 'model': 'MODEL', 'sr': 'SLEW_RATE', 'vcorner': 'VNOISE_CORNER', 'vmax': 'V_MAX', 'vnoise': 'VNOISE'}
parse(text)[source]
t_AND = '\\&'
t_EQUAL = '=='
t_GREATER_THAN = '>'
t_GREATER_THAN_EQUAL = '>='
t_ID(t)[source]

[a-zA-Z?*d.-]+

t_LESS_THAN = '<'
t_LESS_THAN_EQUAL = '<='
t_LPAREN = '\\('
t_NOT_EQUAL = '!='
t_OR = '\\|'
t_RPAREN = '\\)'
t_eof(t)[source]
t_error(t)[source]
t_ignore = ' \t'
t_newline(t)[source]

n+

tokens = ['ID', 'PARAMETER', 'EQUAL', 'NOT_EQUAL', 'GREATER_THAN', 'GREATER_THAN_EQUAL', 'LESS_THAN', 'LESS_THAN_EQUAL', 'AND', 'OR', 'LPAREN', 'RPAREN']