From f7d53e269b59c2673b0ecc06c74ec73259eed76e Mon Sep 17 00:00:00 2001 From: zhao-yilun-zyl Date: Sun, 28 Jul 2024 22:40:47 +0800 Subject: [PATCH] fix(parser): reset stream position for direct string input --- lib/Parser/QasmParser.y | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Parser/QasmParser.y b/lib/Parser/QasmParser.y index 538f562..c802403 100644 --- a/lib/Parser/QasmParser.y +++ b/lib/Parser/QasmParser.y @@ -384,6 +384,11 @@ int yyparse() { if (OQ != "OPENQASM" || OV.empty()) QASM::ASTOpenQASMVersionTracker::Instance().SetVersion(3.0); + if (IIS) { + IIS->clear(); + IIS->seekg(0, std::ios::beg); + } + if (!QASM::QasmPreprocessor::Instance().Preprocess(IIS)) { std::stringstream M; M << "OpenQASM Preprocessor failure!";