我想解析下面的文件,
first=The_First_Step
{
{
value=First.Value,
}
}
second=The_Second_Step
{
{
another = Second_Value,
more = Yet.More,
}
}
我把语法写成,
public static NGSection ParseSections(string ngServerConfig)
{
return Sections.End().Parse(ngServerConfig);
}
internal static Parser<string> ValueText = Parse.LetterOrDigit.AtLeastOnce().Text().Token();
internal static Parser<string> Identifier = Parse.AnyChar.AtLeastOnce().Text().Token();
internal static Parser<Config> Config =
from id in Identifier
from equal in Parse.Char('=').Token()
from value in ValueText
from comma in Parse.Char(',').Token()
select new Config(id, value);
internal static Parser<Section> Section =
from id in Identifier
from equal in Parse.Char('=').Token()
from title in ValueText
from lbracket in Parse.Char('{').Token()
from inbracket in Parse.Char('{').Token()
from configs in Config.AtLeastOnce()
from outbracket in Parse.Char('}').Token()
from rbracket in Parse.Char('}').Token()
select new Section(id, title, configs);
internal static Parser<NGSection> Sections =
from sections in Section.AtLeastOnce()
select new NGSection(sections);
我得到了例外
解析失败:到达输入的意外结束;预期 =(第 13 行,第 2 列);最近消费:矿石 } }
任何线索都会有所帮助。