DairySeeker
DairySeeker

Reputation: 326

Propostional Logic Grammar for ParseKit

I'm trying to write a grammar for Parsekit to be used in my iphone app. Am I doing this correctly?

@start = wff;

wff = disjunction ('IMPLIES' | disjunction);
disjunction = conjunction ('OR' | conjunction)*;
conjunction = notexpression ('AND' | notexpression)*'
notexpression = ('NOT')+ primaryexpression;
primaryexpression = (literal | '(' wff ')');
literal = (A | B | C | D | E | F | G | H | I | J | K | L | M | N |O | P | Q | R | S | T |         U | V | W | X | Y | Z);

I am getting the error:

2012-11-26 10:41:06.348 SemanticTab[4092:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not build ClassName from token array for parserName: conjunction'
*** First throw call stack: 

When trying to parse P OR Q?

Upvotes: 3

Views: 109

Answers (1)

Todd Ditchendorf
Todd Ditchendorf

Reputation: 11337

Developer of ParseKit here.

I see two obvious problems:

  1. The line with the conjunction production definition is terminated with a ' (single quote). That should instead be a ; (semi colon).

  2. The definition for the literal production is not valid. There are no productions called A, B, C, etc. defined. However, if I understand your intention, the easier way to define literal is to use the built-in Word production:

    literal = Word;

Upvotes: 2

Related Questions