this is my existing code, which read the netlist of my two stage operational amplifier circuit, and get the parameters and its values of each components as per given in the code given below,
Netlist:
M7 (Vbias Vbias 0 0) n_18_mm w=W5/1 l=L5 nf=1 mis_flag=1 \
M6 (VOUT Vbias 0 0) n_18_mm w=W7/1 l=L7 nf=1 mis_flag=1 \
M4 (net1 Vbias 0 0) n_18_mm w=W5/1 l=L5 nf=1 mis_flag=1 \
M1 (net2 IN2 net1 0) n_18_mm w=W1/1 l=L1 nf=1 mis_flag=1 \
M0 (net3 IN1 net1 0) n_18_mm w=W1/1 l=L1 nf=1 mis_flag=1 \
M5 (VOUT net2 vdd! vdd!) p_18_mm w=W6/1 l=L6 nf=1 mis_flag=1 \
M3 (net2 net3 vdd! vdd!) p_18_mm w=W3/1 l=L3 nf=1 mis_flag=1 \
M2 (net3 net3 vdd! vdd!) p_18_mm w=W3/1 l=L3 nf=1 mis_flag=1 \
I0 (vdd! Vbias) isource dc=Ib type=dc
C1 (VOUT 0) capacitor c=2p
C0 (VOUT net2) capacitor c=Cc
V1 (IN2 0) vsource dc=Vc type=dc
V0 (vdd! 0) vsource dc=1.8 type=dc
V2 (IN1 IN2) vsource dc=0 mag=200m type=sine freq=1K

Code:
def parse_value_with_unit(value_str, variables):
    multipliers = {'m': 1e-3, 'u': 1e-6, 'n': 1e-9, 'p': 1e-12, 'f': 1e-15, 'k': 1e3, 'K': 1e3, 'M': 1e6, 'G': 1e9}
    unit = value_str[-1]
    if unit in multipliers:
        return float(value_str[:-1]) * multipliers[unit]
    else:
        if value_str in variables:
            return variables[value_str]
        else:
            return float(value_str)

def parse_netlist(netlist):
    # Define regular expressions
    nmos_pattern = re.compile(r'(M\d+) \((.*?)\) n_18_mm w=([\d.]+(?:e[+-]?\d+)?|\w+)/1 l=([\d.]+(?:e[+-]?\d+)?|\w+) nf=\d+')
    pmos_pattern = re.compile(r'(M\d+) \((.*?)\) p_18_mm w=([\d.]+(?:e[+-]?\d+)?|\w+)/1 l=([\d.]+(?:e[+-]?\d+)?|\w+) nf=\d+')
    resistor_pattern = re.compile(r'(R\d+) \((.*?)\) .* r=(\d+\.\d+|\w+)')
    inductor_pattern = re.compile(r'(L\d+) \((.*?)\) .* l=(\d+\.\d+|\w+)')
    capacitor_pattern = re.compile(r'(C\d+) \((.*?)\) .* c=(\d+\.\d+|\w+)')
    current_source_pattern = re.compile(r'(I\d+) \((.*?)\) .* dc=(\d+\.\d+|\w+) type=dc')
    voltage_source_patterns = {
        'dc': re.compile(r'(V\d+) \((.*?)\) .* dc=(\d+\.\d+|\w+) type=dc'),
        'sine': re.compile(r'(V\d+) \((.*?)\) .* dc=(\d+\.\d+|\w+) mag=(\d+\.\d+|\w+) type=sine freq=(\d+\.\d+|\w+)'),
        'pulse': re.compile(r'(V\d+) \((.*?)\) .* type=pulse val0=(\w+) val1=(\w+) period=(\w+) delay=(\w+) rise=(\w+)\s*fall=(\w+) width=(\w+)')
    }

    # Initialize components dictionary
    components = {
        'NMOS_transistors': [],
        'PMOS_transistors': [],
        'resistors': [],
        'inductors': [],
        'capacitors': [],
        'current_sources': [],
        'voltage_sources': []
    }

    # Initialize a dictionary to store variable values
    variables = {}

    # Iterate through each line of the netlist
    for line in netlist.split('\n'):

        # Check for variables in the parameters line
        if line.startswith('parameters'):
            params = line.split()[1:]  # Extract parameters excluding the 'parameters' keyword
            for param in params:
                if '=' in param:
                    name, value = param.split('=')
                    variables[name] = parse_value_with_unit(value, variables)
                else:
                    print(f"Ignoring malformed parameter: {param}")
            continue

        # Check for NMOS transistors
        match = nmos_pattern.search(line)
        if match:
            transistor_name, nets, width_var, length_var = match.groups()
            length = variables[length_var] if length_var in variables else parse_value_with_unit(length_var, variables)            
            width = variables[width_var] if width_var in variables else parse_value_with_unit(width_var, variables)            
            components['NMOS_transistors'].append({'device_name': transistor_name, 'nets': nets.split(), 'length': length, 'width': width})
            continue

        # Check for PMOS transistors
        match = pmos_pattern.search(line)
        if match:
            transistor_name, nets, width_var, length_var = match.groups()
            length = variables[length_var] if length_var in variables else parse_value_with_unit(length_var, variables)            
            width = variables[width_var] if width_var in variables else parse_value_with_unit(width_var, variables)            
            components['PMOS_transistors'].append({'device_name': transistor_name, 'nets': nets.split(), 'length': length, 'width': width})
            continue

        # Check for resistors
        match = resistor_pattern.search(line)
        if match:
            resistor_name, nets, resistance_str = match.groups()
            if resistance_str in variables:
                resistance = variables[resistance_str]
            else:
                resistance = parse_value_with_unit(resistance_str, variables)
            components['resistors'].append({'device_name': resistor_name, 'nets': nets.split(), 'resistance': resistance})
            continue

        # Check for inductors
        match = inductor_pattern.search(line)
        if match:
            inductor_name, nets, inductance_str = match.groups()
            if inductance_str in variables:
                inductance = variables[inductance_str]
            else:
                inductance = parse_value_with_unit(inductance_str, variables)
            components['inductors'].append({'device_name': inductor_name, 'nets': nets.split(), 'inductance': inductance})
            continue

        # Check for capacitors
        match = capacitor_pattern.search(line)
        if match:
            capacitor_name, nets, capacitance_str = match.groups()
            if capacitance_str in variables:
                capacitance = variables[capacitance_str]
            else:
                capacitance = parse_value_with_unit(capacitance_str, variables)
            components['capacitors'].append({'device_name': capacitor_name, 'nets': nets.split(), 'capacitance': capacitance})
            continue

        # Check for voltage sources
        for source_type, pattern in voltage_source_patterns.items():
            match = pattern.search(line)
            if match:
                voltage_source_name = match.group(1)
                nets = match.group(2)
                if source_type == 'dc':
                    dc_value_str = match.group(3)
                    dc_value = parse_value_with_unit(dc_value_str, variables)
                    components['voltage_sources'].append({'device_name': voltage_source_name, 'nets': nets.split(), 'dc_value': dc_value, 'type': source_type})
                elif source_type == 'sine':
                    dc_value_str = match.group(3)
                    ac_value_str = match.group(4)
                    frequency_str = match.group(5)
                    dc_value = parse_value_with_unit(dc_value_str, variables)
                    ac_value = parse_value_with_unit(ac_value_str, variables)
                    frequency = parse_value_with_unit(frequency_str, variables)
                    components['voltage_sources'].append({'device_name': voltage_source_name, 'nets': nets.split(), 'dc_value': dc_value, 'ac_value': ac_value, 'frequency': frequency, 'type': source_type})
                elif source_type == 'pulse':
                    val0_str = match.group(3)
                    val1_str = match.group(4)
                    period_str = match.group(5)
                    delay_str = match.group(6)
                    rise_str = match.group(7)
                    fall_str = match.group(8)
                    width_str = match.group(9)
                    val0 = parse_value_with_unit(val0_str, variables)
                    val1 = parse_value_with_unit(val1_str, variables)
                    period = parse_value_with_unit(period_str, variables)
                    delay = parse_value_with_unit(delay_str, variables)
                    rise = parse_value_with_unit(rise_str, variables)
                    fall = parse_value_with_unit(fall_str, variables)
                    width = parse_value_with_unit(width_str, variables)
                    components['voltage_sources'].append({'device_name': voltage_source_name, 'nets': nets.split(), 'val0': val0, 'val1': val1, 'period': period, 'delay': delay, 'rise': rise, 'fall': fall, 'width': width, 'type': source_type})
                break

        # Check for current sources
        match = current_source_pattern.search(line)
        if match:
            current_source_name, nets, dc_value_str = match.groups()
            # Check if the value is a variable name
            if dc_value_str in variables:
                dc_value = variables[dc_value_str]
            else:
                dc_value = parse_value_with_unit(dc_value_str, variables)
            components['current_sources'].append({'device_name': current_source_name, 'nets': nets.split(), 'dc_value': dc_value})
            continue


    return components