Computer Science Fundamentals Algorithms Subjective
Feb 25, 2013

How will you define a context free grammar?

Detailed Explanation

A context free grammar consists of terminals, non-terminals, a start symbol, and productions.

  • Terminals are the basic symbols from which strings are formed. “Token” is a synonym for terminal. Ex: if, then, else.
  •  Nonterminals are syntactic variables that denote sets of strings, which help define the language generated by the grammar. Ex: stmt, expr.
  • Start symbol is one of the nonterminals in a grammar and the set of strings it denotes is the language defined by the grammar. Ex: S.
  • The productions of a grammar specify the manner in which the terminals and nonterminals can be combined to form strings Ex: expr

 

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback