zero.liso.output module

LISO output file parser

class zero.liso.output.LisoOutputParser(*args, **kwargs)[source]

Bases: zero.liso.base.LisoParser

LISO output file parser

This implements a lexer to identify appropriate definitions in a LISO output file, and a parser to build a solution and circuit from what is found.

The parsing of the LISO output file is more complicated than that for the input file. The data is first parsed. For this, the lexer is initially in its default state and it simply looks for numbers matching a certain pattern (DATUM tokens). In the parser, these are combined together in a list until a NEWLINE token is identified, at which point the list representing a line of the data file is added to the list representing the whole data set.

With the data parsed, the next step is to parse the circuit definition which is included in the output file. This is not only necessary in order to simulate the circuit again, natively, but also for understanding the meaning of the data columns identified in the last step. The parsing of this metadata is handled by identifying in turn the sections in the commented block below the data that correspond to the various parts of the circuit definition. As these have different formats, the lexer enters into different states once it identifies each section, with special lexing rules. The identified tokens are passed to the parser, which pieces them together in set patterns. Once a particular line is parsed (or lines, in the case of op-amps), the particular combination of tokens used to create the line is used to create the circuit.

OPAMP_IGNORE_STRINGS = ['*OVR*', 's***DEFAULT', '***DEFAULT']
property n_capacitors
property n_current_outputs
property n_inductors
property n_mutual_inductances
property n_nodes
property n_noise
property n_noise_sources
property n_noisy
property n_opamps
property n_resistors
property n_voltage_outputs
p_capacitor(p)[source]

capacitor : CAPACITOR NEWLINE

p_current_output_component(p)[source]

current_output_component : CURRENT_OUTPUT_COMPONENT NEWLINE

p_data(p)[source]

data : data datum | datum

p_data_line(p)[source]

data_line : data NEWLINE | NEWLINE

p_datum(p)[source]

datum : DATUM

p_error(p)[source]

Child classes must implement error handler

p_file_contents(p)[source]

file_contents : file_line | file_contents file_line

p_file_line(p)[source]

file_line : data_line | metadata_line

p_inductor(p)[source]

inductor : INDUCTOR NEWLINE

p_metadata_line(p)[source]

metadata_line : resistor | capacitor | inductor | mutual_inductance | opamp | node | voltage_output_node | current_output_component | noise_outputs | noisy_sources

p_mutual_inductance(p)[source]

mutual_inductance : MUTUAL_INDUCTANCE NEWLINE

p_node(p)[source]

node : NODE NEWLINE

p_noise_outputs(p)[source]

noise_outputs : NOISE_OUTPUTS NEWLINE

p_noisy_sources(p)[source]

noisy_sources : NOISY_SOURCES NEWLINE

p_opamp(p)[source]

opamp : OPAMP_CHUNK_1 NEWLINE OPAMP_CHUNK_2 NEWLINE OPAMP_CHUNK_3 NEWLINE OPAMP_CHUNK_4 NEWLINE | OPAMP_CHUNK_1 NEWLINE OPAMP_CHUNK_2 NEWLINE OPAMP_CHUNK_3 NEWLINE

p_resistor(p)[source]

resistor : RESISTOR NEWLINE

p_voltage_output_node(p)[source]

voltage_output_node : VOLTAGE_OUTPUT_NODE NEWLINE

property source_sum_index
states = (('resistors', 'inclusive'), ('capacitors', 'inclusive'), ('inductors', 'inclusive'), ('mutualinductances', 'inclusive'), ('opamps', 'inclusive'), ('nodes', 'inclusive'), ('voltageoutputnodes', 'inclusive'), ('currentoutputcomponents', 'inclusive'), ('noisevoltageoutputs', 'inclusive'), ('noisecurrentoutputs', 'inclusive'), ('noisysources', 'inclusive'), ('gnuplotoptions', 'inclusive'))
t_ANY_capacitors(t)[source]

#(?P<n>d+)scapacitors?:

t_ANY_currentinput(t)[source]

#Currentsinputsintosnodes(?P<node>.+),simpedances(?P<impedance>.+)Ohm

t_ANY_currentoutputcomponents(t)[source]

#OUTPUTs(?P<nout>d+)scurrentsoutputs?:

t_ANY_floatingvoltageinput(t)[source]

#Floatingsvoltagesinputsbetweensnodess(?P<node_p>.+)sands(?P<node_n>.+),simpedances(?P<impedance>.+)Ohm

t_ANY_gnuplotoptions(t)[source]

#d+sGNUPLOT.*

t_ANY_inductors(t)[source]

#(?P<n>d+)scoils?:

t_ANY_inputrefer(t)[source]

#NoisesissINPUT-REFERREDstos(.*)sinputsatsnodes(.*).

t_ANY_mutualinductances(t)[source]

#(?P<n>d+)smutualsinductances?:

t_ANY_nodes(t)[source]

#(?P<n>d+)snodes?:

t_ANY_noisecurrentoutputs(t)[source]

#OUTPUTs(?P<nsource>d+)snoisescurrents?scausedsby:

t_ANY_noiseinputreferred(t)[source]

#sNoisesissREFERREDsTOsTHEsINPUT.

t_ANY_noisevoltageoutputs(t)[source]

#OUTPUTs(?P<nsource>d+)snoisesvoltages?scausedsby:

t_ANY_noisysources(t)[source]

#Noisesisscomputeds(?P<ntype>atsnode|throughscomponent)s(?:.+:)?(?P<element>.+)sfors(nnoise=(?P<nnoise>d+),snnoisy=(?P<nnoisy>d+))s:

t_ANY_opamps(t)[source]

#(?P<n>d+)sop-amps?:

t_ANY_resistors(t)[source]

#(?P<n>d+)sresistors?:

t_ANY_voltageinput(t)[source]

#Voltagesinputsatsnodes(?P<node>.+),simpedances(?P<impedance>.+)Ohm

t_ANY_voltageoutputnodes(t)[source]

#OUTPUTs(?P<nout>d+)svoltagesoutputs?:

t_DATUM = '-?(inf|(\\d+\\.\\d*|\\d*\\.\\d+|\\d+)([eE]-?\\d*\\.?\\d*)?)'
t_capacitors_CAPACITOR(t)[source]

#s+d+s+(?P<capacitor>.*)

t_currentoutputcomponents_CURRENT_OUTPUT_COMPONENT(t)[source]

#s+(?P<index>d+)s(?P<component>.*)

t_gnuplotoptions(t)[source]

#.*

t_ignore = ' \t'
t_ignore_COMMENT = '\\#.*'
t_inductors_INDUCTOR(t)[source]

#s+d+s+(?P<inductor>.*)

t_mutualinductances_MUTUAL_INDUCTANCE(t)[source]

#s+d+s+(?P<mutual_inductance>.*)

t_newline(t)[source]

n+

t_nodes_NODE(t)[source]

#s+d+s+(?P<node>.*)

t_noisevoltageoutputs_noisecurrentoutputs_NOISE_OUTPUTS(t)[source]

#s*(?P<components>.*)

t_noisysources_NOISY_SOURCES(t)[source]

#s+(?P<components>.*)

t_opamps_OPAMP_CHUNK_1(t)[source]

#s+d+s+(?P<opamp1>.*)

t_opamps_OPAMP_CHUNK_2(t)[source]

#s+(?P<opamp2>un=.*)

t_opamps_OPAMP_CHUNK_3(t)[source]

#s+(?P<opamp3>umax=.*)

t_opamps_OPAMP_CHUNK_4(t)[source]

#s+(?P<opamp4>pole.*)

t_resistors_RESISTOR(t)[source]

#s+d+s+(?P<resistor>.*)

t_voltageoutputnodes_VOLTAGE_OUTPUT_NODE(t)[source]

#s+(?P<index>d+)snode:s(?P<node>.*)

tokens = ['DATUM', 'NEWLINE', 'RESISTOR', 'CAPACITOR', 'INDUCTOR', 'MUTUAL_INDUCTANCE', 'OPAMP_CHUNK_1', 'OPAMP_CHUNK_2', 'OPAMP_CHUNK_3', 'OPAMP_CHUNK_4', 'NODE', 'VOLTAGE_OUTPUT_NODE', 'CURRENT_OUTPUT_COMPONENT', 'NOISE_OUTPUTS', 'NOISY_SOURCES']