Google Answers Logo
View Question
 
Q: Operator Precedence with BNF Grammars ( No Answer,   0 Comments )
Question  
Subject: Operator Precedence with BNF Grammars
Category: Computers > Programming
Asked by: cbakhru-ga
List Price: $10.00
Posted: 17 Feb 2006 19:34 PST
Expires: 22 Feb 2006 11:33 PST
Question ID: 447168
Operator Precedence 
 
 Each of the two grammars below, G1 and G2, defines the syntax of
expressions involving identifier operands and the operators
 
  + 
 Infix Plus 
 
  - 
 Prefix and Infix Minus 
 
  * 
 Multiplication 
 
  / 
 Division 
 
  ** 
 Exponentiation 
 
 These two grammars differ slightly in the order in which operations
are evaluated.
 
   
 Explain the effects of this difference, illustrating your answer by
showing the differences in two parse trees for a particular expression
(one in each grammar; G1 and G2). Provide three such illustrations for
three different sentences defined by the grammars.
 
   
 Which of the two grammars would you select and why? 
 
 Grammar G1 
 
   <e> ::= <e1> | <e> + <e1> | <e> - <e1> 
   <e1> ::= <e2> | <e1> * <e2> | <e1> / <e2>  
   <e2> ::= <id> | - <e2> | <e3> 
   <e3> ::= <id> ** <e2> 
 Grammar G2 
 
   <e> ::= <e1> | <e1> + <e> | <e1> - <e> 
   <e1> ::= <e2> | <e2> * <e1> | <e2> / <e1> 
   <e2> ::= <e2> ** <e3> | <e3> 
   <e3> ::= <id> | - <id> 
 
 Describing BNF using BNF 
 
 Write an BNF grammar to describe STANDARD BNF. Since the symbols you
will be using in the meta-language will be the same as those of the
language being described, you will have to use the technique of
underlining such symbols in the language being described.

Start with: 
 
   <grammar> ::= <production>... 
   <production> ::= <left_side> ::= <right_side> 
   <left_side> ::= <non_terminal> 
    
   <non_terminal> ::= < <character>... > 
   <character> ::= a | b | c | d ... | z

Thanks,

Manohar
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy