0

So I have a grammar inside a one-dimensional array, given by the form

struct array
{
    char left;
    char right[3];
    char number;
}

Example:

array.left = 'A';
array.right = "BC";
array.number = insert_some_conventional_null_character_here

This is translated to:

A->BC

------

Other examples:

A->3
C->BDE
X->9

Also, array.number is bounded by [0, 9].

array.right and array.left are literals in the interval [A, Z].

I need to return a linked-list containing all rules(grammar components) applied to get from an input string, called startString to another input string called stopString.

As you can see, this grammar is not given in the Chomsky Normal Form and I believe I cannot translate it into CNF because the grammar would change and I cannot return the linked list requested by the program.

How should I proceed? Just as a Post-Scriptum, there are at most 1000 such rules inside the grammar, so I guess that a recursive parser might not be the way to go. I've asked before and I was told to read about CYK algorithm, which I did. This is a problem I was given as a project. Please keep in mind I just started this level of programming. However, I do have all the basic knowledge.

0 Answers0