Question

I am using Parse Kit and I have question with grammar.

This my grammar string below:

    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';";

So, I suppose that I can create sentence that includes rules of all my terms.

Like in line: "sentence = adjectives subjects will verbs subjects '.';"

So input string from user looks like this: "awesome you will care Apples QA"

I have added delegate (assembler) methods into my assembler like this:

  • (void)didMatchSentence:(PKAssembly *)a
  • (void)didMatchAdjectives:(PKAssembly *)a
  • (void)didMatchWill:(PKAssembly *)a
  • (void)didMatchSubject:(PKAssembly *)a
  • (void)didMatchVerb:(PKAssembly *)a

but parser invoked just two of them: didMatchAdjectives and didMatchWill

How come?

Was it helpful?

Solution

You've got a typo: term calls 'subjects', but method is didMatchSubject, not didMatchSubjects

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top