|
|
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 |
|
There is no answer at this time. |
|
There are no comments at this time. |
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 Home - Answers FAQ - Terms of Service - Privacy Policy |