Ah! So the line number is correct however for the WSA compile the LexicalInfo's FileName and FullPath properties are empty. So I assume this is causing the problem.
I'll look at the source and see if I can spot where this is happening. Any pointers will be welcome :)
Thanks again
-----Original Message-----
From: boolang@googlegroups.com [mailto:boolang@googlegroups.com] On Behalf Of André van der Merwe
Sent: 05 November 2009 21:00
To: boolang@googlegroups.com
Subject: RE: White space agnostics prevents debugging from working?
>I think the parser might not be counting lines properly but I didn't
>have time to confirm this.
>Try to just parse something (other than compile it) and see if the
>node's LexicalInfo is pointing to the correct place...
Hi,
I added a compiler step that calls a visitor to check the node's LexicalInfo.Line property in EnterMemberReferenceExpression and for both the WSA and non-WSA the line numbers look correct. (Hope this is what you were suggesting...)
Thanks for the help.
Full test code
--------------------------
class Program
{
static void Main(string[] args)
{
string code = @"
class Tester:
public def TestMethod():
print 1
System.Diagnostics.Debugger.Break()
print 2
print 3
end
end
System.Diagnostics.Debugger.Break()
print 2";
var codeReader = new StringReader(code);
File.WriteAllText("test.boo", code);
var booc = new BooCompiler();
booc.Parameters.GenerateInMemory = true;
booc.Parameters.Input.Add(new ReaderInput("test.boo", codeReader));
booc.Parameters.OutputType = CompilerOutputType.ConsoleApplication;
booc.Parameters.Debug = true;
booc.Parameters.WhiteSpaceAgnostic = true;
//booc.Parameters.Pipeline = new CompileToMemory();
booc.Parameters.Pipeline = new CompileToFile();
booc.Parameters.OutputAssembly = "test.exe";
//booc.Parameters.Pipeline.RemoveAt(0);
//booc.Parameters.Pipeline.Insert(0, new WSABooParsingStep());
booc.Parameters.Pipeline[0] = new WSABooParsingStep();
booc.Parameters.Pipeline.Add(new RunVisitorCompilerStep(new TestVisitor()));
CompilerContext context = booc.Run();
if (context.Errors.Count == 0)
{
var asm = context.GeneratedAssembly;
var type = asm.GetType("Tester");
var o = Activator.CreateInstance(type);
var method = type.GetMethod("TestMethod");
method.Invoke(o, new object[] { });
}
}
}
class TestVisitor : DepthFirstVisitor
{
public override bool EnterMemberReferenceExpression(MemberReferenceExpression node)
{
Console.WriteLine("{0} {1}", node.LexicalInfo.Line, node.ToString());
return base.EnterMemberReferenceExpression(node);
}
}
public class RunVisitorCompilerStep : AbstractCompilerStep
{
private readonly DepthFirstVisitor m_visitor;
public RunVisitorCompilerStep(DepthFirstVisitor visitor)
{
m_visitor = visitor;
}
public override void Run()
{
m_visitor.Visit(CompileUnit);
}
}
--------------------------
Both output this
3 System.Console.WriteLine
3 System.Console
4 System.Diagnostics.Debugger.Break
4 System.Diagnostics.Debugger
4 System.Diagnostics
5 System.Console.WriteLine
5 System.Console
6 System.Console.WriteLine
6 System.Console
10 System.Diagnostics.Debugger.Break
10 System.Diagnostics.Debugger
10 System.Diagnostics
11 System.Console.WriteLine
11 System.Console