我正在使用 Parse Kit,但我对语法有疑问。
这是我的语法字符串如下:
self.grammar = @" \
@start = sentence+; \
sentence = adjectives subjects will verbs subjects '.'; \
subjects = 'i' | 'you' | 'he' | 'she' | 'it' | 'they' | 'we' | 'who else' | 'Apples QA' | 'Hitler' | 'dance';\
verbs = 'eat' | 'sleep' | 'dance' | 'kill' | 'care'; \
will = 'will'; \
adjectives = 'awesome' | 'red' | 'beautiful' | 'odd' | 'useless' | 'temporary';";
所以,我想我可以创建包含我所有术语规则的句子。
喜欢排队:"sentence = adjectives subjects will verbs subjects '.';"
所以来自用户的输入字符串看起来像这样:“awesome you will care Apples QA”
我已将委托(汇编器)方法添加到我的汇编器中,如下所示:
- (void)didMatchSentence:(PKAssembly *)a
- (void)didMatchAdjectives:(PKAssembly *)a
- (void)didMatchWill:(PKAssembly *)a
- (void)didMatchSubject:(PKAssembly *)a
- (void)didMatchVerb:(PKAssembly *)a
但是解析器只调用了其中两个:didMatchAdjectives 和 didMatchWill
怎么会?