mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Fix logic to detect empty files
This commit is contained in:
parent
657b8ed465
commit
690a5af383
@ -208,7 +208,7 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
|
|
||||||
if (parser_rt == null || parser_rt.Tree == null)
|
if (parser_rt == null || parser_rt.Tree == null)
|
||||||
{
|
{
|
||||||
if (tokens.Count > 0)
|
if (lex.FoundMeat)
|
||||||
{
|
{
|
||||||
Console.WriteLine("No Tree returned from parsing! (Your rule did not parse correctly)");
|
Console.WriteLine("No Tree returned from parsing! (Your rule did not parse correctly)");
|
||||||
}
|
}
|
||||||
@ -216,6 +216,7 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
{
|
{
|
||||||
// the file was empty, this is not an error.
|
// the file was empty, this is not an error.
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonTreeNodeStream nodes = new CommonTreeNodeStream(parser_rt.Tree);
|
CommonTreeNodeStream nodes = new CommonTreeNodeStream(parser_rt.Tree);
|
||||||
@ -253,7 +254,7 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
{
|
{
|
||||||
if (cfg.DebugLevel > 3) Console.Out.WriteLine("Translating file {0}", fullName);
|
if (cfg.DebugLevel > 3) Console.Out.WriteLine("Translating file {0}", fullName);
|
||||||
CommonTreeNodeStream csTree = parseFile(fullName);
|
CommonTreeNodeStream csTree = parseFile(fullName);
|
||||||
if (cfg.DumpCSharp) AntlrUtils.AntlrUtils.DumpNodes(csTree);
|
if (cfg.DumpCSharp && csTree != null) AntlrUtils.AntlrUtils.DumpNodes(csTree);
|
||||||
|
|
||||||
// ASTNode t = parseFile(f, s);
|
// ASTNode t = parseFile(f, s);
|
||||||
// if (t != null)
|
// if (t != null)
|
||||||
|
@ -18,6 +18,13 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
{
|
{
|
||||||
// if there's an #if / #else mismatch, don't complain every token :)
|
// if there's an #if / #else mismatch, don't complain every token :)
|
||||||
bool Warn = true;
|
bool Warn = true;
|
||||||
|
private bool _foundMeat = false;
|
||||||
|
public bool FoundMeat
|
||||||
|
{
|
||||||
|
get { return _foundMeat; }
|
||||||
|
set { _foundMeat = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public PreProcessor()
|
public PreProcessor()
|
||||||
{
|
{
|
||||||
@ -65,6 +72,10 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
{
|
{
|
||||||
state.token = token;
|
state.token = token;
|
||||||
Tokens.Enqueue(token);
|
Tokens.Enqueue(token);
|
||||||
|
if (token.Channel == Token.DEFAULT_CHANNEL)
|
||||||
|
{
|
||||||
|
FoundMeat = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public override IToken NextToken()
|
public override IToken NextToken()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user