I am having some tricky problems with Irony which I do not understand...
The first parsing I do in the runtime of my application succeeds.
string src = "" // this is the file to parse
Grammar g = new CSharpGrammar();
LanguageData language = new LanguageData(g);
Parser parser = new Parser(language);
ParseTree parseTree = parser.Parse(src);
ParseRoot = parseTree.Root;
Then I followed one hint to move the LanguageData variable to the global context. Still everything ok. But now I wanted to call the Irony parser inside of custom functions, parsing multiple files with the c# grammar v3.5 provided by Irony (LINQ queries are not important to me, so that seems sufficient). Same approach:
Parser parser = new Parser(language);
ParseTree parseTree = parser.Parse(file);
ParseRoot = parseTree.Root;
But now the parseroot is and remains "null". And I have absolutely no idea why. I also checked the parser errors a moment ago, there I recognized an error I cannot comprehend.
"Syntax error, expected: statement, member declaration, namespace"
But my file looks like this:
using System;
using Microsoft.SharePoint.WebControls;
namespace WebParts.Layouts.Ordering
{
public partial class ConfirmDelete : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
lblMsg.Text = "Are you sure you want to delete the entry?";
if (!IsPostBack)
{
BtnYes.Attributes.Add("onclick", "OnYes(); return false;");
BtnNo.Attributes.Add("onclick", "OnNo(); return false;");
}
}
}
}
I hope you can see what's wrong with my code... I'm getting desperate with this thing...