19#ifndef FRONTENDS_COMMON_PARSER_OPTIONS_H_ 
   20#define FRONTENDS_COMMON_PARSER_OPTIONS_H_ 
   26#include "ir/configuration.h" 
   27#include "ir/pass_manager.h" 
   28#include "lib/compile_context.h" 
   29#include "lib/cstring.h" 
   30#include "lib/options.h" 
   34extern const char *p4includePath;
 
   35extern const char *p4_14includePath;
 
   42    std::set<cstring> disabledAnnotations;
 
   45    mutable size_t dump_uid = 0;
 
   49    void dumpPass(
const char *manager, 
unsigned seq, 
const char *pass, 
const IR::Node *node) 
const;
 
   52    explicit ParserOptions(std::string_view defaultMessage = 
"Parse a P4 program");
 
   54    std::vector<const char *> *
process(
int argc, 
char *
const argv[]) 
override;
 
   55    enum class FrontendVersion { P4_14, P4_16 };
 
   69    std::filesystem::path 
file;
 
   87    std::optional<ParserOptions::PreprocessorResult> 
preprocess() 
const;
 
 
  167template <
typename OptionsType>
 
  178    template <
typename OptionsDerivedType>
 
  180        optionsInstance = context.
options();
 
  183    template <
typename OptionsDerivedType>
 
  185        optionsInstance = context.
options();
 
  189    OptionsType &
options()
 override { 
return optionsInstance; }
 
  193    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:256
 
void setDefaultInfoDiagnosticAction(DiagnosticAction action)
set the default diagnostic action for calls to info().
Definition error_reporter.h:264
 
void setDiagnosticAction(std::string_view diagnostic, DiagnosticAction action)
Set the action to take for the given diagnostic.
Definition error_reporter.h:248
 
DiagnosticAction getDiagnosticAction(cstring diagnostic, DiagnosticAction defaultAction)
Definition error_reporter.h:234
 
DiagnosticAction getDefaultInfoDiagnosticAction()
Definition error_reporter.h:261
 
DiagnosticAction getDefaultWarningDiagnosticAction()
Definition error_reporter.h:253
 
Definition ir/configuration.h:22
 
Definition parser_options.h:106
 
DiagnosticAction getDiagnosticAction(cstring diagnostic, DiagnosticAction defaultAction) final
Definition parser_options.h:144
 
virtual ParserOptions & options()=0
 
DiagnosticAction getDefaultInfoDiagnosticAction() final
Definition parser_options.h:123
 
void setDefaultWarningDiagnosticAction(DiagnosticAction action)
set the default diagnostic action for calls to warning().
Definition parser_options.h:138
 
void setDefaultInfoDiagnosticAction(DiagnosticAction action)
set the default diagnostic action for calls to info().
Definition parser_options.h:128
 
static P4CContext & get()
Definition parser_options.cpp:530
 
void setDiagnosticAction(std::string_view diagnostic, DiagnosticAction action)
Set the action to take for the given diagnostic.
Definition parser_options.h:149
 
virtual bool isRecognizedDiagnostic(cstring diagnostic)
Definition parser_options.cpp:537
 
DiagnosticAction getDefaultWarningDiagnosticAction() final
Definition parser_options.h:133
 
static const P4CConfiguration & getConfig()
Definition parser_options.cpp:532
 
virtual const P4CConfiguration & getConfigImpl()
Definition parser_options.cpp:543
 
Definition parser_options.h:168
 
OptionsType & options() override
Definition parser_options.h:189
 
static P4CContextWithOptions & get()
Definition parser_options.h:172
 
Definition parser_options.h:40
 
std::vector< cstring > top4
substrings matched against pass names
Definition parser_options.h:77
 
DebugHook getDebugHook() const
Definition parser_options.cpp:524
 
std::optional< ParserOptions::PreprocessorResult > preprocess() const
Returns the output of the preprocessor.
Definition parser_options.cpp:420
 
FrontendVersion langVersion
Which language to compile.
Definition parser_options.h:65
 
cstring preprocessor_options
options to pass to preprocessor
Definition parser_options.h:67
 
bool isAnnotationDisabled(const IR::Annotation *a) const
Check whether this particular annotation was disabled.
Definition parser_options.cpp:516
 
bool optimizeParserInlining
If false, optimization of callee parsers (subparsers) inlining is disabled.
Definition parser_options.h:81
 
void setInputFile()
Expect that the only remaining argument is the input file.
Definition parser_options.cpp:339
 
std::filesystem::path file
file to compile (- for stdin)
Definition parser_options.h:69
 
std::filesystem::path dumpFolder
debugging dumps of programs written in this folder
Definition parser_options.h:79
 
bool searchForIncludePath(const char *&includePathOut, std::vector< cstring > relativePaths, const char *)
Definition parser_options.cpp:368
 
static void closeFile(FILE *file)
Tries to close the input stream associated with the result.
Definition parser_options.cpp:49
 
std::vector< const char * > * process(int argc, char *const argv[]) override
Definition parser_options.cpp:393
 
bool doNotCompile
if true preprocess only
Definition parser_options.h:71
 
void dumpPass(const char *manager, unsigned seq, const char *pass, const IR::Node *node) const
Function that is returned by getDebugHook.
Definition parser_options.cpp:471
 
const char * getIncludePath() const override
Return target specific include path.
Definition parser_options.cpp:407
 
bool noIncludes
Definition parser_options.h:101
 
std::unique_ptr< FILE, decltype(&closeFile)> PreprocessorResult
Records the result of the preprocessor.
Definition parser_options.h:60
 
cstring compilerVersion
Compiler version.
Definition parser_options.h:73
 
cstring exe_name
Name of executable that is being run.
Definition parser_options.h:63
 
bool isv1() const
True if we are compiling a P4 v1.0 or v1.1 program.
Definition parser_options.cpp:469
 
bool doNotPreprocess
if true skip preprocess
Definition parser_options.h:75
 
Definition lib/options.h:34
 
static CompileContextType & top()
Definition compile_context.h:46