aboutsummaryrefslogtreecommitdiff
path: root/src/headless/main.cpp
blob: 94d6b8d648542c8cff250197ac6121cf013a4437 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

#include <openvic-dataloader/v2script/Parser.hpp>

int main(int argc, char** argv) {
   if (argc < 2) {
      std::fprintf(stderr, "usage: %s <filename>", argv[0]);
      return 1;
   }

   auto parser = ovdl::v2script::Parser::from_file(argv[1]);
   if (parser.has_error()) {
      return 1;
   }

   parser.simple_parse();
   if (parser.has_error()) {
      return 2;
   }

   if (parser.has_warning()) {
      for (auto& warning : parser.get_warnings()) {
         std::cerr << "Warning: " << warning.message << std::endl;
      }
   }

   std::cout << parser.get_file_node() << std::endl;

   return 0;
}