Skip to content
Sumedh Arani edited this page Mar 13, 2016 · 1 revision

The program prompts the user to enter a file name. The file will contain a grammar (assuming that the given grammar will be in Chomsky Normal Form). Then the program prompts the user to enter a string. It then outputs whether or not this string so entered belongs to the language of the grammar specified in the input file.

An example input file:

S -> AB | a A -> SA | BS | BB | c B -> AS | AA | b

Assumptions about the grammar file:

  • Assuming that all non-terminals are in uppercase and all terminals are in lowercase.
  • There can be multiple |'s (as shown above), or even none (such as for instance, S -> BA) for a given production. -There can be same non terminal appearing more than once in the LHS.

Clone this wiki locally