Browse Source

Update parser example to latest API.

pull/1751/head
Joao Matos 2 years ago
parent
commit
8c1fa18ccb
  1. 11
      examples/Parser/Parser.cs

11
examples/Parser/Parser.cs

@ -23,12 +23,12 @@ namespace CppSharp
ParseSourceFile(file); ParseSourceFile(file);
} }
public static bool ParseSourceFile(string file) private static bool ParseSourceFile(string file)
{ {
// Lets setup the options for parsing the file. // Lets setup the options for parsing the file.
var parserOptions = new ParserOptions var parserOptions = new ParserOptions
{ {
LanguageVersion = LanguageVersion.CPP11, LanguageVersion = LanguageVersion.CPP20_GNU,
// Verbose here will make sure the parser outputs some extra debugging // Verbose here will make sure the parser outputs some extra debugging
// information regarding include directories, which can be helpful when // information regarding include directories, which can be helpful when
@ -37,13 +37,10 @@ namespace CppSharp
}; };
// This will setup the necessary system include paths and arguments for parsing. // This will setup the necessary system include paths and arguments for parsing.
// It will probe into the registry (on Windows) and filesystem to find the paths parserOptions.Setup(Platform.Host);
// of the system toolchains and necessary include directories.
parserOptions.Setup();
// We create the Clang parser and parse the source code. // We create the Clang parser and parse the source code.
var parser = new ClangParser(); var parserResult = ClangParser.ParseSourceFile(file, parserOptions);
var parserResult = parser.ParseSourceFile(file, parserOptions);
// If there was some kind of error parsing, then lets print some diagnostics. // If there was some kind of error parsing, then lets print some diagnostics.
if (parserResult.Kind != ParserResultKind.Success) if (parserResult.Kind != ParserResultKind.Success)

Loading…
Cancel
Save