Question

In: Computer Science

3.Use EBNF to describe the syntax of Java ifstatements, no need to further define other statements...

3.Use EBNF to describe the syntax of Java ifstatements, no need to further define other statements or Boolean expressions.

4.Python uses indention in its program structures. How do you define the syntax of a language construct that uses indention?

Solutions

Expert Solution

EBNF:
=======

If-statement
------------

if_statement <=
   [if_label : ]
   if boolean_expression then
       { sequential_statement }  
   { elsif boolean_expression then
       { sequential_statement }
   }
   [else
       { sequential_statement }
   ]  
   end if [if_label];  

Python:
========

There are two parts to create language:
    1. Lexeme specification: defines groups of characters that represent a single syntactic construct like token or terminal value
    2. Grammar specification: defines the valid combinations of syntactic constructs/tokens/terminal values that make up non-terminal values that express how the language can be used in level

start ::= list
        | list NEWLINE
        .

list ::= entry
        | list entry
        .

entry ::= STRING NEWLINE
        | STRING NEWLINE INDENT list DEDENT
        .

Sample if-statement:
x = true
if x:
   print("x is true")
else:
   print("x is false")


Related Solutions

16. Which of the statements made by the trained medication assistant reveals the need for further...
16. Which of the statements made by the trained medication assistant reveals the need for further teaching? (Select all that apply.) a. Suspensions should never be shaken before they are measured." b. "When a patient has difficulty swallowing, even long-acting medications should be crushed." c. "It is OK to crush medications in advance when batch prepping them at the station." d. "Disgarded medications should go into the sharps container." 17. Which of these statements regarding controlled substances made by the...
Anurses new parents the proper way to use an nurse need for further teaching
Anurses new parents the proper way to use an nurse need for further teaching
Language: Java or C (NO OTHER LANGUAGE) Do NOT use Java library implementations of the data...
Language: Java or C (NO OTHER LANGUAGE) Do NOT use Java library implementations of the data structures (queues, lists, STs, hashtables etc.) Have a unit test implemented in main(). And comment every code. Show examples from the executions. Assume that the edges defined by the vertex pairs in the data base are one-way. Question: Write a program that can answer if there is a path between any to vertices. For the vertex pairs use this as your input example: AL...
Language: Java or C (NO OTHER LANGUAGE) Do NOT use Java library implementations of the data...
Language: Java or C (NO OTHER LANGUAGE) Do NOT use Java library implementations of the data structures (queues, lists, STs, hashtables etc.) Have a unit test implemented in main(). And comment every code. Show examples from the executions. Assume that the edges defined by the vertex pairs are two-way. Question: First step: write a program based on DFS which can answer questions of the type: "Find the a path from X to Y" Which should result in a list of...
Language: Java or C (NO OTHER LANGUAGE) Do NOT use Java library implementations of the data...
Language: Java or C (NO OTHER LANGUAGE) Do NOT use Java library implementations of the data structures (queues, lists, STs, hashtables etc.) Have a unit test implemented in main(). And comment every code. Show examples from the executions. Question: First step: write a program based on DFS which can answer questions of the type: "Find the a path from X to Y" Which should result in a list of vertices traversed from X to Y if there is a path....
I need this done in JAVA. Define a class named Cash. The class contains the following...
I need this done in JAVA. Define a class named Cash. The class contains the following public elements: A Double stored property that contains the amount of money (dollars and cents) described by an object of the class. A read-only, computed property. It calculates and returns the minimum number of U.S. bills and coins that add up to the amount in the stored property.  The return value is an Int array of length 9 that contains (beginning with index 0 of...
You need to describe these financial statements. The statements are the profit and loss statement, statement...
You need to describe these financial statements. The statements are the profit and loss statement, statement if retained earnings, banalce sheet and the cash flow statement. For each of these reports describe what they are, what is involved in their preparation and how they are dealt with in preparing the financial reports. 800 words
For this Assignment you will need to define the following sectors and describe the role that...
For this Assignment you will need to define the following sectors and describe the role that they play: (The Private Sector) Business (The Nonprofit Sector) Charities & Foundations (The Public Sector) Government You should utilize additional resources. Please submit a minimum of 100 words per item, and remember to cite your sources.
What is a connectivity system? When do you need one? Define and describe the hardware. Define...
What is a connectivity system? When do you need one? Define and describe the hardware. Define and describe the software.
Write the program in Java. Demonstrate that you know how to define variables, create conditional statements,...
Write the program in Java. Demonstrate that you know how to define variables, create conditional statements, write a loop, use arrays, obtain input from the user, display output, test and create a JavaDoc. Create project PaystubTest2 that is a Paystub calculator with program Paystub##.java (where ## is your initials) based on user input. (10 points) You must use the ReadStringFromUser and ReadFloatFromUser methods in the program to obtain user input. (20 points) This program will calculate the Gross Earnings, FICA...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT