DEV Community

Mujahida Joynab
Mujahida Joynab

Posted on

What is grammar in TOC?

Natural Language
What is the use of grammar in a language?

  1. It determines if a sentence is a part of that language or not . It says it is a part of Bengali , Arabic , Hindi or not Example - Here is your coffee Is it a part of English language ? -> Yes , It is

Is here coffee your ?
-> It is not a part of English -> Grammar says

So , Grammar determines -

  1. If a string a part of the language or not checked by automata . That is grammar G = {V,T,P,S} . Here , V = Variables T = Terminal P = Production Rule S = Start Symbol

S -> a S b / epsilon
Epsilon , a S b , aaSbb , aaaSbbb
Epsilon , ab a^2b^2 , a^3b^3 , a^4b^4... ... ... a^nb^n (n>= 0)
aaSbb - a Epsilon b

It benefits grammar

S -> SS
S -> aSb
s -> bSa
S -> Epsilon
Language -> number of a in string w = number of b in string w
a^nb^n
This is how we produce language in grammar

Top comments (0)