Free Tutorials, Linux Command, Source Code Architecture,  Software Engineering, Intelligent Systems, RDBMS, Computer Accounting,  Operations Research, Discrete Mathematics, Network, SAD Lay Networks Lay Networks
Computer Science Networking Operating Systems Linux and Unix Source Code Script & Languages Protocols Glossary
Web laynetworks.com
Google
 


Context Free Grammar
Contributed by Rimincha Ammu

Introduction
A Context Free Grammar (CFG) is a set of recursive rewriting rules (or productions) used to generate patterns of strings.

A CFG consists of the following components:

· A set of terminal symbols, which are the characters of the alphabet that appear in the strings generated by the grammar.

· A set of non-terminal symbols, which are placeholders for patterns of terminal symbols that can be generated by the non-terminal symbols.

· A set of productions, which are rules for replacing (or rewriting) non-terminal symbols (on the left side of the production) in a string with other non-terminal or terminal symbols (on the right side of the production).

· A start symbol, which is a special non-terminal symbol that appears in the initial string generated by the grammar.

To generate a string of terminal symbols from a CFG, we:

· Begin with a string consisting of the start symbol;

· Apply one of the productions with the start symbol on the left hand side, replacing the start symbol with the right hand side of the production;

· Repeat the process of selecting non-terminal symbols in the string, and replacing them with the right hand side of some corresponding production, until all non-terminals have been replaced by terminal symbols.

A) Context Free Grammar for if……..else………if statement

<start> ---à if ( <expr> ) <stmt> else <stmt> if ( <expr> ) <stmt>

<stmt> = Statement
<expr> = Expression
Non-terminal symbols are <stmt> and <expr>
Terminal symbols are if and else
<start> is the Start symbol

B) Context Free Grammar for Switch statement

<start> ---à switch ( <expr> ) <stmt>
<stmt> ---à case <expr> : <stmt>
<stmt> = Statement
<expr> = Expression
Non-terminal symbols are <stmt> and <expr>
Terminal symbols are switch and case
The symbol <stmt> at the end of the first line is the production
<start> is the Start symbol

C) Context Free Grammar for Do……….while statement

<start> ---à do <stmt> while ( <expr> ) ;

<stmt> = Statement
<expr> = Expression
Non-terminal symbols are <stmt> and <expr>
Terminal symbols are do and while
<start> is the Start symbol

--------------------------------------------------------------------------------

ANSWER 2 B

Answer

Top

Back
FDDI Frequently Asked Questions (FAQ), The function and frame format of FDDI,Aloha,Comparative analysis between two types of ATM Switches,Knockout Switch,Barcher-Banyan Switch,Various popular standards for compressing multimedia data,Distributed Multimedia Survey: Standards, ASCII to hex value chart,Comparative analysis - TCP - UDP, Addressing Formats and QoS parameters, Bellman Ford's Algorithm Lay networks, free, java, java script, asp, vb, linux, ignou, tutorial, Unix commands, System Analysis, System Design, Ipv6, quiz, download, free, Computer Architecture, Object Oriented System, Relational Database Management Systems, Object Oriented System, Operating Systems, Software Engineering, Communications and Networks, Discrete Mathematics, Intelligent Systems, Operations Research, Accounting and Finance on Computersmca, networking, protocols, glossary, assignment, project, tma, programming source code, programming, source code, unix, free
 
Book Mark/Share this site at BlinkBits BlinkList Blogmarks co.mments Delicious Digg Fark Furl it! Google Ma.gnolia Netvouz NewsVine RawSugar Reddit Shadows Simpy Stumble Technorati YahooMyWeb

Copyright © 2000- 2007 Lay Networks All rights reserved. 
This website is best viewed in Firefox 1.0.1 above.

Web Hosting sponsored by Customized Software Company India
Web Site Designed by Web Designing, Flash Animation, Multimedia Presentations, Broacher/catalogue designing, Web Promotion 
Refer to your freind About Us Legal IGNOU Contact Us Feedback Donate to laynetworks.com Download Management Tutorials Tutorials History Search here