19#ifndef FRONTENDS_COMMON_PARSER_OPTIONS_H_
20#define FRONTENDS_COMMON_PARSER_OPTIONS_H_
23#include <unordered_map>
25#include "ir/configuration.h"
26#include "ir/pass_manager.h"
27#include "lib/compile_context.h"
28#include "lib/cstring.h"
29#include "lib/options.h"
33extern const char *p4includePath;
34extern const char *p4_14includePath;
40 bool close_input =
false;
41 static const char *defaultMessage;
44 std::set<cstring> disabledAnnotations;
47 mutable size_t dump_uid = 0;
51 void dumpPass(
const char *manager,
unsigned seq,
const char *pass,
const IR::Node *node)
const;
53 virtual void validateOptions()
const;
57 std::vector<const char *> *
process(
int argc,
char *
const argv[])
override;
58 enum class FrontendVersion { P4_14, P4_16 };
62 FrontendVersion langVersion = FrontendVersion::P4_16;
64 cstring preprocessor_options =
"";
68 bool doNotCompile =
false;
72 bool doNotPreprocess =
false;
74 std::vector<cstring> top4;
78 bool optimizeParserInlining =
false;
82 const char *getIncludePath()
override;
86 void closePreprocessedInput(FILE *input)
const;
91 DebugHook getDebugHook()
const;
93 bool isAnnotationDisabled(
const IR::Annotation *a)
const;
96 bool searchForIncludePath(
const char *&includePathOut, std::vector<cstring> relativePaths,
114 static const P4CConfiguration &
getConfig();
166template <
typename OptionsType>
172 return CompileContextStack::top<P4CContextWithOptions>();
177 template <
typename OptionsDerivedType>
179 optionsInstance = context.
options();
182 template <
typename OptionsDerivedType>
184 optionsInstance = context.
options();
188 OptionsType &
options()
override {
return optionsInstance; }
192 OptionsType optionsInstance;
Definition compile_context.h:83
virtual ErrorReporter & errorReporter()
Definition compile_context.cpp:63
void setDefaultWarningDiagnosticAction(DiagnosticAction action)
set the default diagnostic action for calls to warning().
Definition error_reporter.h:262
void setDefaultInfoDiagnosticAction(DiagnosticAction action)
set the default diagnostic action for calls to ::info().
Definition error_reporter.h:270
DiagnosticAction getDiagnosticAction(cstring diagnostic, DiagnosticAction defaultAction)
Definition error_reporter.h:240
DiagnosticAction getDefaultInfoDiagnosticAction()
Definition error_reporter.h:267
void setDiagnosticAction(cstring diagnostic, DiagnosticAction action)
Set the action to take for the given diagnostic.
Definition error_reporter.h:254
DiagnosticAction getDefaultWarningDiagnosticAction()
Definition error_reporter.h:259
Definition parser_options.h:105
DiagnosticAction getDiagnosticAction(cstring diagnostic, DiagnosticAction defaultAction) final
Definition parser_options.h:143
virtual ParserOptions & options()=0
DiagnosticAction getDefaultInfoDiagnosticAction() final
Definition parser_options.h:122
void setDefaultWarningDiagnosticAction(DiagnosticAction action)
set the default diagnostic action for calls to warning().
Definition parser_options.h:137
void setDiagnosticAction(cstring diagnostic, DiagnosticAction action)
Set the action to take for the given diagnostic.
Definition parser_options.h:148
void setDefaultInfoDiagnosticAction(DiagnosticAction action)
set the default diagnostic action for calls to ::info().
Definition parser_options.h:127
static P4CContext & get()
Definition parser_options.cpp:522
virtual bool isRecognizedDiagnostic(cstring diagnostic)
Definition parser_options.cpp:529
DiagnosticAction getDefaultWarningDiagnosticAction() final
Definition parser_options.h:132
static const P4CConfiguration & getConfig()
Definition parser_options.cpp:524
virtual const P4CConfiguration & getConfigImpl()
Definition parser_options.cpp:536
Definition parser_options.h:167
OptionsType & options() override
Definition parser_options.h:188
static P4CContextWithOptions & get()
Definition parser_options.h:171
Definition parser_options.h:39
std::vector< const char * > * process(int argc, char *const argv[]) override
Definition parser_options.cpp:375
bool noIncludes
Definition parser_options.h:100