Developer of ParseKit here.
I see one obvious problem: conjunction
is misspelled in a couple of places in your grammar.
ParseKit's Grammar Parser's error messages are not the greatest. Ideally, you would receive a nice error message leading you to the problem (but, hey it's open source so anyone is welcome to contribute a fix of this nature).
However, I can tell you how I find these issues:
- Update your ParseKit working copy to head of the google code trunk.
- In Xcode, turn on breakpoints and add a breakpoint for all exceptions
- Place your ParseKit grammar in this file:
~/Desktop/grammar.txt
- (Optional) Place any example input in this file:
~/Desktop/input.txt
- Run the ParseKit
DebugApp
target in Debug configuration. - Click the big
Run
button in the window that appears when the app runs. - Wait for an exception to be thrown. Breakpoint is hit.
If there is a bug in your grammar, you will find the exception has most likely occurred in a ParseKit Assembler callback like:
- (void)parser:(PKParser *)p didMatchExpression:(PKAssembly *)a
print a
to the debug console. You'll see something like:
(lldb) po a
(PKAssembly *) $1 = 0x00000001075a9010 [] /conjuction/ ^(/or/ /conjuction/)/*
This is a printout of the PKAssembly
object passed into your callback. Here you can see where ParseKit's grammar parser failed to parse your grammar. It appears that the ParseKit Grammar Parser failed while parsing this expression:
conjuction (or conjuction)*;
And from the position of the ^
(caret), you can tell the parser choked right after seeing the first conjuction
.
This expression is located in just one line in your grammar:
disjunction = conjuction (or conjuction)*;
That's how I noticed that there was a misspelling in this line.
This approach will invariably lead you to the problematic line in your grammar. Hope that helps.