main.cpp 716 B

123456789101112131415161718192021222324252627
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include <cstdio>
  5. #include <cstring>
  6. #include <iostream>
  7. #include "executable_semantics/syntax_helpers.h"
  8. extern FILE* yyin;
  9. extern auto yyparse() -> int; // NOLINT(readability-identifier-naming)
  10. int main(int argc, char* argv[]) {
  11. // yydebug = 1;
  12. if (argc > 1) {
  13. Carbon::input_filename = argv[1];
  14. yyin = fopen(argv[1], "r");
  15. if (yyin == nullptr) {
  16. std::cerr << "Error opening '" << argv[1] << "': " << strerror(errno)
  17. << std::endl;
  18. return 1;
  19. }
  20. }
  21. return yyparse();
  22. }