Write C Code Check See Input String Derived Grammar Grammar 0 B B 1 2 B Program Checkc Out Q37110665

  1. write C code to check to see if an input string can be derivedfrom a grammar. The grammar is:

A ::= 0 B

B ::= 1 A | 2 B | ;

Your program “check.c” should output “yes” if the line ofstandard input can be derived from this grammar, and “no”otherwise. Here are some examples:

$ ./check

0 ;

yes

$ ./check

0 2 1 ;

no

$

The input values will always be separated by spaces, as shownabove.


Solution


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.