summaryrefslogtreecommitdiff
path: root/includes/parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'includes/parser.h')
-rw-r--r--includes/parser.h370
1 files changed, 370 insertions, 0 deletions
diff --git a/includes/parser.h b/includes/parser.h
new file mode 100644
index 0000000..ae28fee
--- /dev/null
+++ b/includes/parser.h
@@ -0,0 +1,370 @@
+#pragma once
+
+#include "cw_common.h"
+#include "pref_structs.h"
+#include "option_system.h"
+
+enum {
+ PRAGMA_FLAGS_0,
+ PRAGMA_FLAGS_1
+};
+enum {
+ PR_UNSET = 0, // this is the only one we know the name of (from asserts)
+ PR_ON = 1,
+ PR_OFF = 2,
+ PR_AUTO = 3,
+ PR_RESET = 4
+};
+
+typedef struct {
+ void *value;
+ const char *pragma;
+ int flags;
+} Pragma; // assumed name
+
+enum {
+ CLPStr0 = 0,
+ CLPStr1 = 1,
+ CLPStr2 = 2,
+ CLPStr3 = 3,
+ CLPStr4 = 4,
+ CLPStr5 = 5,
+ CLPStr6 = 6,
+ CLPStr7 = 7,
+ CLPStr8 = 8,
+ CLPStr9 = 9,
+ CLPStr10 = 10,
+ CLPStr11 = 11,
+ CLPStr12 = 12,
+ CLPStr13 = 13,
+ CLPStr14 = 14,
+ CLPStr15 = 15,
+ CLPStr16 = 16,
+ CLPStr17 = 17,
+ CLPStr18 = 18,
+ CLPStr19_UnknownOptionX = 19,
+ CLPStr20_UnknownOptionX_ExpectedOneOfX = 20,
+ CLPStr21_OptionObsolete = 21,
+ CLPStr22_OptionObsoleteWithHelp = 22,
+ CLPStr23_OptionXSubstitutedWithX = 23,
+ CLPStr24_OptionDeprecated = 24,
+ CLPStr25_OptionDeprecatedWithHelp = 25,
+ CLPStr26_OptionIgnored = 26,
+ CLPStr27_OptionIgnoredWithText = 27,
+ CLPStr28_WarningText = 28,
+ CLPStr29_OptionHasNoEffect = 29,
+ CLPStr30_OptionShouldNotBeSpecifiedMultipleTimes = 30,
+ CLPStr31_OptionOverridesEffect = 31,
+ CLPStr32_OptionOverridesEffectWithHelp = 32,
+ CLPStr33_NoDefaultHandlerSetUpForX_Ignoring = 33,
+ CLPStr34_ArgumentsExpected = 34,
+ CLPStr35_TokenXNotExpected = 35,
+ CLPStr36_UnexpectedAdditionalArgumentX = 36,
+ CLPStr37 = 37,
+ CLPStr38_NoHelpAvailableForOptionX = 38,
+ CLPStr39 = 39,
+ CLPStr40 = 40,
+ CLPStr41 = 41,
+ CLPStr42 = 42,
+ CLPStr43 = 43,
+ CLPStr44 = 44,
+ CLPStr45 = 45,
+ CLPStr46 = 46,
+ CLPStr47 = 47,
+ CLPStr48 = 48,
+ CLPStr49 = 49,
+ CLPStr50 = 50,
+ CLPStr51 = 51,
+ CLPStr52 = 52,
+ CLPStr53 = 53,
+ CLPStr54 = 54,
+ CLPStr55 = 55,
+ CLPStr56 = 56,
+ CLPStr57 = 57,
+ CLPStr58 = 58,
+ CLPStr59 = 59,
+ CLPStr60 = 60,
+ CLPStr61 = 61,
+ CLPStr62 = 62,
+ CLPStr63 = 63,
+ CLPStr64 = 64,
+ CLPStr65 = 65,
+ CLPStr66 = 66,
+ CLPStr67 = 67,
+ CLPStr68 = 68,
+ CLPStr69 = 69,
+ CLPStr70 = 70,
+ CLPStr71 = 71,
+ CLPStr72 = 72,
+ CLPStr73 = 73,
+ CLPStr74 = 74,
+ CLPStr75 = 75,
+ CLPStr76 = 76,
+ CLPStr77 = 77,
+ CLPStr78 = 78
+};
+
+// State
+
+typedef struct {
+ char *name;
+ void *ptr;
+ SInt32 size;
+} PrefDataPanel; // assumed name
+
+typedef struct {
+ OSType TYPE;
+ OSType LANG;
+ OSType CPU;
+ OSType OS;
+ int numPrefPanels;
+ char **prefPanels;
+ char *toolInfo;
+ char *copyright;
+ int numOptionLists;
+ OptionList **optionLists;
+ int numPrefDataPanels;
+ PrefDataPanel *prefDataPanels;
+ int (*PreParse)();
+ int (*MidParse)();
+ int (*PostParse)();
+} ParserTool; // assumed name
+
+typedef struct {
+ struct CWPluginPrivateContext *context;
+ char helpKey[64];
+ SInt32 helpFlags;
+ UInt16 ioCols;
+ UInt16 ioRows;
+ CWCommandLineArgs *args;
+ const ToolVersionInfo *toolVersion;
+ int numPlugins;
+ const CLPluginInfo *plugins;
+ int numPanels;
+ const char **panelNames;
+ OSType cpu;
+ OSType os;
+ char lastoutputname[256];
+ SInt32 currentSegment;
+ SInt32 currentOverlayGroup;
+ SInt32 currentOverlay;
+ int possibleFiles;
+ int userSpecifiedFiles;
+ int unusedFiles;
+ Boolean hadAnyOutput;
+ Boolean hadErrors;
+ Boolean showHelp;
+ Boolean underIDE;
+ Boolean alwaysUsePaths;
+ Boolean noOptions;
+ Boolean printedVersion;
+ Boolean passingArgs;
+ Boolean disToFile;
+ Boolean ppToFile;
+ Boolean initBefore;
+ Boolean weakImport;
+ Boolean mergeIntoOutput;
+ Boolean success;
+ Boolean ignoreUnknown;
+ UInt8 unused[2];
+} ParseOptsType; // assumed name
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/********************************/
+/* IO.c */
+extern void ShowTextHandle(const char *description, Handle text);
+extern void ShowVersion(Boolean decorate);
+
+/********************************/
+/* OptimizerHelpers.c */
+extern Pragma irPragmas[];
+
+extern int SetPragmaOptimizationsToUnspecified(const char *opt, void *, const char *, int);
+extern int SetOptFlags(const char *opt, void *str, const char *, int flags);
+extern int DisplayOptimizationOptions();
+
+/********************************/
+/* ParserErrors.c */
+extern void CLPReportError_V(const char *format, va_list ap);
+extern void CLPReportWarning_V(const char *format, va_list ap);
+extern void CLPReport_V(const char *format, va_list ap);
+extern void CLPStatus_V(const char *format, va_list ap);
+extern void CLPAlert_V(const char *format, va_list ap);
+extern void CLPOSAlert_V(const char *format, SInt32 err, va_list ap);
+extern char *CLPGetErrorString(SInt16 errid, char *buffer);
+extern void CLPReportError(SInt16 errid, ...);
+extern void CLPReportWarning(SInt16 errid, ...);
+extern void CLPReport(SInt16 errid, ...);
+extern void CLPAlert(SInt16 errid, ...);
+extern void CLPOSAlert(SInt16 errid, SInt16 err, ...);
+extern void CLPProgress(SInt16 errid, ...);
+extern void CLPStatus(SInt16 errid, ...);
+extern void CLPFatalError(const char *format, ...);
+
+/********************************/
+/* ParserFace.c */
+extern const char *failedCallback;
+extern jmp_buf exit_plugin;
+extern ParseOptsType parseopts;
+
+extern Handle Parser_FindPrefPanel(const char *name);
+extern SInt32 Parser_StorePanels(struct CWPluginPrivateContext *context);
+extern CWPLUGIN_ENTRY (CWParser_GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize);
+extern CWPLUGIN_ENTRY (CWParser_GetDropInName)(const char **dropinName);
+extern CWPLUGIN_ENTRY (CWParser_GetDisplayName)(const char **displayName);
+extern CWPLUGIN_ENTRY (CWParser_GetPanelList)(const CWPanelList **panelList);
+extern CWPLUGIN_ENTRY (CWParser_GetTargetList)(const CWTargetList **targetList);
+extern CWPLUGIN_ENTRY (CWParser_GetVersionInfo)(const VersionInfo **versioninfo);
+extern CWPLUGIN_ENTRY (Parser_SupportsPlugin)(const struct CLPluginInfo *pluginfo, OSType cpu, OSType os, Boolean *isSupported);
+extern CWPLUGIN_ENTRY (Parser_SupportsPanels)(int numPanels, const char **panelNames, Boolean *isSupported);
+extern CWPLUGIN_ENTRY (parser_main)(struct CWPluginPrivateContext *context);
+
+/********************************/
+/* ParserGlue-mach-ppc-c.c */
+extern PCmdLine pCmdLine;
+extern PCmdLineCompiler pCmdLineCompiler;
+extern PCmdLineLinker pCmdLineLinker;
+extern PFrontEndC pFrontEndC;
+extern PWarningC pWarningC;
+extern PGlobalOptimizer pGlobalOptimizer;
+extern PBackEnd pBackEnd;
+extern PDisassembler pDisassembler;
+extern PMachOLinker pLinker;
+extern PMachOProject pMachOProject;
+extern PCLTExtras pCLTExtras;
+
+/********************************/
+/* ParserHelpers.c */
+extern SInt16 lastStage;
+extern Boolean dashIMinusMovesPaths;
+extern Boolean usedDashIMinus;
+extern Boolean namingSysPaths;
+
+extern int FindFileInPath(const char *filename, OSSpec *fss);
+extern char *GetEnvVar(const char *name, Boolean warn, const char **match);
+extern int Opt_AddAccessPath(const char *opt, void *var, const char *arg, int flags);
+extern int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg, int flags);
+extern int Opt_AddFramework(const char *opt, void *var, const char *arg, int flags);
+extern void ListParseMessage(void (*errprint)(const char *, va_list), const char *envvar, SInt16 id, ...);
+extern int AddAccessPathList(const char *list, char sep1, char sep2, int source, char *text, Boolean system, SInt32 position, Boolean recursive);
+extern int Opt_FindAndAddFile(const char *opt, void *var, const char *arg, int flags);
+extern int Opt_FindAndAddFileRef(const char *opt, void *var, const char *arg);
+extern int Opt_AddUnixLibraryFile(const char *opt, void *var, const char *arg);
+extern int AddFileList(const char *list, char sep1, char sep2, int source, char *text, SInt32 position);
+extern int IsFileInOutputDirectory(const OSSpec *file);
+extern void GetCFileNameInOutputDirectory(const char *input, char *name, int maxlen);
+extern void GetPFileNameInOutputDirectory(const char *input, unsigned char *name, int len);
+extern void AddStringLenToHandle(Handle *h, const char *str, int len);
+extern void AddStringToHandle(Handle *h, const char *str);
+extern int Opt_PrintVersion(const char *opt, void *var, const char *arg, int flags);
+extern void GetFirstSourceFilenameBase(char *buffer, char *defaul);
+extern int Opt_SavePrefs(const char *opt, void *var, const char *arg, int flags);
+extern int ParseNumber(const char *arg, Boolean emit_error, SInt32 *ret, const char **endptr);
+extern int Opt_MaybeMoveAccessPaths(const char *opt, void *var, const char *arg, int flags);
+
+/********************************/
+/* ParserHelpers-cc.c */
+extern Handle definesHandle;
+
+extern int Opt_AddStringToDefines(const char *opt, void *str, const char *param, int flags);
+extern int Opt_DefineSymbol(const char *var, const char *value);
+extern int Opt_UndefineSymbol(const char *opt, void *, const char *arg, int flags);
+extern int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename, int flags);
+extern int Opt_PragmaTrueFalse(const char *, void *flag, const char *, int flags);
+extern int Opt_PragmaFalseTrue(const char *, void *flag, const char *, int flags);
+extern int Opt_PragmaOnOff(const char *, void *flag, const char *arg);
+extern int Opt_PragmaOffOn(const char *, void *flag, const char *arg);
+extern int SetupPragmas(const Pragma *pragmas);
+
+/********************************/
+/* Projects.c */
+extern int GetFileCount();
+extern void SetFileOutputName(SInt32 position, SInt16 which, char *outfilename);
+extern int AddFileToProject(OSSpec *oss, SInt16 which, char *outfilename, Boolean exists, SInt32 position);
+extern Boolean GetFileInfo(SInt32 position, OSSpec *spec, char *plugin);
+extern int AddAccessPath(OSPathSpec *oss, SInt16 type, SInt32 position, Boolean recursive);
+extern int MoveSystemPathsIntoUserList();
+extern void AddVirtualFile(const char *filename, Handle *text);
+extern void GetOutputFileDirectory(OSPathSpec *dir);
+extern void SetOutputFileDirectory(OSPathSpec *dir);
+extern void AddOverlayGroup(const char *name, CWAddr64 *addr, SInt32 *groupnum, SInt32 *overlaynum);
+extern void AddOverlay(SInt32 groupnum, const char *name, SInt32 *overlaynum);
+extern void AddSegment(const char *name, SInt16 attrs, SInt32 *segmentnum);
+extern void ChangeSegment(SInt32 segmentnum, const char *name, SInt16 attrs);
+extern int GetSegment(SInt32 segmentnum, char *name, SInt16 *attrs);
+
+/********************************/
+/* TargetOptimizer-ppc-mach.c */
+extern char schedule_ppc_default;
+
+extern int TargetSetOptFlags(short val, Boolean set);
+extern void TargetDisplayOptimizationOptions(Handle txt);
+extern void TargetSetPragmaOptimizationsToUnspecified();
+
+/********************************/
+/* TargetWarningHelpers-ppc-cc.c */
+extern Pragma warningPragmas[];
+
+extern int TargetSetWarningFlags(short val, Boolean set);
+extern void TargetDisplayWarningOptions(Handle txt);
+
+/********************************/
+/* Targets.c */
+extern ParserTool *pTool;
+
+extern int SetParserToolInfo(ParserTool *tool);
+extern Boolean ParserToolMatchesPlugin(OSType type, OSType lang, OSType cpu, OSType os);
+extern Boolean ParserToolHandlesPanels(int numPanels, const char **panelNames);
+extern Boolean SetupParserToolOptions();
+
+/********************************/
+/* ToolHelpers.c */
+enum {
+ OutputOrdering0 = 0,
+ OutputOrdering1 = 1,
+ OutputOrdering2 = 2
+};
+extern char linkerOutputFilename[256];
+extern Boolean setLinkerOutputFilename;
+extern Boolean setOutputDirectory;
+extern SInt16 outputOrdering;
+
+extern int Opt_HandleOutputName(const char *opt, void *, const char *filename, int flags);
+extern int ValidateToolState(Boolean mustHaveFiles);
+extern void ToolReportMessage(SInt16 errid, SInt16 type, va_list va);
+extern void ToolReportWarning(SInt16 id, ...);
+extern void ToolReportError(SInt16 id, ...);
+extern void ToolReportOSError(SInt16 id, int err, ...);
+extern void ToolReportInfo(SInt16 id, ...);
+extern int Opt_DoNotLink(const char *opt, void *var, const char *arg);
+extern int Opt_IncreaseVerbosity(const char *opt, void *var, const char *arg, int flags);
+extern int Opt_SetStage(const char *opt, void *str, const char *arg, int flags);
+extern int Opt_RedirectStream(const char *opt, void *file, const char *filename);
+
+/********************************/
+/* ToolHelpers-cc.c */
+extern int Opt_DummyLinkerRoutine(const char *opt, void *, const char *, int);
+extern int Opt_DummyLinkerSettingRoutine(const char *var, const char *val);
+extern void FinishCompilerTool();
+
+/********************************/
+/* Utils.c */
+extern int my_tolower(char c);
+extern int my_isdigit(char c);
+extern int my_isalpha(char c);
+extern int my_isalnum(char c);
+extern int my_isxdigit(char c);
+extern char *Utils_SpellList(char *list, char *buffer, char opts);
+extern int Utils_CompareOptionString(const char *a, const char *b, int cased, int sticky);
+
+/********************************/
+/* WarningHelpers.c */
+extern int SetWarningFlags(const char *opt, void *str, const char *, int flags);
+extern int DisplayWarningOptions();
+
+#ifdef __cplusplus
+extern "C" }
+#endif