.. _program_listing_file_blackbird_cpp_Blackbird.h: Program Listing for File Blackbird.h ==================================== |exhale_lsh| :ref:`Return to documentation for file ` (``blackbird_cpp/Blackbird.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2019 Xanadu Quantum Technologies Inc. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #define _USE_MATH_DEFINES #include #include #include #include #include #include #include "antlr4-runtime/antlr4-runtime.h" #include "blackbirdLexer.h" #include "blackbirdParser.h" #include "blackbirdBaseVisitor.h" #include "BlackbirdProgram.h" namespace blackbird { template bool is_type(const SrcType* src) { return dynamic_cast(src) != nullptr; } class Visitor : public blackbirdBaseVisitor { private: std::string var_type; std::string var_name; public: std::unordered_map> complex_vars; std::unordered_map float_vars; std::unordered_map int_vars; std::unordered_map str_vars; std::unordered_map bool_vars; std::unordered_map complexmat_vars; std::unordered_map floatmat_vars; std::unordered_map intmat_vars; Program* program; template O* _create_operation(blackbirdParser::ArgumentsContext *ctx, intvec modes); antlrcpp::Any visitNumber(blackbirdParser::NumberContext *ctx); antlrcpp::Any visitExpressionvar(blackbirdParser::ExpressionvarContext *ctx); antlrcpp::Any visitArrayvar(blackbirdParser::ArrayvarContext *ctx); antlrcpp::Any visitArrayrow(blackbirdParser::ArrayrowContext*); antlrcpp::Any visitStatement(blackbirdParser::StatementContext *ctx); antlrcpp::Any visitProgram(blackbirdParser::ProgramContext *ctx); antlrcpp::Any visitStart(blackbirdParser::StartContext *ctx); }; Program* parse(std::ifstream &stream); Program* parse(std::string &s_input); }