From f59978893fed309ff19bacd787398c4bab4aa7c8 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 4 May 2020 13:46:24 -0400 Subject: C++ Extractor (#1337) * WIP: Doing texing using slangs lexer for cpp-extractor * Node tree for C++ extraction. * Bug fixing. Add dump of hierarchy. * First pass at extracting fields. * Parse template types. * Use diagnostics defs for C++ extractor. * Simplify Diagnostic Defs. * Remove the brace stack. * Added IdentifierLookup. * Add handling for >> style template close. * Improved identifier handling/keywords. * Added ability to check if reader is at cursor position. * Handling of an unspecified root type. * Parsing code comments. Tidy up some parsing - to use advanceIf functions more. * Improve path handling. * Fixes around changes to Path interface. * Working Range, Type and Scope header. * Extract the middle part of marker and put in output. Gives more flexibility at macro injection, and in class definitions. * Split DERIVED types into it's own macro, to provide way to generate for derived types. * Fix clang/g++ compile issue. * Tabs -> spaces. * Fix small bug in getFileNameWithoutExt * Small improvement around naming. Co-authored-by: Tim Foley --- .../slang-cpp-extractor-diagnostic-defs.h | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tools/slang-cpp-extractor/slang-cpp-extractor-diagnostic-defs.h (limited to 'tools/slang-cpp-extractor/slang-cpp-extractor-diagnostic-defs.h') diff --git a/tools/slang-cpp-extractor/slang-cpp-extractor-diagnostic-defs.h b/tools/slang-cpp-extractor/slang-cpp-extractor-diagnostic-defs.h new file mode 100644 index 000000000..715f74c23 --- /dev/null +++ b/tools/slang-cpp-extractor/slang-cpp-extractor-diagnostic-defs.h @@ -0,0 +1,45 @@ +// + +// The file is meant to be included multiple times, to produce different +// pieces of declaration/definition code related to diagnostic messages +// +// Each diagnostic is declared here with: +// +// DIAGNOSTIC(id, severity, name, messageFormat) +// +// Where `id` is the unique diagnostic ID, `severity` is the default +// severity (from the `Severity` enum), `name` is a name used to refer +// to this diagnostic from code, and `messageFormat` is the default +// (non-localized) message for the diagnostic, with placeholders +// for any arguments. + +#ifndef DIAGNOSTIC +#error Need to #define DIAGNOSTIC(...) before including "slang-cpp-extractor-diagnostics-defs.h" +#define DIAGNOSTIC(id, severity, name, messageFormat) /* */ +#endif + +DIAGNOSTIC(-1, Note, seeDeclarationOf, "see declaration of '$0'") +DIAGNOSTIC(-1, Note, seeOpenBrace, "see open brace") + +DIAGNOSTIC(1, Error, cannotOpenFile, "cannot open file '$0'.") + +// Parsing errors +DIAGNOSTIC(100000, Error, expectingToken, "Expecting token $0") +DIAGNOSTIC(100001, Error, typeAlreadyDeclared, "Type '$0' already declared") +DIAGNOSTIC(100002, Error, scopeNotClosed, "Scope not closed") +DIAGNOSTIC(100003, Error, typeNameDoesntMatch, "Type name doesn't match $0") +DIAGNOSTIC(100004, Error, didntFindMatchingBrace, "Didn't find brace matching $0") +DIAGNOSTIC(100005, Error, braceOpenAtEndOfFile, "Brace open at file end") +DIAGNOSTIC(100006, Error, unexpectedTemplateClose, "Unexpected template close") +DIAGNOSTIC(100007, Error, superTypeNotFound, "Super type not found for $0") +DIAGNOSTIC(100008, Error, superTypeNotAType, "Named super type is not a type $0") + +// Command line errors 100100 + +DIAGNOSTIC(100101, Error, optionAlreadyDefined, "Option '$0' is already defined '$1'") +DIAGNOSTIC(100102, Error, requireValueAfterOption, "Require a value after $0 option") +DIAGNOSTIC(100103, Error, unknownOption, "Unknown option '$0'") +DIAGNOSTIC(100104, Error, noInputPathsSpecified, "No input paths specified") +DIAGNOSTIC(100105, Error, noOutputPathSpecified, "No -o output path specified") + +#undef DIAGNOSTIC -- cgit v1.2.3