| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
context free grammer
|
Original Message
|
Name: Dilip Tiwari
Date: March 25, 2003 at 22:12:28 Pacific
Subject: context free grammer OS: Win98 SE CPU/Ram: P330 / 64 MB
|
Comment: I have to submitt my assingments in collage and following question i am not able to solve....i need help..... Q. Discuss usefulness of CONTEXT FREE GRAMMAR. Construct context free grammar for all conditional and looping statements in C-language. Thanks and bye ! Dilip
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Jimbo
Date: March 26, 2003 at 00:18:20 Pacific
|
Reply: (edit)Try a google search on 'context free grammar' and you will find a good amount of discussion on this topic. Also, try posting to the programming forum too. -jim
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Sarika
Date: April 4, 2003 at 00:46:08 Pacific
|
Reply: (edit)Hi Dilip, go through the reply.May be it'll be of some use A context-free grammar 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" comes from the feature that the variable V can always be replaced by w, no matter in what context it occurs. A formal language is context-free if there is a context-free grammar which generates it. Context-free grammars are important because they are powerful enough to describe the syntax of programming languages; in fact, almost all programming languages are defined via 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. ___________________________________________ Here is a context-free grammar for syntactically correct infix algebraic expressions in the variables x, y and z: S -> T + S | T - S | T T -> T * T | T / T | ( S ) | x | y | z This grammar can for example generate the string "( x + y ) * x - z * y / ( x + x )". Regards
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Rishiraj
Date: April 21, 2003 at 05:12:22 Pacific
|
Reply: (edit)A) Context Free Grammar for if……..else………if statement ---à if ( ) else if ( ) = Statement = Expression Non-terminal symbols are and Terminal symbols are if and else is the Start symbol B) Context Free Grammar for Switch statement ---à switch ( ) ---à case : = Statement = Expression Non-terminal symbols are and Terminal symbols are switch and case The symbol at the end of the first line is the production is the Start symbol C) Context Free Grammar for Do……….while statement ---à do while ( ) ; = Statement = Expression Non-terminal symbols are and Terminal symbols are do and while is the Start symbol Hope this helps Regards
Report Offensive Follow Up For Removal
|

Post Locked
This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
Go to Unix Forum Home