|
|
|
@ -1,22 +1,22 @@
@@ -1,22 +1,22 @@
|
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
|
|
namespace Cxxi |
|
|
|
|
{ |
|
|
|
|
public class Parser |
|
|
|
|
{ |
|
|
|
|
public Library Library { get; private set; } |
|
|
|
|
private readonly DriverOptions options; |
|
|
|
|
|
|
|
|
|
public Parser(DriverOptions options) |
|
|
|
|
{ |
|
|
|
|
this.options = options; |
|
|
|
|
Library = new Library(options.OutputNamespace, options.LibraryName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public bool ParseHeaders(IEnumerable<string> headers) |
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
|
|
namespace Cxxi |
|
|
|
|
{ |
|
|
|
|
public class Parser |
|
|
|
|
{ |
|
|
|
|
public Library Library { get; private set; } |
|
|
|
|
private readonly DriverOptions options; |
|
|
|
|
|
|
|
|
|
public Parser(DriverOptions options) |
|
|
|
|
{ |
|
|
|
|
bool bHasErrors = false; |
|
|
|
|
this.options = options; |
|
|
|
|
Library = new Library(options.OutputNamespace, options.LibraryName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public bool ParseHeaders(IEnumerable<string> headers) |
|
|
|
|
{ |
|
|
|
|
bool hasErrors = false; |
|
|
|
|
foreach (var header in headers) |
|
|
|
|
{ |
|
|
|
|
var result = ParseHeader(header); |
|
|
|
@ -26,36 +26,39 @@ namespace Cxxi
@@ -26,36 +26,39 @@ namespace Cxxi
|
|
|
|
|
{ |
|
|
|
|
foreach (var diag in result.Diagnostics) |
|
|
|
|
{ |
|
|
|
|
if (diag.Level == ParserDiagnosticLevel.Error || diag.Level == ParserDiagnosticLevel.Fatal) |
|
|
|
|
if (diag.Level == ParserDiagnosticLevel.Error || |
|
|
|
|
diag.Level == ParserDiagnosticLevel.Fatal) |
|
|
|
|
{ |
|
|
|
|
Console.WriteLine(String.Format("{0}({1},{2}): error: {3}", diag.FileName, diag.lineNumber, diag.columnNumber, diag.Message)); |
|
|
|
|
bHasErrors = true; |
|
|
|
|
Console.WriteLine(string.Format("{0}({1},{2}): error: {3}", |
|
|
|
|
diag.FileName, diag.LineNumber, diag.ColumnNumber, |
|
|
|
|
diag.Message)); |
|
|
|
|
hasErrors = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} //if
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return !bHasErrors; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ParserResult ParseHeader(string file) |
|
|
|
|
{ |
|
|
|
|
var parserOptions = new ParserOptions |
|
|
|
|
{ |
|
|
|
|
Library = Library, |
|
|
|
|
FileName = file, |
|
|
|
|
Verbose = false, |
|
|
|
|
IncludeDirs = options.IncludeDirs, |
|
|
|
|
Defines = options.Defines, |
|
|
|
|
ToolSetToUse = options.ToolsetToUse |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var result = ClangParser.Parse(parserOptions); |
|
|
|
|
HeaderParsed(file, result); |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Action<string, ParserResult> HeaderParsed = delegate {}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return !hasErrors; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ParserResult ParseHeader(string file) |
|
|
|
|
{ |
|
|
|
|
var parserOptions = new ParserOptions |
|
|
|
|
{ |
|
|
|
|
Library = Library, |
|
|
|
|
FileName = file, |
|
|
|
|
Verbose = false, |
|
|
|
|
IncludeDirs = options.IncludeDirs, |
|
|
|
|
Defines = options.Defines, |
|
|
|
|
ToolSetToUse = options.ToolsetToUse |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var result = ClangParser.Parse(parserOptions); |
|
|
|
|
HeaderParsed(file, result); |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Action<string, ParserResult> HeaderParsed = delegate {}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|