143 bool resolve_instructions;
160 bool resolve_error_model;
167 Analyzer(
const std::string &api_version =
"1.0");
177 void register_mapping(
const std::string &name,
const values::Value &value);
190 void register_function(
191 const std::string &name,
201 void register_function(
202 const std::string &name,
203 const std::string ¶m_types,
212 void register_default_functions_and_mappings();
226 void register_instruction(
227 const std::string &name,
228 const std::string ¶m_types =
"",
229 bool allow_conditional =
true,
230 bool allow_parallel =
true,
231 bool allow_reused_qubits =
false,
232 bool allow_different_index_sizes =
false 240 template <
typename T>
243 const std::string &name,
244 const std::string ¶m_types =
"",
245 bool allow_conditional =
true,
246 bool allow_parallel =
true,
247 bool allow_reused_qubits =
false,
248 bool allow_different_index_sizes =
false 256 allow_different_index_sizes
258 insn.set_annotation<T>(std::forward<T>(annotation));
259 register_instruction(insn);
274 void register_error_model(
275 const std::string &name,
276 const std::string ¶m_types =
"" 284 template <
typename T>
287 const std::string &name,
288 const std::string ¶m_types =
"" 294 model.set_annotation<T>(std::forward<T>(annotation));
295 register_error_model(model);
Main class used for analyzing cQASM files.
tree::One< semantic::Program > analyze_string(const std::string &data, const std::string &filename, const std::string &api_version)
Parses and analyzes the given string with the default analyzer, dumping error messages to stderr and ...
Defines the types for the cQASM abstract syntax tree, based on the classes from cqasm::tree.
Exception thrown by AnalysisResult::unwrap() when the cQASM file fails to parse.
std::vector< std::string > errors
List of accumulated errors.
Toplevel namespace with entry points for the new API.
tree::One< semantic::Program > analyze(const std::string &filename, const std::string &api_version)
Parses and analyzes the given file with the default analyzer, dumping error messages to stderr and th...
void register_error_model_with_annotation(T &&annotation, const std::string &name, const std::string ¶m_types="")
Convenience method for registering an error model with a single user-specified annotation.
Table of the supported instructions and their overloads.
Defines the types for the cQASM semantic tree, based on the classes from cqasm::tree.
Version number primitive used within the AST and semantic trees.
ast::One< semantic::Program > root
Root node of the semantic tree, if analysis was successful.
Representation of an error model.
Contains helper classes and objects for the lexer and parser generated by flex/bison, as well as the entry points for invoking the parser directly, in case you don't need semantic analysis.
Representation of an available instruction (also known as gate) in the instruction set...
cqasm::tree::One< T > One
Table of all overloads of all constant propagation functions.
Table of the supported instructions and their overloads.
Namespace for the "new" cQASM 1.x API.
tree::One< Node > Value
A cQASM value, either known at compile-time or an expression for something only known at runtime...
Table of all mappings within a certain scope.
tree::Any< TypeBase > Types
Zero or more cQASM types.
Contains MappingTable, FunctionTable, and ErrorModelTable, representing the various cQASM namespaces ...
Parse result information.
Helper class for analyzing a single AST.
void register_instruction_with_annotation(T &&annotation, const std::string &name, const std::string ¶m_types="", bool allow_conditional=true, bool allow_parallel=true, bool allow_reused_qubits=false, bool allow_different_index_sizes=false)
Convenience method for registering an instruction type with a single user-specified annotation...
std::function< values::Value(const values::Values &)> FunctionImpl
C++ function representing (one of the overloads of) a function usable in cQASM constant expressions...