This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center




7年前关闭。




我正在使用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 '.';"
因此,来自用户的输入字符串如下所示:“太棒了,您将在乎Apple质量检查”

我已经将委托(汇编器)方法添加到了我的汇编器中,如下所示:
  • (void)didMatchSentence:(PKAssembly *)a
  • (void)didMatchAdjectives:(PKAssembly *)a
  • (void)didMatchWill:(PKAssembly *)a
  • (void)didMatchSubject:(PKAssembly *)a
  • (void)didMatchVerb:(PKAssembly *)a

  • 但解析器仅调用了其中两个:didMatchAdjectives和didMatchWill

    怎么会?

    最佳答案

    您有错别字:term称为“subjects”,但方法是didMatchSubject,而不是didMatchSubjects

    关于objective-c - ParseKit尚未按我预期的那样调用方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13291666/

    10-09 15:59