qiskit/qasm/qasmparser.py
def verify_as_gate(self, obj, bitlist, arglist=None):
        """Verify a user defined gate call."""
        if obj.name not in self.global_symtab:
            raise QasmError("Cannot find gate definition for '" + obj.name
                            + "', line", str(obj.line), 'file', obj.file)
        g_sym = self.global_symtab[obj.name]
        if not (g_sym.type == 'gate' or g_sym.type == 'opaque'):
            raise QasmError("'" + obj.name + "' is used as a gate "
                            + "or opaque call but the symbol is neither;"
                            + " it is a '" + g_sym.type + "' line",
                            str(obj.line), 'file', obj.file)

        if g_sym.n_bits() != bitlist.size():
            raise QasmError("Gate or opaque call to '" + obj.name
                            + "' uses", str(bitlist.size()),
                            "qubits but is declared for",
                            str(g_sym.n_bits()), "qubits", "line",
                            str(obj.line), 'file', obj.file)

        if arglist:
            if g_sym.n_args() != arglist.size():
                raise QasmError("Gate or opaque call to '" + obj.name
                                + "' uses", str(arglist.size()),
                                "qubits but is declared for",
                                str(g_sym.n_args()), "qubits", "line",
                                str(obj.line), 'file', obj.file)
        else:
            if g_sym.n_args() > 0:
                raise QasmError("Gate or opaque call to '" + obj.name
                                + "' has no arguments but is declared for",
                                str(g_sym.n_args()), "qubits", "line",
                                str(obj.line), 'file', obj.file)
def verify_as_gate(self, obj, bitlist, arglist=None):
        """Verify a user defined gate call."""
        if obj.name not in self.global_symtab:
            raise QasmError("Cannot find gate definition for '" + obj.name
                            + "', line", str(obj.line), 'file', obj.file)
        g_sym = self.global_symtab[obj.name]
        if not (g_sym.type == 'gate' or g_sym.type == 'opaque'):
            raise QasmError("'" + obj.name + "' is used as a gate "
                            + "or opaque call but the symbol is neither;"
                            + " it is a '" + g_sym.type + "' line",
                            str(obj.line), 'file', obj.file)

        if g_sym.n_bits() != bitlist.size():
            raise QasmError("Gate or opaque call to '" + obj.name
                            + "' uses", str(bitlist.size()),
                            "qubits but is declared for",
                            str(g_sym.n_bits()), "qubits", "line",
                            str(obj.line), 'file', obj.file)

        if arglist:
            if g_sym.n_args() != arglist.size():
                raise QasmError("Gate or opaque call to '" + obj.name
                                + "' uses", str(arglist.size()),
                                "qubits but is declared for",
                                str(g_sym.n_args()), "qubits", "line",
                                str(obj.line), 'file', obj.file)
        else:
            if g_sym.n_args() > 0:
                raise QasmError("Gate or opaque call to '" + obj.name
                                + "' has no arguments but is declared for",
                                str(g_sym.n_args()), "qubits", "line",
                                str(obj.line), 'file', obj.file)
Verify a user defined gate call.