1
我想分析如下文件,獲取例外,同時解析使用SPRACHE文件「分析失敗:達到輸入意外結束;預計=」
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欄);最近消耗:礦石 } }
任何線索都會有幫助。
只是好奇,爲什麼「關閉」投票呢?這是一個編程問題,包含源代碼,示例輸入和錯誤消息......任何有待改進的建議? –