mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 06:30:09 +01:00
36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <iostream>
|
|
|
|
#include "executable_semantics/syntax_helpers.h"
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
extern FILE* yyin;
|
|
extern auto yyparse() -> int; // NOLINT(readability-identifier-naming)
|
|
|
|
int main(int argc, char* argv[]) {
|
|
// yydebug = 1;
|
|
|
|
using llvm::cl::desc;
|
|
using llvm::cl::opt;
|
|
// TODO: Add with related support.
|
|
// opt<bool> quiet_option("quiet", desc("Disable tracing"));
|
|
opt<std::string> input_filename(llvm::cl::Positional, desc("<input file>"));
|
|
llvm::cl::ParseCommandLineOptions(argc, argv);
|
|
|
|
if (input_filename.getNumOccurrences() > 0) {
|
|
Carbon::input_filename = input_filename.c_str();
|
|
yyin = fopen(input_filename.c_str(), "r");
|
|
if (yyin == nullptr) {
|
|
std::cerr << "Error opening '" << input_filename
|
|
<< "': " << strerror(errno) << std::endl;
|
|
return 1;
|
|
}
|
|
}
|
|
return yyparse();
|
|
}
|