2011-08-18 26 views
2

我想在Objective-C中使用ParseKit開發一個UCI解析器,但我需要一種方法來匹配從文字到行尾的所有內容(可能會減去尾隨空格)。如何在ParseKit中匹配從文字到行尾的所有內容?

例如,我想分析該行:

@" 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^ 

回答

1

這裏是ParseKit的開發者。我想如果你改爲執行

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

方法,你將收到一個你想要的結果的程序集。

相關問題