Today we will discuss “context-free languages” and “context-free grammar”
Context-free language:
A context-free language is a formal language that is a member of the set of languages defined by context-free grammars. The set of context-free languages is identical to the set of languages accepted by pushdown automata.
To understand it better we will need the definition of context-free grammars.
Context-free grammar:
A context-free grammar (CFG) is a formal grammar in which every production rule is of the form
V → w
Where V is a nonterminal symbol and w is a string consisting of terminals and/or non-terminals. The term "context-free" expresses the fact that the non-terminal V can always be replaced by w, regardless of the context in which it occurs. A formal language is context-free if there is a context-free grammar that generates it.
Familiarly known as "CFGs", or "type-2" grammars. Here, there can only be one nonterminal symbol on the left-hand "assumption" side of the rule. Luckily, any rule can be rewritten to move all symbols to the right-hand "conclusion" side as needed (for example, A B ® C D is the same as A ® B C D. Rules can be applied to individual symbols since there is only one given assumption (like the "A" in the previous example). This means "CFGs are popular for natural language grammars."
Context-free grammars are powerful enough to describe the syntax of most programming languages; in fact, the syntax of most programming languages is specified using context-free grammars. On the other hand, context-free grammars are simple enough to allow the construction of efficient parsing algorithms which, for a given string, determine whether and how it can be generated from the grammar.
Next post will be based on pushdown automata. So keep in touch….
Subscribe to:
Post Comments (Atom)
1 comment:
thank's...CFG def. its is good to understand,
Post a Comment