1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
fredd [130]
3 years ago
14

In chapter 3, we discussed syntax and semantics, in general there are two types of grammars for programming languages, regular a

nd context-free, what is the difference, what is the scope (where are they applied), and how can the use of these grammars produce a higher level of program reliability. Does this higher level of reliability encourage complexity?
Computers and Technology
1 answer:
WARRIOR [948]3 years ago
8 0

Answer:

Lexical rules that are defined in case of regular grammar are simple and the notation is quite easy to understand.

Regular expression are useful for defining constructs of identifiers or constants. e.g. a|b etc.

In the case of context-free, grammar is not simple and deals with the productions.

Context-free are useful in describing the nested constructs like if-else etc which are not defined by regular expressions.

These produce a higher level of reliability as it provides a medium for generating syntactical as well as semantic data. The grammar is context-free is a little complex.

Explanation:

You might be interested in
Write the definition of a method named countPos that receives a reference to a Scanner object associated with a stream of input
NNADVOKAT [17]

Answer:

Here is the method countPos    

  static int countPos(Scanner input){ //method that takes a reference to a Scanner object

   int counter=0;  // to count the positive integers  

   int number; //to store each integer value

   if(input.hasNextInt()){ //checks if next token in this scanner input is an integer value

       number=input.nextInt(); //nextInt() method of a Scanner object reads in a string of digits and converts them into an int type and stores it into number variable

       counter=countPos(input); //calls method by passing the Scanner object and stores it in counter variable

       if(number>0) //if the value is a positive number

           counter++;    } //adds 1 to the counter variable each time a positive input value is enountered

   else    { //if value is not a positive integer

       return counter;    } //returns the value of counter

   return counter; } //returns the total count of the positive numbers

Explanation:

Here is the complete program:

import java.util.Scanner; //to take input from user

public class Main { //class name

//comments with each line of method below are given in Answer section

static int countPos(Scanner input){

   int counter=0;

   int number;

   if(input.hasNextInt()){

       number=input.nextInt();

       counter=countPos(input);

       if(number>0)

           counter++;    }

   else    {

       return counter;    }

   return counter; }

public static void main(String[] args) { //start of main function

       System.out.println("Number of positive integers: " + countPos(new Scanner(System.in)));  } } //prints the number of positive integers by calling countPos method and passing Scanner object to it

The program uses hasNextInt method that returns the next token (next input value) and if condition checks using this method if the input value is an integer. nextInt() keeps scanning the next token of the input as an integer. If the input number is a positive number then the counter variable is incremented to 1 otherwise not. If the use enters anything other than an integer value then the program stops and returns the total number of positive integers input by the user. This technique is used in order to avoid using any loop. The program and its output is attached

3 0
3 years ago
Select the correct answer. Larry finds it easy to run legacy programs and applications in a virtualized environment. How does th
muminat

The answer is B: installs and runs different versions of an operating system on the same computing device

Virtual machines are like guest operating systems or application environments that give you the perception that you are physically connected to a different box. A system virtual machine, for instance, copies all the components and processes of a real computer. It helps the user experiment with different operating systems and applications without the need to install them on your physical hardware.


8 0
3 years ago
Please help ASAP!
makkiz [27]
B. training is the correct answer
8 0
2 years ago
A. The client is running in a loop:
Ierofanga [76]
Aaaaaaaaaaaaaaaaaaaaaaaaaaaa
4 0
3 years ago
The directory "a" contains its subdirectory "b" and there is no other entry in the directory "a". You want to display "the conte
Svet_ta [14]

The answer assumes that the question is about which command help accomplish display directory contents in Unix-like operating systems.

Answer:

The command is <em>ls</em>.

Explanation:

The command <em>ls</em> (short for <em>list</em>) displays a variety of important information in different ways regarding any directory contents. Because of this, it is probably one of the most used commands in Unix-like operating systems.

Any directory can contain directories and files of different sizes, recently created/modified, attributes like permissions for being accessed, and, with this command, we can see all this information by size, chronologically, by owner, and/or by many more ways.  

In the question, we can accomplish to list that the directory "a" contains its sub-directory "b" and no other entry using the next line of code:

Command-line 1: \\ ls\; a (<em>the command "says": display content of a</em>)

Result: b

The result is only the directory <em>b </em>because there is no other entry in it.

To display more information regarding <em>b</em>, we can use the many options available for the command <em>ls</em>, like <em>-a</em> (all entries), <em>-d</em> (only directories), <em>-l</em> (long listing format), and so on, e.g. ls -a  A (display all entries in directory A, included hidden files).

6 0
3 years ago
Other questions:
  • Approximately what percent of U.S. businesses have some form of remote work program? (from Chapter 1)
    14·1 answer
  • I just started game development using unity, I’m trying to control my sphere moving on a flat surface using the W,A,S,D keys, if
    11·1 answer
  • The concept of plug and play" is demonstrated by which of the following
    15·1 answer
  • Can anybody come up with a catchy title for this?
    11·1 answer
  • the part of the computer that contains the brain , or central processing unit , is also known the what ?
    12·1 answer
  • What was the process called that required the photographer to have a tent or darkroom handy so that chemicals could be mixed qui
    7·1 answer
  • Create a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop shou
    5·1 answer
  • Complete the sentence with the correct response.
    12·1 answer
  • The code on the side is a software solution to the mutual exclusion problem for two processes. It shares two variables:
    11·1 answer
  • What is not recyclable in a<br> hybrid car<br> hydrogen car<br> petrol car
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!