Qiskit-terra: print_tokens method under QasmParser class does not return anything (if it succeed)

Created on 23 Jan 2018  路  3Comments  路  Source: Qiskit/qiskit-terra

Expected Behavior & Context

I'm trying to parse a QASM code. But when I use parser functions by this way:

from qiskit import qasm
_qasm = qasm.Qasm(filename="test.qasm")
print(_qasm.print_tokens())

the method print_tokens() (https://github.com/QISKit/qiskit-sdk-py/blob/master/qiskit/qasm/_qasmparser.py#L1050) does not return anything and the print() I used raises only None. Reviewing the code, the method print_tokens under _QasmParser_ (which is used within the method print_tokens() under the Qasm class https://github.com/QISKit/qiskit-sdk-py/blob/master/qiskit/qasm/_qasm.py#L42) class tries to print the tokens resulting, but it does not return that string with the results.

Possible solution

I think the solution is simple, the print_tokens() method under _QasmParser_ class should return the string with the tokens instead of trying to print() the string.

Your Environment

  • Version used: qiskit==0.4.6
  • Environment name and version (e.g. Python 3.6.1): Python == 3.6.2
  • Operating System and version: Mac OS X 10.13.2
bug good first issue

All 3 comments

Possible related, the self.lexer.token() call in _qasmparser.py looks like returning None in every case.

Can I work on this issue?

PR #306 merged, so issue fixed!
Thanks @ysiraichi and @1ucian0 !!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ajavadia picture ajavadia  路  5Comments

Zhuravlev-A-E picture Zhuravlev-A-E  路  6Comments

ewinston picture ewinston  路  3Comments

1ucian0 picture 1ucian0  路  6Comments

1ucian0 picture 1ucian0  路  5Comments