• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PANDA_ASSEMBLER_PANDASM_H
17 #define PANDA_ASSEMBLER_PANDASM_H
18 
19 #include "utils/pandargs.h"
20 
21 namespace ark::pandasm {
22 
23 void PrintError(const ark::pandasm::Error &e, const std::string &msg);
24 
25 void PrintErrors(const ark::pandasm::ErrorList &warnings, const std::string &msg);
26 
27 bool PrepareArgs(ark::PandArgParser &paParser, const ark::PandArg<std::string> &inputFile,
28                  const ark::PandArg<std::string> &outputFile, const ark::PandArg<std::string> &logFile,
29                  const ark::PandArg<bool> &help, const ark::PandArg<bool> &verbose, std::ifstream &inputfile, int argc,
30                  char **argv);
31 
32 bool Tokenize(ark::pandasm::Lexer &lexer, std::vector<std::vector<ark::pandasm::Token>> &tokens,
33               std::ifstream &inputfile);
34 
35 bool ParseProgram(ark::pandasm::Parser &parser, std::vector<std::vector<ark::pandasm::Token>> &tokens,
36                   const ark::PandArg<std::string> &inputFile,
37                   ark::Expected<ark::pandasm::Program, ark::pandasm::Error> &res);
38 
39 bool DumpProgramInJson(ark::pandasm::Program &program, const ark::PandArg<std::string> &scopesFile);
40 
41 bool EmitProgramInBinary(ark::pandasm::Program &program, ark::PandArgParser &paParser,
42                          const ark::PandArg<std::string> &outputFile, ark::PandArg<bool> &optimize,
43                          ark::PandArg<bool> &sizeStat);
44 
45 bool BuildFiles(ark::pandasm::Program &program, ark::PandArgParser &paParser,
46                 const ark::PandArg<std::string> &outputFile, ark::PandArg<bool> &optimize, ark::PandArg<bool> &sizeStat,
47                 ark::PandArg<std::string> &scopesFile);
48 
49 }  // namespace ark::pandasm
50 
51 #endif  // PANDA_ASSEMBLER_PANDASM_H
52