如何在 ParseKit 中匹配从文字到行尾的所有内容?
我正在尝试使用 ParseKit 在 Objective-C 中开发 UCI 解析器,但我需要一种方法匹配从文字到行尾的所有内容(可能减去尾随空格)。
例如,我要解析的行是:
@" id name Protector 1.4.0 Linux \n"
我的语法看起来像:
@start = sentence+;
sentence = 'id' 'name' name;
name = Any+;
并且
- (void)didMatchName:(PKAssembly *)a
{
NSLog(@"%@", a);
}
显然打印:
[id, name, Protector, 1.4, .0]id/name/Protector/1.4/.0^Linux
[id, name, Protector]id/name/Protector^1.4/.0/Linux
[id, name, Protector, 1.4, .0, Linux]id/name/Protector/1.4/.0/Linux^
[id, name, Protector, 1.4]id/name/Protector/1.4^.0/Linux
如何构建以这种方式标记该字符串的语法?
[id, name, Protector 1.4.0 Linux]id/name/Protector 1.4.0 Linux^
I am trying to develop an UCI parser in Objective-C using ParseKit, but I need a way to match everything from a literal to the end of the line (possibly minus the trailing whitespace).
For example, the line I want to parse is:
@" id name Protector 1.4.0 Linux \n"
My grammar looks like:
@start = sentence+;
sentence = 'id' 'name' name;
name = Any+;
and
- (void)didMatchName:(PKAssembly *)a
{
NSLog(@"%@", a);
}
obviously prints:
[id, name, Protector, 1.4, .0]id/name/Protector/1.4/.0^Linux
[id, name, Protector]id/name/Protector^1.4/.0/Linux
[id, name, Protector, 1.4, .0, Linux]id/name/Protector/1.4/.0/Linux^
[id, name, Protector, 1.4]id/name/Protector/1.4^.0/Linux
How can I construct a grammar that tokenizes that string in this way?
[id, name, Protector 1.4.0 Linux]id/name/Protector 1.4.0 Linux^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ParseKit 的开发者在这里。我认为如果您改为实现该
方法,您将收到包含您想要的结果的程序集。
Developer of ParseKit here. I think if you instead implement the
Method, you will receive an Assembly with the results you want.