Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 512
DairySeeker Avatar asked Jul 30 '26 03:07

DairySeeker


1 Answers

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;

like image 133
Todd Ditchendorf Avatar answered Aug 01 '26 16:08

Todd Ditchendorf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!