1

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^
4

1 に答える 1

1

ParseKit の開発者はこちら。代わりに実装すると思います

- (void)didMatchSentence:(PKAssembly *)a
{
  NSLog(@"%@", a);
}

方法、必要な結果を含むアセンブリを受け取ります。

于 2011-08-21T19:34:03.513 に答える