Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6332897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:21:49+00:00 2026-05-24T18:21:49+00:00

I just discovered ParseKit but can’t seem to get it working on a simple

  • 0

I just discovered ParseKit but can’t seem to get it working on a simple example.

NSString *test = @"FOO:BAR";

    NSString *grammar = ...//get grammar txt file and read it into a string

    PKParser *parser = nil;
    parser = [[PKParserFactory factory] parserFromGrammar:grammar assembler:self];

    [parser parse:test];
}

- (void)didMatchFoo:(PKAssembly *)a
{
    NSLog(@"FOO");
}

- (void)didMatchBar:(PKAssembly *)a
{
    NSLog(@"BAR");
}

My grammar file looks like this:

@start = foo;
foo = 'FOO:' bar;
bar = 'BAR';

But the methods don’t fire.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:21:50+00:00Added an answer on May 24, 2026 at 6:21 pm

    Developer of ParseKit here. The example above will not work. By default the Tokenizer will tokenize this:

    FOO:BAR
    

    as three tokens:

    Word (FOO)
    Symbol (:)
    Word (BAR)
    

    The problem is your grammar is expecting a word like ‘FOO:’, but colons are Symbol chars by default, not Word chars. If you want colons (:) to be accepted as valid internal “Word” chars, you’ll have to customize the Tokenizer to make it accept that. I kinda doubt you really want that tho. If you do, read the docs here to learn how to customize the Tokenizer: http://parsekit.com/tokenization.html

    I think a better ‘toy’ grammar to start with might be something like:

    @start = pair;
    pair = foo colon bar;
    foo = 'FOO';
    colon = ':';
    bar = 'BAR';
    

    You have a lot of flexibility in how you do your declarations in your grammar. An equivalent grammar would be:

    @start = foo ':' bar;
    foo = 'FOO';
    bar = 'BAR';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just discovered a bug where the code looked something like this: char *foo
I just discovered this component and started working with it. I understand that the
I've just discovered that Oracle lets you do the following: SELECT foo.a, (SELECT c
I just discovered when creating some CRUD tests that you can't set data in
I just discovered the possibility to use vi-mode in zsh. Pretty awesome. But I
I just discovered that some parts of the code I am working on incorrectly
I just discovered that i can give a name to For and While statements.
Just discovered MSpec, and want to try it out. However, I can't find any
Just discovered Comet, and am very confused. Can someone tell me what the consensus
I just discovered that when Language Extensions are disabled in MSVC, you get this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.