Question

I'm going through the ParseKit example and trying to modify it to suit my needs and running into this problem. As soon as I pass in the grammar file to parserFromGrammar:assembler, I get an error:

[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array

I thought maybe it was because my grammar files had token names with underscores in them. Does ParseKit support underscores? What would the method name be that gets called back? Aka would the token name "foo_bar" call a method didMatchFoo_bar?

I then took out all the underscored names and it still gives me that error. I'm using the example grammar file from the ParseKit website:

@start = sentence+;
sentence = adjectives 'beer' '.';
adjectives = cold adjective*;
adjective = cold | freezing;
cold = 'cold';
freezing = 'freezing';

Thanks

Was it helpful?

Solution

Developer of ParseKit here. 2 things:

  1. To answer your first question, I believe the answer is YES.

  2. I just tried out the grammar and it seems to work for me. However, I am using the latest version of ParseKit from Google Code (not GitHub. GitHub is out of date. sorry.)

So checkout ParseKit from Google Code here:

https://parsekit.googlecode.com/svn/trunk

And then select the "DebugApp" target and "DebugApp" Executable and run.

In the Xcode project, do a global search for "cold freezing beer". you'll see I've added your example as the default example run in DebugApp. Seems to work ok.

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