Question

I am learning about compilers and am trying to understand what goes on in the separate...

I am learning about compilers and am trying to understand what goes on in the separate phases. The questions I have are dealing with a 2-phase compiler. So, the front-end and the back-end. In the front-end is where we have the lexical analysis, syntax analysis, and semantic analysis. In the back-end is where we have instruction selection, register allocation, and instruction scheduling.

I am given some situations that produce errors and told to determine if the error could be detected by a compiler and in which phase it occurs.

A statement in an Ada program is missing the terminating semicolon. I know this would be detected in the front-end, but I'm not sure if it would be deteced by the lexical analyzer, syntax analyzer, or semantic analyzer. The lexical analyzer goes through each line character by character and separates them into tokens. So for something like "x = y + 1;" the tokens are <x>, <=>, <y>, <+>, <1>, <;>. So if the semicolon was mission, would the lexical analyzer get to the end of the line and detect that there is no semicolon and raise the error? Or would something like "x = x + 1" be detected by the syntax analyzer. The syntax analyzer checks to see if the programs structure is legal for the language we are compiling. In this case, since we are missing the semicolon, it wouldn't be legal, would it? I could also see how this would be detected by the semantic analyzer too though. My problem is determining which one it is. Any help would be appreciated.

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
I am learning about compilers and am trying to understand what goes on in the separate...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • A python program contains an import statement for a module that does not exist on the...

    A python program contains an import statement for a module that does not exist on the computer it is run on. I'm trying to determine which phase of a compiler would detect this error. I know it wouldn't be in the lexiacl analysis phase since the lexical analyzer doesn’t try to make sense of the program beyond trying to recognize tokens. I don't think this would be detected in the syntax phase since we are checking to see if the...

  • How to replace elements in a 2D array? Okay so for my program, I am trying...

    How to replace elements in a 2D array? Okay so for my program, I am trying to create a fish tank. My program is to generate 4 different FISH: ><))'> in a tank of tilde (~) characters. The tank is a 2D array of 8 rows and 32 columns so it would look like ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for one of the eight rows (before I generate the random positions of the fish in the rank). Then one row could look like ~~~~~~~~~~><))'>~~~~~~~~~~~~~~~~...

  • I am trying to understand this material how can i go about solving #4 3. (8...

    I am trying to understand this material how can i go about solving #4 3. (8 points total) Suppose a firm has the following benefit and cost structure: B(Q) 140Q 302 C(Q) 0.50 a. Find the MB(Q) and MC(Q) functions. b. What value of Q maximizes the Net Benefit NB(Q) B(Q)-C(Q)? 4. (50 points total) Abby is a first grader who likes to drink milk and juice. Suppose her parents give her $12 a week in pocket money to spend...

  • Please help me with the following C Programming project. I am providing the code I used...

    Please help me with the following C Programming project. I am providing the code I used which needs to be reworked to add the following requirements. Here is my code #include<stdio.h> char input; int main() { int i = 0; while (true){ scanf_s("%c", &input); if (input == 'X') break; printf("%c", input); } return 0; } Here are the requirements for the code plus and additional note what the code should have. Goals Understand the ASCII representation of character values. Understand...

  • C PROGRAM When you print out the old and new bitsets, which are of type unsigned...

    C PROGRAM When you print out the old and new bitsets, which are of type unsigned char, please use the %p control character in the printff statement rather than %x or %d or %c. The compiler will complain, but we don't always listen to them anyway. The difference is it will print the bitset out in hex with a preceeding %0x. unsigned char bitset = 0x14 ; printf("Bitsrt is %p\n", bitset) ; results in Bitset is 0x14, which is what...

  • I am completing a study guide for the next section of class because I am trying...

    I am completing a study guide for the next section of class because I am trying to get ahead. Any suggestions? A wave whose displacement velocity is either in the same direction or opposite direction as the wave velocity describes which type of a wave? a. Transverse wave b. Mechanical wave c. Longitudinal wave d. Electromagnetic wave Which of the following are always one wavelength apart and are drawn as parallel lines? Plane waves b. Wave fronts c. Wave phase...

  • I am currently trying to figure out the experiment below. Please complete Table 1 with an...

    I am currently trying to figure out the experiment below. Please complete Table 1 with an explanation, I appreciate it thank you!  Promise to give thumbs up! Introduction The phase differences between the output voltage, the voltage across the inductor, the voltage across the capacitor, and the voltage across the resistor will be examined at resonant frequency. The voltage and phase relationship will also be examined for frequencies above and below resonance. Theory An inductor, a capacitor, and a resistor are...

  • The answer i am looking for is 7.4786% but i have no idea what to do....

    The answer i am looking for is 7.4786% but i have no idea what to do. Any help would be great, also please show work so i can follow what to do. Thank you. Exercise (9.11) Suppose that ZYX's loan in Example (9.10) is 400 million at time 0, and that ZYX has agreed to pay interest at the 1-year spot rate and also repay 100 million of principal at the end of each of the 4 years. ZYX enters...

  • I am looking for help with just trial one. I am not sure what equations to use or how to go about even answering these questions. I figure if I can get help with trial 1 I should be able to do trial 2...

    I am looking for help with just trial one. I am not sure what equations to use or how to go about even answering these questions. I figure if I can get help with trial 1 I should be able to do trial 2 on my own. ( This week has been really bad, I lost my grandfather, so if you could "dumb" down the steps as much as possible I would appreciate it, my brain is just not working...

  • I would like some assistance correcting an issue I am having with this assignment. Once a...

    I would like some assistance correcting an issue I am having with this assignment. Once a finite state automaton (FSA) is designed, its transition diagram can be translated in a straightforward manner into program code. However, this translation process is considerably tedious if the FSA is large and troublesome if the design is modified. The reason is that the transition information and mechanism are combined in the translation. To do it differently, we can design a general data structure such...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT