libqasm
library for handling cQASM files
Public Member Functions | Public Attributes | List of all members
cqasm::v1::analyzer::AnalysisResult Class Reference

Analysis result class. More...

Public Member Functions

ast::One< semantic::Programunwrap (std::ostream &out=std::cerr) const
 "Unwraps" the result (as you would in Rust) to get the program node or an exception. More...
 

Public Attributes

ast::One< semantic::Programroot
 Root node of the semantic tree, if analysis was successful. More...
 
std::vector< std::string > errors
 List of accumulated errors. More...
 

Detailed Description

Analysis result class.

An object of this type is returned by the various analyze*() methods of the Analyzer class. There are three possibilities.

If you don't want to manage printing error messages yourself and would like an exception upon failure in all cases, you can call unwrap() on the returned object.

Definition at line 55 of file cqasm-v1-analyzer.hpp.

#include <cqasm-v1-analyzer.hpp>

Collaboration diagram for cqasm::v1::analyzer::AnalysisResult:
Collaboration graph
[legend]

Member Function Documentation

◆ unwrap()

ast::One< semantic::Program > cqasm::v1::analyzer::AnalysisResult::unwrap ( std::ostream &  out = std::cerr) const

"Unwraps" the result (as you would in Rust) to get the program node or an exception.

The exception is always an AnalysisFailed, deriving from std::runtime_error. The actual error messages are in this case first written to the given output stream, defaulting to stderr.

Definition at line 27 of file cqasm-v1-analyzer.cpp.

Member Data Documentation

◆ root

ast::One<semantic::Program> cqasm::v1::analyzer::AnalysisResult::root

Root node of the semantic tree, if analysis was successful.

The node may be empty or incomplete if errors is nonempty; use unwrap() to ensure it's complete if you just want to use it and don't care about things like pretty-printing error messages for your users in a different way than what unwrap() does for you.

Definition at line 65 of file cqasm-v1-analyzer.hpp.

◆ errors

std::vector<std::string> cqasm::v1::analyzer::AnalysisResult::errors

List of accumulated errors.

Analysis was successful if and only if errors.empty().

Definition at line 71 of file cqasm-v1-analyzer.hpp.


The documentation for this class was generated from the following files: