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

Suppose you define the class myGrid in Java. Suppose further that my Image[][] is a variable...
Suppose you define the class myGrid in Java. Suppose further that my Image[][] is a variable defined to be a 2D array with 100 rows and 100 columns of type myGrid, and that the myGrid class has two methods: setX()and setY(). Write the Java code snippet to instantiate every cell of myImage[][]with myGrid objects, and use the setX()and setY()methods to store the row and the column location of each myGrid object in the array.
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...
***Need 200 words in total for the 3 question about LINUX below*** What is the syntax...
***Need 200 words in total for the 3 question about LINUX below*** What is the syntax used to identify operating systems in the GRUB menu? What do the systemctl set-default graphical.target commands do? How does the multi-user.target file differ from the graphical.target file?
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
c++ programing. Objectives Further practice with classes Use of inheritance Use compositions Define a class called...
c++ programing. Objectives Further practice with classes Use of inheritance Use compositions Define a class called Person with private members name of type string, and money of integer type. The class has the public member functions set(), getMoney(), print(), and a parameterized constructor with default values. Define a class called Patient with private data members name of type string, durationOfTreatment, and TreatmentCost of type integer. The class has the public member functions set(), getCost(), getDuration(), print(), and a parameterized constructor...
Java or python. The clients need to be able to communicate with each other using the...
Java or python. The clients need to be able to communicate with each other using the command line. The "local chat" program should be implemented using a client/Server model based on UDP protocol. Requirements: 1. The chat is performed between 2 clients and not the server. 2. The server will first start up and choose a port number. Then the server prints out its IP address and port number. 3. The client then will start up and create a socket...
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....
-Kindly define each of the below-listed terms. Further, use each term in a written sentence to...
-Kindly define each of the below-listed terms. Further, use each term in a written sentence to demonstrate that you have a firm understanding of the term from a sociological perspective. 1) Theory 2) Inequality 3) Capitalism 4) Stratification
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT