Files
carbon-lang/executable_semantics/main.cpp
T
fd96e0e630 add command-line flag to enable/disable tracing output (#325)
* add command-line flag to enable/disable tracing output

* adding missing exit for pattern variable in wrong context and a test case for it (#324)

* Update executable_semantics/interpreter/interpreter.cpp

comment on separate line as code

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>

* fix interpreter's handling of optional else of if statement (#323)

* Update pattern_variable_fail.golden due to error (#334)

* Use llvm's CommandLine for parsing (#332)

* GitHub testing action (#331)

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>

* add copyright

* Create a Dictionary abstraction over the raw Cons list. (#327)

* Create a Dictionary abstraction over the raw Cons list.

* renamed Cons and some methods of Dictionary, various other cleanup

* Update executable_semantics/tracing_flag.cpp

added namespace comment

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>

* added a comment to cpp file

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
Co-authored-by: Dave Abrahams <dabrahams@google.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-03-03 16:01:59 -05:00

39 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 "executable_semantics/tracing_flag.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;
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;
}
}
if (quiet_option) {
Carbon::tracing_output = false;
}
return yyparse();
}