Ch 3 Review Questions

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Rewrite the BNF of Example 3.4 to give + precedence over * and force + to be right associative.

<assign> -> <id> = <expr> <id> -> A|B|C <expr> - > <expr> + <term> | <term> |<term> ++ | <term> - - <term> -> <term> * <factor> | <factor> <factor> -> (<expr1> ) | <id>

Rewrite the BNF of Example 3.4 to add the ++ and -- unary operators of Java.

<assign> -> <id> = <expr> <id> -> A | B | C <expr> -> <expr> + <term> | <term> <term> -> <term> * <factor> | <factor> <factor> -> ( <expr> ) | <id> | <id> ++ | <id> - -

Write EBNF descriptions for the following: a. A Java class definition header statement b. A Java method call statement c. A C switch statement d. A C union definition e. C float literals

A Java class definition header statement <class_head> ® {<modifier>} class <id> [extends class_name] [implements <interface_name> {, <interface_name>}] <modifier> ® public | abstract | final A Java method call statement <for> -> for '(' [[<type>] <id> = <expr> {, [<type>] <id> = <expr>}] ; [<expr>] ; [<expr>{, <expr>}] ')' '{' <stmt_list> '}' A C switch statement <switch_stmt> ® switch ( <expr> ) {case <literal> : <stmt_list> {case <literal> : <stmt_list> } [default : <stmt_list>] } A C union definition <union_defn> -> union <var_list> <union_identifier>; <var_list> -> <list_of_data-type specifier> <var> <list_of_data-type specifier> -> int | float | long |char | double <union_identifier> -> <var> C float literals <float-literal> -> <real> <suffix> | <real> <exponent> <suffix> | <integer> <exponent> <suffix>

The two mathematical models of language description are generation and recognition. Describe how each can define the syntax of a program- ming language.

syntax error refers to an error in the syntax of a sequence of which is written in a particular programming language. Semantic Error: it is a logical error. it is due to wrong logical statements


संबंधित स्टडी सेट्स

Chapter 32 Environmental Emergencies

View Set

Multiplying and Dividing with Fractions - Word Problems

View Set

Chapter 5 Accounting Questions (Regent University 2019)

View Set

Getting Started with Python: Introduction

View Set

AZ-204: Create Azure App Service web apps

View Set

AI-900 Microsoft Learn Knowledge Checks

View Set