freeTextLiteral

Nov 21, 2009 at 10:29 AM

Hello,

i need some help.

i would parse this structur:

 

class test
{
Content
}

Content is free text.

I do it with this definition:

var compilation_unit = new NonTerminal("compilation_unit");
var class_declaration = new NonTerminal("class_declaration");
var class_body = new NonTerminal("class_body");
var freeTextLiteral = new FreeTextLiteral("freeTextLiteral", "\n", "\r", Environment.NewLine);
var description = new NonTerminal("description");
IdentifierTerminal identifier = TerminalFactory.CreateCSharpIdentifier("Identifier");

KeyTerm Lbr = ToTerm("{");
KeyTerm Rbr = ToTerm("}");

this.Root = compilation_unit;
compilation_unit.Rule=  class_declaration;
class_declaration.Rule = "class" + identifier + Lbr +  class_body + Rbr;
class_body.Rule = description;
description.Rule = Empty | freeTextLiteral;

But it doesnt work.
The error is: "Syntax error, expected: freeTextLiteral. }"

The Testdata is:
class test
{
dsfsdfsdf
}

Can someone help me?

Coordinator
Nov 22, 2009 at 1:01 AM

Try with the latest source version, I've fixed some bugs related to FreeTextLiteral

Also look at this thread:

http://irony.codeplex.com/Thread/View.aspx?ThreadId=75375

Follow the example at the end.