LearnYourBasics

Spread your knowledge

Grammar in Theory of Computing

Grammar is a set of rules and regulations for constructing a language. Grammar defines how strings are generated in a language.

In TOC, a Grammar is represented by four tuples.

G = { VNT, VT, P, S }

VNT : Finite set of Non-terminal symbols

VT : Finite set of terminal symbols

P : Set of Production Rules

S : Start symbol . It is the symbol from where strings are produced ). It is a subset of VNT .

Terminal Symbols are represented by small case letters. (a,b,c…)

Non Terminal Symbols are represented by capital letters. (A,B,C…). These symbols take part in language generation but are not a part of it.

Production Rules – used to generate new sequences of strings and symbols. It is denoted in LHS to RHS pattern.

Grammars are also classified into 4 different categories based on their production rules which falls under Chomsky Hierarchy.

  1. Regular Grammar
  2. Context-Free Grammar
  3. Context-Sensitive Grammar
  4. Unrestricted

Leave a Comment

You must be logged in to post a comment.
Scroll to Top