English, asked by rujal4799, 1 year ago

Difference between context free grammar and context sensitive grammar

Answers

Answered by Anonymous
6
Hi.

A context-free grammar (CFG) is a grammar where (as you noted) each production has the form A → w, where A is a non terminal and w is a string of terminals and non terminals. Informally, a CFG is a grammar where any non terminal can be expanded out to any of its productions at any point. The language of a grammar is the set of strings of terminals that can be derived from the start symbol.

context-sensitive grammar (CSG) is a grammar where each production has the form wAx → wyx, where w and x are strings of terminals and non terminals and y is also a string of terminals. In other words, the productions give rules saying "if you see A in a given context, you may replace A by the string y." It's an unfortunate that these grammars are called "context-sensitive grammars" because it means that "context-free" and "context-sensitive" are not opposites, and it means that there are certain classes of grammars that arguably take a lot of contextual information into account but aren't formally considered to be context-sensitive.

Hope for the best.

If u have any query, u can ask me.

Please mark this answer as brainliest.

Similar questions