Question

In: Computer Science

Write EBNF descriptions for the following: • a Java For each statement Assume that EBNF descriptions...

Write EBNF descriptions for the following:

• a Java For each statement

Assume that EBNF descriptions for statement(s), type, array, white space are given. (statmnts, type, array, and whitespace respectively)

You have to create EBNF descriptions for For each statement and also variable.

Use the following Java variable naming rules to create EBNF description for variable.

o All variable names must begin with a letter of the alphabet, an underscore ( _ ) , or a dollar sign ( $ ).

o After the first initial letter, variable names may also contain letters and the digits 0 to 9. No spaces or special characters are allowed.

Assume that EBNF description for alphabet (including both upper and lower cases) and digits (0 – 9) are given. (alphabet and digit respectively)

Solutions

Expert Solution

EBNF:-

<statements> -> statmnts; | <for> | statmnts;<statements>

<for> -> for '(' <type> <variable> ':' <array> ')' '{' <statements> '}'

<variable> -> ('_' | '$' | <alpha>)<var>

<var> -> ('' | '$' | <alpha> | <num>)<var> | '' | '$' | <alpha> | <num>|epsilon

<type> -> type

<array> -> array

<alpha> -> alphabet

<num> -> digit

let example:-

for(type alphabet : array){

statmnts;

}

<statements> -> <for>

-> for '(' <type> <variable> ':' <array> ')' '{' <statements> '}'

-> for '(' type <variable> ':' <array> ')' '{' <statements> '}'

->for '(' type <alpha><var> ':' <array> ')' '{' <statements> '}'

->for '(' type alphabet<var> ':' <array> ')' '{' <statements> '}'

->for '(' type alphabet ':' <array> ')' '{' <statements> '}'

->for '(' type alphabet ':' array ')' '{' <statements> '}'

->for '(' type alphabet ':' array ')' '{' statmnts; '}'

one more example:-

for(type alphabet : array){

for(type _alphabet : array){

statmnts;

statmnts;

}

}

<statements> -> <for>

-> for '(' <type> <variable> ':' <array> ')' '{' <statements> '}'

-> for '(' type <variable> ':' <array> ')' '{' <statements> '}'

->for '(' type <alpha><var> ':' <array> ')' '{' <statements> '}'

->for '(' type alphabet<var> ':' <array> ')' '{' <statements> '}'

->for '(' type alphabet ':' <array> ')' '{' <statements> '}'

->for '(' type alphabet ':' array ')' '{' <statements> '}'

->for '(' type alphabet ':' array ')' '{' <for> '}'

->for '(' type alphabet ':' array ')' '{' for '(' <type> <variable> ':' <array> ')' '{' <statements> '}' '}'

->for '(' type alphabet ':' array ')' '{' for '(' type <variable> ':' <array> ')' '{' <statements> '}' '}'

->for '(' type alphabet ':' array ')' '{' for '(' type _<alpha> ':' <array> ')' '{' <statements> '}' '}'

->for '(' type alphabet ':' array ')' '{' for '(' type _alphabet ':' <array> ')' '{' <statements> '}' '}'

->for '(' type alphabet ':' array ')' '{' for '(' type _alphabet ':' array ')' '{' <statements> '}' '}'

->for '(' type alphabet ':' array ')' '{' for '(' type _alphabet ':' array ')' '{' statmnts;<statements> '}' '}'

->for '(' type alphabet ':' array ')' '{' for '(' type _alphabet ':' array ')' '{' statmnts; statmnts; '}' '}'


Related Solutions

5-Write an EBNF rules that describes the following while statement of Java. Then, write the recursive-descent...
5-Write an EBNF rules that describes the following while statement of Java. Then, write the recursive-descent subprogram in Java or C/C++ for the EBNF rule. Please summit your source code and a screen shot of the parsing of the following examples. do { if ( number % 2 == 0 ) even ++; number=number+1; } while (number <= 10)
Write the EBNF for mini Java language based of the following information: Data Types Integer Int...
Write the EBNF for mini Java language based of the following information: Data Types Integer Int Long Double Boolean Char References Complex Data Structures Arrays int v[30]; Classes member variables class Name { int a; char b; char name[25]; } Methods Return data type Primitive data type Void Method Name Parameter list Could be empty Statement Block { Variable declarations Executable Statements } Program Variable Declarations Class Definitions Methods Only one method named "main" but must have one method named...
Write down descriptions for each of the following sets:
Write down descriptions for each of the following sets:● Three different countably infinite subsets of the real numbers.● Three different uncountably infinite subsets of the real numbers.● One uncountably infinite proper super set of the real numbers.
Write a program in java processing. Write a program that does the following: · Assume the...
Write a program in java processing. Write a program that does the following: · Assume the canvas size of 500X500. · The program asks the user to enter a 3 digit number. · The program then checks the value of the first and last digit of the number. · If the first and last digits are even, it makes the background green and displays the three digit number at the mouse pointer. · If the two digits are odd, it...
Java please! Write the code in Exercise.java to meet the following problem statement: Write a program...
Java please! Write the code in Exercise.java to meet the following problem statement: Write a program that will print the number of words, characters, and letters read as input. It is guaranteed that each input will consist of at least one line, and the program should stop reading input when either the end of the file is reached or a blank line of input is provided. Words are assumed to be any non-empty blocks of text separated by spaces, and...
Write the chemical formula for each substance mentioned in the following word descriptions (use the front...
Write the chemical formula for each substance mentioned in the following word descriptions (use the front inside cover to find the symbols for the elements you do not know). (a) Zinc carbonate can be heated to form zinc oxide and carbon diox- ide. (b) On treatment with hydrofluoric acid, silicon dioxide forms silicon tetrafluoride and water. (c) Sulfur dioxide reacts with water to form sulfurous acid. (d) The substance phos- phorus trihydride, commonly called phosphine, is a toxic gas. (e)...
This for Java Programming Write a java statement to import the java utilities. Create a Scanner...
This for Java Programming Write a java statement to import the java utilities. Create a Scanner object to read input. int Age;     Write a java statement to read the Age input value 4 . Redo 1 to 3 using JOptionPane
Select the correct term for each of the following descriptions. Descriptions Terms This theory argues that...
Select the correct term for each of the following descriptions. Descriptions Terms This theory argues that there is no optimal dividend policy because a firm’s dividend policy does not affect the value of the firm. Stock dividend    According to this theory, an announced dividend payment that exceeds investors’ expectations is interpreted to be “good” news and should be expected to increase the price of the firm’s common stock, whereas an announced dividend that is less than investors’ expectations is...
Select the appropriate term associated with a bank reconciliation for each of the following descriptions. Descriptions...
Select the appropriate term associated with a bank reconciliation for each of the following descriptions. Descriptions Terms a. Cash receipts received by the company but not yet recorded by the bank. b. Fees imposed by the bank to the company for providing routine services. c. Checks written to the company that are returned by the bank as not having adequate funds. d. Checks written by the company but not yet recorded by the bank. e. Money earned on the average...
Write a balanced chemical equation for each of the following descriptions of chemical reactions, including state symbols:
Write a balanced chemical equation for each of the following descriptions of chemical reactions, including state symbols:a. Aluminum metal reacts with aqueous iron(II) chloride to form aqueous aluminum chloride and iron metal.b. Solid cobalt (III) oxide reacts with solid carbon to produce solid cobalt and carbon dioxide gas.c. Nitrogen dioxide gas reacts with gaseous oxygen and liquid water to form aqueous nitric acid.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT