2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-07-03 01:31:54 +00:00

Add verbose parameter to ZoneCodeGenerator instead of always being verbose in debug mode

This commit is contained in:
Jan
2019-09-27 22:57:58 +02:00
parent f9b7fa57c8
commit 49dfff1efe
10 changed files with 28 additions and 18 deletions

View File

@ -15,7 +15,7 @@ namespace ZoneCodeGenerator.Parsing.C_Header
new PostProcessorUsages(),
};
public static IDataRepository ReadFile(string path)
public static IDataRepository ReadFile(string path, bool verbose = false)
{
try
{
@ -29,7 +29,7 @@ namespace ZoneCodeGenerator.Parsing.C_Header
var lexer = new Lexer(preprocessorStream);
var parser = new Parser<HeaderParserState>(state, lexer);
if (!parser.Parse())
if (!parser.Parse(verbose))
return null;
dataRepository = new InMemoryDataRepository();

View File

@ -16,7 +16,7 @@ namespace ZoneCodeGenerator.Parsing.CommandFile
new PostProcessorDefaultBlock(),
};
public static bool ReadFile(string path, CUISession session)
public static bool ReadFile(string path, CUISession session, bool verbose = false)
{
try
{
@ -29,7 +29,7 @@ namespace ZoneCodeGenerator.Parsing.CommandFile
var lexer = new Lexer(preprocessorStream);
var parser = new Parser<ICommandParserState>(state, lexer);
if (!parser.Parse())
if (!parser.Parse(verbose))
return false;
preprocessorStream.Close();

View File

@ -17,12 +17,7 @@ namespace ZoneCodeGenerator.Parsing.Matching
{
Lexer = lexer;
this.taggedMatchers = taggedMatchers;
#if DEBUG
Verbose = true;
#else
Verbose = false;
#endif
}
public TokenMatcher GetMatcherByTag(string tag)

View File

@ -17,7 +17,7 @@ namespace ZoneCodeGenerator.Parsing
this.lexer = lexer;
}
public bool Parse()
public bool Parse(bool verbose = false)
{
while (!lexer.IsEndOfStream)
{
@ -27,7 +27,7 @@ namespace ZoneCodeGenerator.Parsing
{
foreach (var test in state.GetTests())
{
switch (test.PerformTest(state, lexer))
switch (test.PerformTest(state, lexer, verbose))
{
case TokenTestResult.Match:
lexer.SkipTokens(test.ConsumedTokenCount);

View File

@ -57,7 +57,7 @@ namespace ZoneCodeGenerator.Parsing.Testing
protected abstract void ProcessMatch(TState state);
public TokenTestResult PerformTest(TState state, ILexer lexer)
public TokenTestResult PerformTest(TState state, ILexer lexer, bool verbose = false)
{
var tokenOffset = 0;
matchedEntries.Clear();
@ -65,7 +65,10 @@ namespace ZoneCodeGenerator.Parsing.Testing
ConsumedTokenCount = 0;
tested = true;
var context = new MatchingContext(lexer, taggedMatchers);
var context = new MatchingContext(lexer, taggedMatchers)
{
Verbose = verbose
};
if (context.Verbose)
{

View File

@ -4,6 +4,6 @@
{
int ConsumedTokenCount { get; }
TokenTestResult PerformTest(TState state, ILexer lexer);
TokenTestResult PerformTest(TState state, ILexer lexer, bool verbose = false);
}
}